summaryrefslogtreecommitdiff
path: root/digital/beacon/src/laser.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/beacon/src/laser.c')
-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();
}