From b9639cc703c6ff0ab6ffc2dfa8be0b07251db7ac Mon Sep 17 00:00:00 2001 From: Kai Ryu Date: Thu, 17 Jul 2014 14:16:35 +0900 Subject: [PATCH] Add macro to make breathing led to use timer1 if timer3 is in other use --- common/breathing_led.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/common/breathing_led.c b/common/breathing_led.c index 4e4822f8..11346e8f 100644 --- a/common/breathing_led.c +++ b/common/breathing_led.c @@ -10,6 +10,18 @@ static uint8_t breathing_led_duration = 0; void breathing_led_init(void) { +#ifdef BREATHING_LED_TIMER1 + /* Timer1 setup */ + /* CTC mode */ + TCCR1B |= (1<>8)&0xff; + OCR1AL = BREATHING_LED_TIMER_TOP&0xff; +#else /* Timer3 setup */ /* CTC mode */ TCCR3B |= (1<>8)&0xff; OCR3AL = BREATHING_LED_TIMER_TOP&0xff; +#endif SREG = sreg; } void breathing_led_enable(void) { /* Enable Compare Match Interrupt */ +#ifdef BREATHING_LED_TIMER1 + TIMSK1 |= (1<