+// -----------------------------------------------------------------------------
+// Timer Abstractions
+// -----------------------------------------------------------------------------
+
+//Currently we support timers 1 and 3 used at the sime time, channels A-C,
+//pins PB5, PB6, PB7, PC4, PC5, and PC6
+#if defined(C6_AUDIO)
+ #define CPIN_AUDIO
+ #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC6);
+ #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3A1) | (0 << COM3A0) | (1 << WGM31) | (0 << WGM30);
+ #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3A)
+ #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3A)
+ #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3A1);
+ #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3A1) | _BV(COM3A0));
+ #define TIMER_3_PERIOD ICR3
+ #define TIMER_3_DUTY_CYCLE OCR3A
+ #define TIMER3_AUDIO_vect TIMER3_COMPA_vect
+#endif
+#if defined(C5_AUDIO)
+ #define CPIN_AUDIO
+ #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC5);
+ #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3B1) | (0 << COM3B0) | (1 << WGM31) | (0 << WGM30);
+ #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3B)
+ #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3B)
+ #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3B1);
+ #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3B1) | _BV(COM3B0));
+ #define TIMER_3_PERIOD ICR3
+ #define TIMER_3_DUTY_CYCLE OCR3B
+ #define TIMER3_AUDIO_vect TIMER3_COMPB_vect
+#endif
+#if defined(C4_AUDIO)
+ #define CPIN_AUDIO
+ #define CPIN_SET_DIRECTION DDRC |= _BV(PORTC4);
+ #define INIT_AUDIO_COUNTER_3 TCCR3A = (0 << COM3C1) | (0 << COM3C0) | (1 << WGM31) | (0 << WGM30);
+ #define ENABLE_AUDIO_COUNTER_3_ISR TIMSK3 |= _BV(OCIE3C)
+ #define DISABLE_AUDIO_COUNTER_3_ISR TIMSK3 &= ~_BV(OCIE3C)
+ #define ENABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A |= _BV(COM3C1);
+ #define DISABLE_AUDIO_COUNTER_3_OUTPUT TCCR3A &= ~(_BV(COM3C1) | _BV(COM3C0));
+ #define TIMER_3_PERIOD ICR3
+ #define TIMER_3_DUTY_CYCLE OCR3C
+ #define TIMER3_AUDIO_vect TIMER3_COMPC_vect
+#endif