TheLegace

Untitled

Apr 14th, 2013
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. void exti0_isr(void)
  2. {
  3.     exti_reset_request(EXTI0);
  4.     encoder.stateA = gpio_get(GPIOA, GPIO0);
  5.     // encoder.stateB = gpio_get(GPIOA, GPIO4);
  6.     // and adjust counter + if A leads B
  7.     encoder.count += encoder.stateA!=encoder.stateB  ? +1 : -1;
  8. }
  9.  
  10. void exti4_isr(void)
  11. {
  12.     //Counter-Clockwise
  13.     exti_reset_request(EXTI4);
  14.     // encoder.stateA = gpio_get(GPIOA, GPIO0);
  15.     encoder.stateB = gpio_get(GPIOA, GPIO4);
  16.     // and adjust counter + if B follows A
  17.     encoder.count += encoder.stateA == encoder.stateB ? +1 : -1;
  18.     gpio_toggle(GPIOD, GPIO12);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment