Merge pull request #10 from the-real-orca/mingw
authorMichel Pollet <buserror+git@gmail.com>
Sun, 2 Dec 2012 17:09:44 +0000 (09:09 -0800)
committerMichel Pollet <buserror+git@gmail.com>
Sun, 2 Dec 2012 17:09:44 +0000 (09:09 -0800)
MinGW merge, thanks!

simavr/cores/sim_megax4.h
simavr/sim/avr_uart.c

index 4b6c463..5ff74fe 100644 (file)
@@ -119,6 +119,7 @@ const struct mcu_t SIM_CORENAME = {
                .name = '0',
                .r_udr = UDR0,
 
+               .u2x = AVR_IO_REGBIT(UCSR0A, U2X0),
                .txen = AVR_IO_REGBIT(UCSR0B, TXEN0),
                .rxen = AVR_IO_REGBIT(UCSR0B, RXEN0),
                .ucsz = AVR_IO_REGBITS(UCSR0C, UCSZ00, 0x3), // 2 bits
@@ -150,6 +151,7 @@ const struct mcu_t SIM_CORENAME = {
                .name = '1',
                .r_udr = UDR1,
 
+               .u2x = AVR_IO_REGBIT(UCSR1A, U2X1),
                .txen = AVR_IO_REGBIT(UCSR1B, TXEN1),
                .rxen = AVR_IO_REGBIT(UCSR1B, RXEN1),
                .ucsz = AVR_IO_REGBITS(UCSR1C, UCSZ10, 0x3), // 2 bits
index 9911787..f723ee4 100644 (file)
@@ -192,9 +192,8 @@ static void avr_uart_write(struct avr_t * avr, avr_io_addr_t addr, uint8_t v, vo
                //uint8_t udre = avr_regbit_get(avr, p->udrc.raised);
                uint8_t txc = avr_regbit_get(avr, p->txc.raised);
 
-               // no need to write this value in here, only the
-               // interrupt flags need clearing!
-               // avr_core_watch_write(avr, addr, v);
+                // required for u2x (double uart transmission speed)
+               avr_core_watch_write(avr, addr, v);
 
                //avr_clear_interrupt_if(avr, &p->udrc, udre);
                avr_clear_interrupt_if(avr, &p->txc, txc);
@@ -232,6 +231,9 @@ void avr_uart_reset(struct avr_io_t *io)
        avr_cycle_timer_cancel(avr, avr_uart_txc_raise, p);
        uart_fifo_reset(&p->input);
 
+        avr_regbit_set(avr, p->ucsz);
+        avr_regbit_clear(avr, p->ucsz2);
+
        // DEBUG allow printf without fiddling with enabling the uart
        avr_regbit_set(avr, p->txen);
        p->usec_per_byte = 100;