// CTC etc. are missing because atmega8 does not support them on timer0
},
.cs = { AVR_IO_REGBIT(TCCR0, CS00), AVR_IO_REGBIT(TCCR0, CS01), AVR_IO_REGBIT(TCCR0, CS02) },
- .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */},
+ .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */, AVR_TIMER_EXTCLK_CHOOSE, AVR_TIMER_EXTCLK_CHOOSE /* AVR_TIMER_EXTCLK_CHOOSE means External clock chosen*/},
+
+ .ext_clock_pin = AVR_IO_REGBIT(EXT_CLOCK0_PORT, EXT_CLOCK0_PIN),
.r_tcnt = TCNT0,
.raised = AVR_IO_REGBIT(TIFR, TOV0),
.vector = TIMER0_OVF_vect,
},
- // Compare Output Mode is missing for timer0 as atmega8 does not support it
+#ifdef OC0_PORT
+ .comp = {
+ [AVR_TIMER_COMPA] = {
+ .r_ocr = OCR0,
+ .com = AVR_IO_REGBITS(TCCR0, COM00, 0x3),
+ .com_pin = AVR_IO_REGBIT(OC0_PORT, OC0_PIN),
+ .interrupt = {
+ .enable = AVR_IO_REGBIT(TIMSK, OCIE0),
+ .raised = AVR_IO_REGBIT(TIFR, OCF0),
+ .vector = TIMER0_COMP_vect,
+ },
+ },
+ },
+#else
+// Compare Output Mode is missing for timer0 on atmega8
+#endif
},
.timer1 = {
.name = '1',
[15] = AVR_TIMER_WGM_OCPWM(),
},
.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 */},
+ .cs_div = { 0, 0, 3 /* 8 */, 6 /* 64 */, 8 /* 256 */, 10 /* 1024 */, AVR_TIMER_EXTCLK_CHOOSE, AVR_TIMER_EXTCLK_CHOOSE /* AVR_TIMER_EXTCLK_CHOOSE means External clock chosen*/},
+
+ .ext_clock_pin = AVR_IO_REGBIT(EXT_CLOCK1_PORT, EXT_CLOCK1_PIN),
.r_tcnt = TCNT1L,
.r_icr = ICR1L,
.r_ocr = OCR1AL,
.r_ocrh = OCR1AH, // 16 bits timers have two bytes of it
.com = AVR_IO_REGBITS(TCCR1A, COM1A0, 0x3),
- .com_pin = AVR_IO_REGBIT(PORTB, PB5),
+ .com_pin = AVR_IO_REGBIT(OC1A_PORT, OC1A_PIN),
.interrupt = {
.enable = AVR_IO_REGBIT(TIMSK, OCIE1A),
.raised = AVR_IO_REGBIT(TIFR, OCF1A),
.r_ocr = OCR1BL,
.r_ocrh = OCR1BH,
.com = AVR_IO_REGBITS(TCCR1A, COM1B0, 0x3),
- .com_pin = AVR_IO_REGBIT(PORTB, PB6),
+ .com_pin = AVR_IO_REGBIT(OC1B_PORT, OC1B_PIN),
.interrupt = {
.enable = AVR_IO_REGBIT(TIMSK, OCIE1B),
.raised = AVR_IO_REGBIT(TIFR, OCF1B),
[AVR_TIMER_COMPA] = {
.r_ocr = OCR2,
.com = AVR_IO_REGBITS(TCCR2, COM20, 0x3),
- .com_pin = AVR_IO_REGBIT(PORTB, PB7), // same as timer1C
+ .com_pin = AVR_IO_REGBIT(OC2_PORT, OC2_PIN), // same as timer1C
.interrupt = {
.enable = AVR_IO_REGBIT(TIMSK, OCIE2),
.raised = AVR_IO_REGBIT(TIFR, OCF2),