47 #include <avr/interrupt.h>
52 #include "rtimer-arch.h"
54 #if defined(__AVR_ATmega1281__) || defined(__AVR_ATmega1284P__)
68 #if defined(__AVR_AT90USB1287__) || defined(__AVR_ATmega128RFA1__)
74 #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega644__)
82 extern uint8_t debugflowsize,debugflow[DEBUGFLOWSIZE];
83 #define DEBUGFLOW(c) if (debugflowsize<(DEBUGFLOWSIZE-1)) debugflow[debugflowsize++]=c
89 #if defined(TCNT3) && RTIMER_ARCH_PRESCALER
90 ISR (TIMER3_COMPA_vect) {
92 ENERGEST_ON(ENERGEST_TYPE_IRQ);
95 ETIMSK &= ~((1 << OCIE3A) | (1 << OCIE3B) | (1 << TOIE3) |
96 (1 << TICIE3) | (1 << OCIE3C));
98 #if RTIMER_CONF_NESTED_INTERRUPTS
107 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
111 #elif RTIMER_ARCH_PRESCALER
112 #warning "No Timer3 in rtimer-arch.c - using Timer1 instead"
113 ISR (TIMER1_COMPA_vect) {
115 TIMSK &= ~((1<<TICIE1)|(1<<OCIE1A)|(1<<OCIE1B)|(1<<TOIE1));
124 rtimer_arch_init(
void)
126 #if RTIMER_ARCH_PRESCALER
134 ETIMSK &= ~((1 << OCIE3A) | (1 << OCIE3B) | (1 << TOIE3) |
135 (1 << TICIE3) | (1 << OCIE3C));
137 ETIFR |= (1 << ICF3) | (1 << OCF3A) | (1 << OCF3B) | (1 << TOV3) |
148 #if RTIMER_ARCH_PRESCALER==1024
150 #elif RTIMER_ARCH_PRESCALER==256
152 #elif RTIMER_ARCH_PRESCALER==64
154 #elif RTIMER_ARCH_PRESCALER==8
156 #elif RTIMER_ARCH_PRESCALER==1
159 #error Timer3 PRESCALER factor not supported.
162 #elif RTIMER_ARCH_PRESCALER
166 TIMSK &= ~((1<<TICIE1)|(1<<OCIE1A)|(1<<OCIE1B)|(1<<TOIE1));
167 TIFR |= (1 << ICF1) | (1 << OCF1A) | (1 << OCF1B) | (1 << TOV1);
177 #if RTIMER_ARCH_PRESCALER==1024
179 #elif RTIMER_ARCH_PRESCALER==256
181 #elif RTIMER_ARCH_PRESCALER==64
183 #elif RTIMER_ARCH_PRESCALER==8
185 #elif RTIMER_ARCH_PRESCALER==1
188 #error Timer1 PRESCALER factor not supported.
199 rtimer_arch_schedule(rtimer_clock_t t)
201 #if RTIMER_ARCH_PRESCALER
211 ETIFR |= (1 << ICF3) | (1 << OCF3A) | (1 << OCF3B) | (1 << TOV3) |
214 ETIMSK |= (1 << OCIE3A);
216 #elif RTIMER_ARCH_PRESCALER
219 TIFR |= (1 << ICF1) | (1 << OCF1A) | (1 << OCF1B) | (1 << TOV1);
220 TIMSK |= (1 << OCIE1A);