COSA
An Object-Oriented Platform for Arduino Programming
RTT_Config.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_RTT_CONFIG_HH
22 #define COSA_RTT_CONFIG_HH
23 
24 // Real-Time Timer Configuration
25 #define COUNT 250
26 #define PRESCALE 64
27 #define TIMER_MAX (COUNT - 1)
28 #define US_PER_TIMER_CYCLE (PRESCALE / I_CPU)
29 #define US_PER_TICK (COUNT * US_PER_TIMER_CYCLE)
30 #define MS_PER_TICK (US_PER_TICK / 1000)
31 #define US_DIRECT_EXPIRE (800 / I_CPU)
32 #define US_TIMER_EXPIRE (US_PER_TICK - 1)
33 
34 // Real-Time Timer Registers. Use Timer2 if available to keep
35 // timer running in low power mode
36 #if defined(TIMER2_COMPA_vect)
37 #define timern_enable timer2_enable
38 #define timern_disable timer2_disable
39 #define TCCRnB TCCR2B
40 #define CSn _BV(CS22)
41 #define TCCRnA TCCR2A
42 #define OCRnA OCR2A
43 #define OCRnB OCR2B
44 #define TIMSKn TIMSK2
45 #define TCNTn TCNT2
46 #define TIFRn TIFR2
47 #define TIMERn_COMPA_vect TIMER2_COMPA_vect
48 #define TIMERn_COMPB_vect TIMER2_COMPB_vect
49 #elif defined(TCNT0)
50 #define timern_enable timer0_enable
51 #define timern_disable timer0_disable
52 #define TCCRnB TCCR0B
53 #define CSn (_BV(CS01) | _BV(CS00))
54 #define TCCRnA TCCR0A
55 #define OCRnA OCR0A
56 #define OCRnB OCR0B
57 #define TIMSKn TIMSK0
58 #define TCNTn TCNT0
59 #define TIFRn TIFR0
60 #define TIMERn_COMPA_vect TIMER0_COMPA_vect
61 #define TIMERn_COMPB_vect TIMER0_COMPB_vect
62 #endif
63 #endif