// asynchronous timer source bit.. if set, use 32khz frequency
.as2 = AVR_IO_REGBIT(ASSR, AS0),
- .r_ocra = OCR0,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV0),
.vector = TIMER0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE0),
- .raised = AVR_IO_REGBIT(TIFR, OCF0),
- .vector = TIMER0_COMP_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0),
+ .vector = TIMER0_COMP_vect,
+ },
+ },
},
},
.timer1 = {
.cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* TODO: 2 External clocks */},
- .r_ocra = OCR1AL,
- .r_ocrb = OCR1BL,
- .r_ocrc = OCR1CL,
.r_tcnt = TCNT1L,
.r_icr = ICR1L,
.r_icrh = ICR1H,
- .r_ocrah = OCR1AH, // 16 bits timers have two bytes of it
- .r_ocrbh = OCR1BH,
- .r_ocrch = OCR1CH,
.r_tcnth = TCNT1H,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV1),
.vector = TIMER1_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
- .raised = AVR_IO_REGBIT(TIFR, OCF1A),
- .vector = TIMER1_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
- .raised = AVR_IO_REGBIT(TIFR, OCF1B),
- .vector = TIMER1_COMPB_vect,
- },
- .compc = {
- .enable = AVR_IO_REGBIT(ETIMSK, OCIE1C),
- .raised = AVR_IO_REGBIT(ETIFR, OCF1C),
- .vector = TIMER1_COMPC_vect,
- },
.icr = {
.enable = AVR_IO_REGBIT(TIMSK, TICIE1),
.raised = AVR_IO_REGBIT(TIFR, ICF1),
.vector = TIMER1_CAPT_vect,
},
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR1AL,
+ .r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1A),
+ .vector = TIMER1_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR1BL,
+ .r_ocrh = OCR1BH,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1B),
+ .vector = TIMER1_COMPB_vect,
+ },
+ },
+ [AVR_TIMER_COMPC] = {
+ .r_ocr = OCR1CL,
+ .r_ocrh = OCR1CH,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(ETIMSK, OCIE1C),
+ .raised = AVR_IO_REGBIT(ETIFR, OCF1C),
+ .vector = TIMER1_COMPC_vect,
+ },
+ },
+ },
+
},
.timer2 = {
.name = '2',
.cs = { AVR_IO_REGBIT(TCCR2, CS20), AVR_IO_REGBIT(TCCR2, CS21), AVR_IO_REGBIT(TCCR2, CS22) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* TODO external clock */ },
- .r_ocra = OCR2,
.r_tcnt = TCNT2,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV2),
.vector = TIMER2_OVF_vect,
},
- .compa = { // compa is just COMP
- .enable = AVR_IO_REGBIT(TIMSK, OCIE2),
- .raised = AVR_IO_REGBIT(TIFR, OCF2),
- .vector = TIMER2_COMP_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR2,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE2),
+ .raised = AVR_IO_REGBIT(TIFR, OCF2),
+ .vector = TIMER2_COMP_vect,
+ },
+ },
},
},
.timer3 = {
.cs = { AVR_IO_REGBIT(TCCR3B, CS30), AVR_IO_REGBIT(TCCR3B, CS31), AVR_IO_REGBIT(TCCR3B, CS32) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* TODO: 2 External clocks */},
- .r_ocra = OCR3AL,
- .r_ocrb = OCR3BL,
- .r_ocrc = OCR3CL,
.r_tcnt = TCNT3L,
.r_icr = ICR3L,
.r_icrh = ICR3H,
- .r_ocrah = OCR3AH, // 16 bits timers have two bytes of it
- .r_ocrbh = OCR3BH,
- .r_ocrch = OCR3CH,
.r_tcnth = TCNT3H,
.overflow = {
.raised = AVR_IO_REGBIT(ETIFR, TOV3),
.vector = TIMER3_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(ETIMSK, OCIE3A),
- .raised = AVR_IO_REGBIT(ETIFR, OCF3A),
- .vector = TIMER3_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(ETIMSK, OCIE3B),
- .raised = AVR_IO_REGBIT(ETIFR, OCF3B),
- .vector = TIMER3_COMPB_vect,
- },
- .compc = {
- .enable = AVR_IO_REGBIT(ETIMSK, OCIE3C),
- .raised = AVR_IO_REGBIT(ETIFR, OCF3C),
- .vector = TIMER3_COMPC_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR3AL,
+ .r_ocrh = OCR3AH, // 16 bits timers have two bytes of it
+ .com = { AVR_IO_REGBIT(TCCR3A, COM3A1), AVR_IO_REGBIT(TCCR3A, COM3A0) },
+ .com_pin = AVR_IO_REGBIT(PORTE, PE3),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(ETIMSK, OCIE3A),
+ .raised = AVR_IO_REGBIT(ETIFR, OCF3A),
+ .vector = TIMER3_COMPA_vect,
+ }
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR3BL,
+ .r_ocrh = OCR3BH,
+ .com = { AVR_IO_REGBIT(TCCR3A, COM3B1), AVR_IO_REGBIT(TCCR3A, COM3B0) },
+ .com_pin = AVR_IO_REGBIT(PORTE, PE4),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(ETIMSK, OCIE3B),
+ .raised = AVR_IO_REGBIT(ETIFR, OCF3B),
+ .vector = TIMER3_COMPB_vect,
+ }
+ },
+ [AVR_TIMER_COMPC] = {
+ .r_ocr = OCR3CL,
+ .r_ocrh = OCR3CH,
+ .com = { AVR_IO_REGBIT(TCCR3A, COM3C1), AVR_IO_REGBIT(TCCR3A, COM3C0) },
+ .com_pin = AVR_IO_REGBIT(PORTE, PE5),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(ETIMSK, OCIE3C),
+ .raised = AVR_IO_REGBIT(ETIFR, OCF3C),
+ .vector = TIMER3_COMPC_vect,
+ }
+ }
},
.icr = {
.enable = AVR_IO_REGBIT(ETIMSK, TICIE3),
.cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR0A,
- .r_ocrb = OCR0B,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR0, TOV0),
.vector = TIMER0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
- .vector = TIMER0_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
- .vector = TIMER0_COMPB_vect,
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
+ .vector = TIMER0_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR0B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
+ .vector = TIMER0_COMPB_vect,
+ }
+ }
+ }
},
.timer1 = {
.name = '1',
.cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* External clock T1 is not handled */},
- .r_ocra = OCR1AL,
- .r_ocrb = OCR1BL,
.r_tcnt = TCNT1L,
.r_icr = ICR1L,
.r_icrh = ICR1H,
- .r_ocrah = OCR1AH, // 16 bits timers have two bytes of it
- .r_ocrbh = OCR1BH,
.r_tcnth = TCNT1H,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR1, TOV1),
.vector = TIMER1_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK1, OCIE1A),
- .raised = AVR_IO_REGBIT(TIFR1, OCF1A),
- .vector = TIMER1_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK1, OCIE1B),
- .raised = AVR_IO_REGBIT(TIFR1, OCF1B),
- .vector = TIMER1_COMPB_vect,
- },
.icr = {
.enable = AVR_IO_REGBIT(TIMSK1, ICIE1),
.raised = AVR_IO_REGBIT(TIFR1, ICF1),
.vector = TIMER1_CAPT_vect,
},
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR1AL,
+ .r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK1, OCIE1A),
+ .raised = AVR_IO_REGBIT(TIFR1, OCF1A),
+ .vector = TIMER1_COMPA_vect,
+ }
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR1BL,
+ .r_ocrh = OCR1BH,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK1, OCIE1B),
+ .raised = AVR_IO_REGBIT(TIFR1, OCF1B),
+ .vector = TIMER1_COMPB_vect,
+ }
+ }
+ }
},
.timer2 = {
.name = '2',
.cs = { AVR_IO_REGBIT(TCCR2B, CS20), AVR_IO_REGBIT(TCCR2B, CS21), AVR_IO_REGBIT(TCCR2B, CS22) },
.cs_div = { 0, 0, 3 /* 8 */, 5 /* 32 */, 6 /* 64 */, 7 /* 128 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR2A,
- .r_ocrb = OCR2B,
.r_tcnt = TCNT2,
// asynchronous timer source bit.. if set, use 32khz frequency
.raised = AVR_IO_REGBIT(TIFR2, TOV2),
.vector = TIMER2_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK2, OCIE2A),
- .raised = AVR_IO_REGBIT(TIFR2, OCF2A),
- .vector = TIMER2_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK2, OCIE2B),
- .raised = AVR_IO_REGBIT(TIFR2, OCF2B),
- .vector = TIMER2_COMPB_vect,
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR2A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK2, OCIE2A),
+ .raised = AVR_IO_REGBIT(TIFR2, OCF2A),
+ .vector = TIMER2_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR2B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK2, OCIE2B),
+ .raised = AVR_IO_REGBIT(TIFR2, OCF2B),
+ .vector = TIMER2_COMPB_vect,
+ },
+ }
+ }
},
.spi = {
.disabled = AVR_IO_REGBIT(PRR,PRSPI),
.cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR0A,
- .r_ocrb = OCR0B,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR0, TOV0),
.vector = TIMER0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
- .vector = TIMER0_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
- .vector = TIMER0_COMPB_vect,
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0A,
+ .com = { AVR_IO_REGBIT(TCCR0A, COM0A0), AVR_IO_REGBIT(TCCR0A, COM0A1) },
+ .com_pin = AVR_IO_REGBIT(PORTD, 6),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
+ .vector = TIMER0_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR0B,
+ .com = { AVR_IO_REGBIT(TCCR0A, COM0B0), AVR_IO_REGBIT(TCCR0A, COM0B1) },
+ .com_pin = AVR_IO_REGBIT(PORTD, 5),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
+ .vector = TIMER0_COMPB_vect,
+ }
+ }
+ }
},
.timer1 = {
.name = '1',
.cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* External clock T1 is not handled */},
- .r_ocra = OCR1AL,
- .r_ocrb = OCR1BL,
.r_tcnt = TCNT1L,
.r_icr = ICR1L,
.r_icrh = ICR1H,
- .r_ocrah = OCR1AH, // 16 bits timers have two bytes of it
- .r_ocrbh = OCR1BH,
.r_tcnth = TCNT1H,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR1, TOV1),
.vector = TIMER1_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK1, OCIE1A),
- .raised = AVR_IO_REGBIT(TIFR1, OCF1A),
- .vector = TIMER1_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK1, OCIE1B),
- .raised = AVR_IO_REGBIT(TIFR1, OCF1B),
- .vector = TIMER1_COMPB_vect,
- },
.icr = {
.enable = AVR_IO_REGBIT(TIMSK1, ICIE1),
.raised = AVR_IO_REGBIT(TIFR1, ICF1),
.vector = TIMER1_CAPT_vect,
},
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR1AL,
+ .r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
+ .com = { AVR_IO_REGBIT(TCCR1A, COM1A0), AVR_IO_REGBIT(TCCR1A, COM1A1) },
+ .com_pin = AVR_IO_REGBIT(PORTB, 1),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK1, OCIE1A),
+ .raised = AVR_IO_REGBIT(TIFR1, OCF1A),
+ .vector = TIMER1_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR1BL,
+ .r_ocrh = OCR1BH,
+ .com = { AVR_IO_REGBIT(TCCR1A, COM1B0), AVR_IO_REGBIT(TCCR1A, COM1B1) },
+ .com_pin = AVR_IO_REGBIT(PORTB, 2),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK1, OCIE1B),
+ .raised = AVR_IO_REGBIT(TIFR1, OCF1B),
+ .vector = TIMER1_COMPB_vect,
+ },
+ },
+ },
},
.timer2 = {
.name = '2',
.cs = { AVR_IO_REGBIT(TCCR2B, CS20), AVR_IO_REGBIT(TCCR2B, CS21), AVR_IO_REGBIT(TCCR2B, CS22) },
.cs_div = { 0, 0, 3 /* 8 */, 5 /* 32 */, 6 /* 64 */, 7 /* 128 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR2A,
- .r_ocrb = OCR2B,
.r_tcnt = TCNT2,
// asynchronous timer source bit.. if set, use 32khz frequency
.raised = AVR_IO_REGBIT(TIFR2, TOV2),
.vector = TIMER2_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK2, OCIE2A),
- .raised = AVR_IO_REGBIT(TIFR2, OCF2A),
- .vector = TIMER2_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK2, OCIE2B),
- .raised = AVR_IO_REGBIT(TIFR2, OCF2B),
- .vector = TIMER2_COMPB_vect,
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR2A,
+ .com = { AVR_IO_REGBIT(TCCR2A, COM2A0), AVR_IO_REGBIT(TCCR2A, COM2A1) },
+ .com_pin = AVR_IO_REGBIT(PORTB, 3),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK2, OCIE2A),
+ .raised = AVR_IO_REGBIT(TIFR2, OCF2A),
+ .vector = TIMER2_COMPA_vect,
+ }
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR2B,
+ .com = { AVR_IO_REGBIT(TCCR2A, COM2B0), AVR_IO_REGBIT(TCCR2A, COM2B1) },
+ .com_pin = AVR_IO_REGBIT(PORTD, 3),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK2, OCIE2B),
+ .raised = AVR_IO_REGBIT(TIFR2, OCF2B),
+ .vector = TIMER2_COMPB_vect,
+ }
+ }
+ }
},
-
.spi = {
.disabled = AVR_IO_REGBIT(PRR,PRSPI),
.cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR0A,
- .r_ocrb = OCR0B,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR0, TOV0),
.vector = TIM0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
- .vector = TIM0_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
- .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
- .vector = TIM0_COMPB_vect,
- },
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0A),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0A),
+ .vector = TIM0_COMPA_vect,
+ }
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR0B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK0, OCIE0B),
+ .raised = AVR_IO_REGBIT(TIFR0, OCF0B),
+ .vector = TIM0_COMPB_vect,
+ }
+ }
+ }
+ }
};
static avr_t * make()
.cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR0A,
- .r_ocrb = OCR0B,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV0),
.vector = TIMER0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE0A),
- .raised = AVR_IO_REGBIT(TIFR, OCF0A),
- .vector = TIMER0_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE0B),
- .raised = AVR_IO_REGBIT(TIFR, OCF0B),
- .vector = TIMER0_COMPB_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0A),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0A),
+ .vector = TIMER0_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR0B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0B),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0B),
+ .vector = TIMER0_COMPB_vect,
+ }
+ }
},
},
.timer1 = {
.cs = { AVR_IO_REGBIT(TCCR1B, CS10), AVR_IO_REGBIT(TCCR1B, CS11), AVR_IO_REGBIT(TCCR1B, CS12) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ /* External clock T1 is not handled */},
- .r_ocra = OCR1AL,
- .r_ocrb = OCR1BL,
.r_tcnt = TCNT1L,
.r_icr = ICR1L,
.r_icrh = ICR1H,
- .r_ocrah = OCR1AH, // 16 bits timers have two bytes of it
- .r_ocrbh = OCR1BH,
.r_tcnth = TCNT1H,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV1),
.vector = TIMER1_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
- .raised = AVR_IO_REGBIT(TIFR, OCF1A),
- .vector = TIMER1_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
- .raised = AVR_IO_REGBIT(TIFR, OCF1B),
- .vector = TIMER1_COMPB_vect,
- },
.icr = {
.enable = AVR_IO_REGBIT(TIMSK, ICIE1),
.raised = AVR_IO_REGBIT(TIFR, ICF1),
.vector = TIMER1_CAPT_vect,
},
- },
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR1AL,
+ .r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1A),
+ .vector = TIMER1_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR1BL,
+ .r_ocrh = OCR1BH,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1B),
+ .vector = TIMER1_COMPB_vect,
+ }
+ }
+ }
+ }
};
static avr_t * make()
.cs = { AVR_IO_REGBIT(TCCR0B, CS00), AVR_IO_REGBIT(TCCR0B, CS01), AVR_IO_REGBIT(TCCR0B, CS02) },
.cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */ },
- .r_ocra = OCR0A,
- .r_ocrb = OCR0B,
.r_tcnt = TCNT0,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV0),
.vector = TIMER0_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE0A),
- .raised = AVR_IO_REGBIT(TIFR, OCF0A),
- .vector = TIMER0_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE0B),
- .raised = AVR_IO_REGBIT(TIFR, OCF0B),
- .vector = TIMER0_COMPB_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0A),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0A),
+ .vector = TIMER0_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR0B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0B),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0B),
+ .vector = TIMER0_COMPB_vect,
+ },
+ },
},
},
.timer1 = {
.cs = { AVR_IO_REGBIT(TCCR1, CS10), AVR_IO_REGBIT(TCCR1, CS11), AVR_IO_REGBIT(TCCR1, CS12), AVR_IO_REGBIT(TCCR1, CS13) },
.cs_div = { 0, 0, 1 /* 2 */, 2 /* 4 */, 3 /* 8 */, 4 /* 16 */ },
- .r_ocra = OCR1A,
- .r_ocrb = OCR1B,
- .r_ocrc = OCR1C,
.r_tcnt = TCNT1,
.overflow = {
.raised = AVR_IO_REGBIT(TIFR, TOV1),
.vector = TIMER1_OVF_vect,
},
- .compa = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
- .raised = AVR_IO_REGBIT(TIFR, OCF1A),
- .vector = TIMER1_COMPA_vect,
- },
- .compb = {
- .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
- .raised = AVR_IO_REGBIT(TIFR, OCF1B),
- .vector = TIMER1_COMPB_vect,
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR1A,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1A),
+ .vector = TIMER1_COMPA_vect,
+ },
+ },
+ [AVR_TIMER_COMPB] = {
+ .r_ocr = OCR1B,
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
+ .raised = AVR_IO_REGBIT(TIFR, OCF1B),
+ .vector = TIMER1_COMPB_vect,
+ },
+ },
+ [AVR_TIMER_COMPC] = {
+ .r_ocr = OCR1C,
+ },
},
},
-
-
};
#endif /* SIM_CORENAME */