misc: Fix confusing typo in error message
[simavr] / simavr / cores / sim_mega128.c
index 6d4e1d8..ce142a5 100644 (file)
@@ -41,9 +41,9 @@ void m128_reset(struct avr_t * avr);
 #include "avr/iom128.h"
 
 /*
- * This is a template for all of the 128 devices, hopefuly
+ * This is a template for all of the 128 devices, hopefully
  */
-struct mcu_t {
+const struct mcu_t {
        avr_t          core;
        avr_eeprom_t    eeprom;
        avr_flash_t     selfprog;
@@ -107,6 +107,8 @@ struct mcu_t {
 
                .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,
@@ -136,6 +138,8 @@ struct mcu_t {
 
                .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,
@@ -468,7 +472,7 @@ struct mcu_t {
 
                .twi = {
                        .enable = AVR_IO_REGBIT(TWCR, TWIE),
-                       .raised = AVR_IO_REGBIT(TWSR, TWINT),
+                       .raised = AVR_IO_REGBIT(TWCR, TWINT),
                        .vector = TWI_vect,
                },
        },
@@ -477,7 +481,7 @@ struct mcu_t {
 
 static avr_t * make()
 {
-        return &mcu_mega128.core;
+       return avr_core_allocate(&mcu_mega128.core, sizeof(struct mcu_t));
 }
 
 avr_kind_t mega128 = {