From 94e2e1e4af9b973b888f00988b0cfeb2d69eb99a Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Sun, 22 Apr 2012 22:49:28 +0200 Subject: digital/beacon: add comments & line feed --- digital/beacon/src/laser.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c index ffbdbcbb..205b60be 100644 --- a/digital/beacon/src/laser.c +++ b/digital/beacon/src/laser.c @@ -117,20 +117,29 @@ ISR(TIMER3_CAPT_vect) static uint16_t virtual_angle = 0; TLaser_edge_type current_edge; + /* Check which kind of edge triggered the interrupt */ current_edge = laser_get_edge_type(); switch(current_edge) { + /* First rising edge of a reflector */ case LASER_FIRST_RISING_EDGE: virtual_angle = ICR3; break; + + /* Common rising edge of a reflector */ case LASER_RISING_EDGE: + /* Could be a bounce so inhibit the latest angle confirmation */ laser_inhibit_angle_confirmation(); + /* Recompute the angle value */ virtual_angle = (virtual_angle + ICR3) / 2; break; + + /* Falling edge detected */ case LASER_FALLING_EDGE: + /* Recompute the angle value */ virtual_angle = (virtual_angle + ICR3) / 2; @@ -140,8 +149,11 @@ ISR(TIMER3_CAPT_vect) /* Start virtual angle confirmation */ laser_engage_angle_confirmation(ICR3); break; + default: break; } + + /* Invert the edge detection to catch next rising or falling edge */ laser_invert_IRQ_edge_trigger(); } -- cgit v1.2.3