Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void exti0_isr(void)
- {
- exti_reset_request(EXTI0);
- encoder.stateA = gpio_get(GPIOA, GPIO0);
- // encoder.stateB = gpio_get(GPIOA, GPIO4);
- // and adjust counter + if A leads B
- encoder.count += encoder.stateA!=encoder.stateB ? +1 : -1;
- }
- void exti4_isr(void)
- {
- //Counter-Clockwise
- exti_reset_request(EXTI4);
- // encoder.stateA = gpio_get(GPIOA, GPIO0);
- encoder.stateB = gpio_get(GPIOA, GPIO4);
- // and adjust counter + if B follows A
- encoder.count += encoder.stateA == encoder.stateB ? +1 : -1;
- gpio_toggle(GPIOD, GPIO12);
- }
Advertisement
Add Comment
Please, Sign In to add comment