/*
* This is a template for all of the 128 devices, hopefuly
*/
-struct mcu_t {
+const struct mcu_t {
avr_t core;
avr_eeprom_t eeprom;
avr_flash_t selfprog;
.txen = AVR_IO_REGBIT(UCSR0B, TXEN0),
.rxen = AVR_IO_REGBIT(UCSR0B, RXEN0),
+ .ucsz = AVR_IO_REGBITS(UCSR0C, UCSZ00, 0x3), // 2 bits
+ .ucsz2 = AVR_IO_REGBIT(UCSR0B, UCSZ02), // 1 bits
.r_ucsra = UCSR0A,
.r_ucsrb = UCSR0B,
.txen = AVR_IO_REGBIT(UCSR1B, TXEN1),
.rxen = AVR_IO_REGBIT(UCSR1B, RXEN1),
+ .ucsz = AVR_IO_REGBITS(UCSR1C, UCSZ10, 0x3), // 2 bits
+ .ucsz2 = AVR_IO_REGBIT(UCSR1B, UCSZ12), // 1 bits
.r_ucsra = UCSR1A,
.r_ucsrb = UCSR1B,
AVR_IO_REGBIT(TCCR1B, WGM12), AVR_IO_REGBIT(TCCR1B, WGM13) },
.wgm_op = {
[0] = AVR_TIMER_WGM_NORMAL16(),
- // TODO: 1 PWM phase corret 8bit
- // 2 PWM phase corret 9bit
- // 3 PWM phase corret 10bit
+ // TODO: 1 PWM phase correct 8bit
+ // 2 PWM phase correct 9bit
+ // 3 PWM phase correct 10bit
[4] = AVR_TIMER_WGM_CTC(),
[5] = AVR_TIMER_WGM_FASTPWM8(),
[6] = AVR_TIMER_WGM_FASTPWM9(),
.r_icrh = ICR1H,
.r_tcnth = TCNT1H,
+ .ices = AVR_IO_REGBIT(TCCR1B, ICES1),
+ .icp = AVR_IO_REGBIT(PORTD, 4),
+
.overflow = {
.enable = AVR_IO_REGBIT(TIMSK, TOIE1),
.raised = AVR_IO_REGBIT(TIFR, TOV1),
AVR_IO_REGBIT(TCCR3B, WGM32), AVR_IO_REGBIT(TCCR3B, WGM33) },
.wgm_op = {
[0] = AVR_TIMER_WGM_NORMAL16(),
- // TODO: 1 PWM phase corret 8bit
- // 2 PWM phase corret 9bit
- // 3 PWM phase corret 10bit
+ // TODO: 1 PWM phase correct 8bit
+ // 2 PWM phase correct 9bit
+ // 3 PWM phase correct 10bit
[4] = AVR_TIMER_WGM_CTC(),
[5] = AVR_TIMER_WGM_FASTPWM8(),
[6] = AVR_TIMER_WGM_FASTPWM9(),
[7] = AVR_TIMER_WGM_FASTPWM10(),
- // TODO: 8 PWM phase and freq corret ICR
- // 9 PWM phase and freq corret OCR
+ // TODO: 8 PWM phase and freq correct ICR
+ // 9 PWM phase and freq correct OCR
// 10
// 11
[12] = AVR_TIMER_WGM_ICCTC(),
.r_icrh = ICR3H,
.r_tcnth = TCNT3H,
+ .ices = AVR_IO_REGBIT(TCCR3B, ICES3),
+ .icp = AVR_IO_REGBIT(PORTE, 7),
+
.overflow = {
.enable = AVR_IO_REGBIT(ETIMSK, TOIE3),
.raised = AVR_IO_REGBIT(ETIFR, TOV3),
.twi = {
.enable = AVR_IO_REGBIT(TWCR, TWIE),
- .raised = AVR_IO_REGBIT(TWSR, TWINT),
+ .raised = AVR_IO_REGBIT(TWCR, TWINT),
.vector = TWI_vect,
},
},
static avr_t * make()
{
- return &mcu_mega128.core;
+ return avr_core_allocate(&mcu_mega128.core, sizeof(struct mcu_t));
}
avr_kind_t mega128 = {