39 #include "contiki-conf.h"
43 #define UART1_BASE (0x80005000)
44 #define UART2_BASE (0x8000B000)
119 static volatile struct UART_struct *
const UART1 = (
void *) (
UART1_BASE);
120 static volatile struct UART_struct *
const UART2 = (
void *) (
UART2_BASE);
123 #ifndef REG_NO_COMPAT
128 #define UCON_SAMP_8X 0
129 #define UCON_SAMP_16X 1
133 #define URXCON (0x0c)
134 #define UTXCON (0x10)
136 #define UBRCNT (0x18)
138 #define UART1_UCON ((volatile uint32_t *) ( UART1_BASE + UCON ))
139 #define UART1_USTAT ((volatile uint32_t *) ( UART1_BASE + USTAT ))
140 #define UART1_UDATA ((volatile uint32_t *) ( UART1_BASE + UDATA ))
141 #define UART1_URXCON ((volatile uint32_t *) ( UART1_BASE + URXCON ))
142 #define UART1_UTXCON ((volatile uint32_t *) ( UART1_BASE + UTXCON ))
143 #define UART1_UCTS ((volatile uint32_t *) ( UART1_BASE + UCTS ))
144 #define UART1_UBRCNT ((volatile uint32_t *) ( UART1_BASE + UBRCNT ))
146 #define UART2_UCON ((volatile uint32_t *) ( UART2_BASE + UCON ))
147 #define UART2_USTAT ((volatile uint32_t *) ( UART2_BASE + USTAT ))
148 #define UART2_UDATA ((volatile uint32_t *) ( UART2_BASE + UDATA ))
149 #define UART2_URXCON ((volatile uint32_t *) ( UART2_BASE + URXCON ))
150 #define UART2_UTXCON ((volatile uint32_t *) ( UART2_BASE + UTXCON ))
151 #define UART2_UCTS ((volatile uint32_t *) ( UART2_BASE + UCTS ))
152 #define UART2_UBRCNT ((volatile uint32_t *) ( UART2_BASE + UBRCNT ))
156 void uart_init(
volatile struct UART_struct * uart, uint32_t baud);
157 void uart_setbaud(
volatile struct UART_struct * uart, uint32_t baud);
158 void uart_flowctl(
volatile struct UART_struct * uart, uint8_t on);
166 #ifndef UART1_CONF_TX_BUFFERSIZE
167 #define UART1_TX_BUFFERSIZE 1024
169 #define UART1_TX_BUFFERSIZE UART1_CONF_TX_BUFFERSIZE
172 extern volatile uint32_t u1_tx_head, u1_tx_tail;
173 void uart1_putc(
char c);
183 #ifndef UART1_CONF_RX_BUFFERSIZE
184 #define UART1_RX_BUFFERSIZE 128
186 #define UART1_RX_BUFFERSIZE UART1_CONF_RX_BUFFERSIZE
189 #if UART1_RX_BUFFERSIZE > 32
190 extern volatile uint32_t u1_rx_head, u1_rx_tail;
191 #define uart1_can_get() ((u1_rx_head!=u1_rx_tail) || (*UART1_URXCON > 0))
193 #define uart1_can_get() (*UART1_URXCON > 0)
195 uint8_t uart1_getc(
void);
197 #ifndef UART2_CONF_TX_BUFFERSIZE
198 #define UART2_TX_BUFFERSIZE 1024
200 #define UART2_TX_BUFFERSIZE UART1_CONF_TX_BUFFERSIZE
203 extern volatile uint32_t u2_tx_head, u2_tx_tail;
204 void uart2_putc(
char c);
206 #ifndef UART2_CONF_RX_BUFFERSIZE
207 #define UART2_RX_BUFFERSIZE 128
209 #define UART2_RX_BUFFERSIZE UART1_CONF_RX_BUFFERSIZE
211 #if UART2_RX_BUFFERSIZE > 32
212 extern volatile uint32_t u2_rx_head, u2_rx_tail;
213 #define uart2_can_get() ((u2_rx_head!=u2_rx_tail) || (*UART2_URXCON > 0))
215 #define uart2_can_get() (*UART2_URXCON > 0)
217 uint8_t uart2_getc(
void);
void uart_init(const unsigned int uart_num, uint32_t module_clk_hz, const uint32_t baud)
Initialize UART.
#define UART2_BASE
Peripheral UART2 base address.
#define UART1
Peripheral UART1 base pointer.
#define UART1_BASE
Peripheral UART1 base address.
#define UART2
Peripheral UART2 base pointer.