summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorent Duchon2012-04-22 22:49:28 +0200
committerFlorent Duchon2012-05-04 00:06:27 +0200
commit94e2e1e4af9b973b888f00988b0cfeb2d69eb99a (patch)
tree7429ebe4a467c628ab9cfe93bdbce05384aef34e
parentb918019c6bd7d07ffc22e5a0bf91b699a7bace1a (diff)
digital/beacon: add comments & line feed
-rw-r--r--digital/beacon/src/laser.c12
1 files changed, 12 insertions, 0 deletions
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();
}