SimAVR
AVR Simulator
avr_uart.h
Go to the documentation of this file.
1 /*
2  * avr_uart.h
3  *
4  * Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
5  *
6  * This file is part of simavr.
7  *
8  * simavr is free software: you can redistribute it and/or modify it under the terms of the GNU
9  * General Public License as published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * simavr is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
13  * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
14  * Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with simavr. If not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19 
25 #ifndef __AVR_UART_H__
26 #define __AVR_UART_H__
27 
28 #ifdef __cplusplus
29 extern "C"
30 {
31 #endif
32 
33 #include "sim_avr.h"
34 
35 #include "fifo_declare.h"
36 
37  DECLARE_FIFO (uint8_t, uart_fifo, 64);
38 
70  enum
71  {
77  };
78 
80 #define AVR_IOCTL_UART_GETIRQ(_name) AVR_IOCTL_DEF('u','a','r',(_name))
81 
82  enum
83  {
88  AVR_UART_FLAG_STDIO = (1 << 1),
89  };
90 
91  typedef struct avr_uart_t
92  {
94  char name;
96 
101 
108 
110 
114 
115  uart_fifo_t input;
116 
117  uint32_t flags;
119 
120  uint8_t *stdio_out;
121  int stdio_len;
122  } avr_uart_t;
123 
124  // takes a uint32_t* as parameter
125 #define AVR_IOCTL_UART_SET_FLAGS(_name) AVR_IOCTL_DEF('u','a','s',(_name))
126 #define AVR_IOCTL_UART_GET_FLAGS(_name) AVR_IOCTL_DEF('u','a','g',(_name))
127 
128  void avr_uart_init (avr_t * avr, avr_uart_t * port);
129 
130 #ifdef __cplusplus
131 };
132 #endif
133 
134 #endif /*__AVR_UART_H__*/
135 
Definition: avr_uart.h:76
signaled (continuously) when input fifo is not full
Definition: avr_uart.h:74
avr_regbit_t usbs
stop bits
Definition: avr_uart.h:105
struct avr_uart_t avr_uart_t
int stdio_len
current size in the stdio output
Definition: avr_uart.h:121
avr_int_vector_t udrc
Definition: avr_uart.h:113
signaled when input fifo IS full
Definition: avr_uart.h:75
avr_io_addr_t r_ucsra
Definition: avr_uart.h:98
uint16_t avr_io_addr_t
Definition: sim_avr_types.h:37
Definition: avr_uart.h:72
avr_io_addr_t r_ucsrc
Definition: avr_uart.h:100
avr_t * avr
Definition: run_avr.c:54
Definition: avr_uart.h:73
avr_regbit_t disabled
bit in the PRR
Definition: avr_uart.h:95
avr_regbit_t rxen
receive enabled
Definition: avr_uart.h:102
avr_io_addr_t r_ucsrb
Definition: avr_uart.h:99
uint32_t flags
Definition: avr_uart.h:117
interrupt vector for the IO modules
Definition: sim_interrupts.h:37
avr_io_addr_t r_ubrrh
Definition: avr_uart.h:109
This 'structure' is a packed representation of an IO register 'bit' (or consecutive bits)...
Definition: sim_avr_types.h:47
avr_io_addr_t r_udr
Definition: avr_uart.h:97
void avr_uart_init(avr_t *avr, avr_uart_t *port)
Definition: avr_uart.c:298
avr_io_addr_t r_ubrrl
Definition: avr_uart.h:109
avr_io_t io
Definition: avr_uart.h:93
print lines on the console
Definition: avr_uart.h:88
avr_int_vector_t txc
Definition: avr_uart.h:112
avr_regbit_t txen
transmit enable
Definition: avr_uart.h:103
avr_regbit_t ucsz
data bits
Definition: avr_uart.h:106
avr_cycle_count_t usec_per_byte
Definition: avr_uart.h:118
uint64_t avr_cycle_count_t
Definition: sim_avr_types.h:36
the uart code monitors for firmware that pool on reception registers, and can do an atomic usleep() i...
Definition: avr_uart.h:87
avr_int_vector_t rxc
Definition: avr_uart.h:111
Definition: avr_uart.h:91
char name
Definition: avr_uart.h:94
DECLARE_FIFO(uint8_t, uart_fifo, 64)
avr_regbit_t ucsz2
data bits, continued
Definition: avr_uart.h:107
Main AVR instance.
Definition: sim_avr.h:142
IO module base struct Modules uses that as their first member in their own struct.
Definition: sim_io.h:42
uint8_t * stdio_out
Definition: avr_uart.h:120
uart_fifo_t input
Definition: avr_uart.h:115
avr_regbit_t u2x
double UART speed
Definition: avr_uart.h:104