Merge pull request #1 from schuay/master
[simavr] / simavr / sim / avr_uart.h
index 1d8c725..f0ff4af 100644 (file)
@@ -30,14 +30,14 @@ DECLARE_FIFO(uint8_t, uart_fifo, 64);
 
 /*
  * The method of "connecting" the the UART from external code is to use 4 IRQS.
- * The easy one is UART->YOU, where you will be called with the byte everytime
+ * The easy one is UART->YOU, where you will be called with the byte every time
  * the AVR firmware sends one. Do whatever you like with it.
  *
  * The slightly more tricky one is the INPUT part. Since the AVR is quite a bit
  * slower than your code most likely, there is a way for the AVR UART to tell
- * you to "pause" sending it bytes when it's own input buffer is full.
- * So, the UART will send XON to you when it's fifo is empty, XON means you can
- * send as many bytes as you have until XOFF is send. Note that these are two
+ * you to "pause" sending it bytes when its own input buffer is full.
+ * So, the UART will send XON to you when its fifo is empty, XON means you can
+ * send as many bytes as you have until XOFF is sent. Note that these are two
  * IRQs because you /will/ be called with XOFF when sending a byte in INPUT...
  * So it's a reentrant process.
  *
@@ -50,13 +50,13 @@ DECLARE_FIFO(uint8_t, uart_fifo, 64);
  * volatile int off = 0;
  * void irq_xon()
  * {
- *     off = 0;
- *     while (!off && bytes_lefts)
+ *     off = 0;
+ *     while (!off && bytes_left)
  *     avr_raise_irq(UART_IRQ_INPUT, a_byte);
  * }
  * void irq_xoff()
  * {
- *  off = 1;
+ *     off = 1;
  * }
  *
  */
@@ -92,6 +92,9 @@ typedef struct avr_uart_t {
        avr_regbit_t    rxen;           // receive enabled
        avr_regbit_t    txen;           // transmit enable
        avr_regbit_t    u2x;            // double UART speed
+       avr_regbit_t    usbs;           // stop bits
+       avr_regbit_t    ucsz;           // data bits
+       avr_regbit_t    ucsz2;          // data bits, continued
 
        avr_io_addr_t r_ubrrl,r_ubrrh;
 
@@ -102,6 +105,10 @@ typedef struct avr_uart_t {
        uart_fifo_t     input;
 
        uint32_t                flags;
+       avr_cycle_count_t usec_per_byte;
+
+       uint8_t *               stdio_out;
+       int                             stdio_len;      // current size in the stdio output
 } avr_uart_t;
 
 /* takes a uint32_t* as parameter */