From be9707599969a1cf1a80bff6fb13fbcb8a4b659f Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Fri, 11 May 2012 00:05:32 +0200 Subject: digital/beacon: laser_engage_angle_confirmation() hanndles top 0 position --- digital/beacon/src/laser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'digital') diff --git a/digital/beacon/src/laser.c b/digital/beacon/src/laser.c index 27638678..bc5b7466 100644 --- a/digital/beacon/src/laser.c +++ b/digital/beacon/src/laser.c @@ -85,7 +85,16 @@ void laser_inhibit_angle_confirmation(void) /* This function configures the AVR OC3B interrupt that will send the angle LASER_SENDING_OFFSET after the latest rising edge */ void laser_engage_angle_confirmation(uint16_t value) { - OCR3A = value + LASER_CONFIRMATION_OFFSET; + if(value > CODEWHEEL_CPR - LASER_CONFIRMATION_OFFSET) + { + OCR3B = LASER_CONFIRMATION_OFFSET - (CODEWHEEL_CPR - value); + } + else + { + OCR3B = value + LASER_CONFIRMATION_OFFSET; + } + + /* Enable interrupt */ TIMSK3 |= (1<