1 // Copyright (C) IBM 2019, see LICENSE.CC4
2 // based on code from microwatt https://github.com/antonblanchard/microwatt
5 * Our UART uses 16x oversampling, so at 50 MHz and 115200 baud
6 * each sample is: 50000000/(115200*16) = 27 clock cycles. This
7 * means each bit is off by 0.47% so for 8 bits plus a start and
8 * stop bit the errors add to be 4.7%.
12 IDLE
, START_BIT
, BITS
, STOP_BIT
, ERROR
15 struct uart_tx_state
{
18 enum state tx_state
= IDLE
;
19 unsigned long tx_countbits
;
20 unsigned char tx_bits
;
21 unsigned char tx_byte
;
22 unsigned char tx_prev
;
24 enum state rx_state
= IDLE
;
25 unsigned char rx_char
;
26 unsigned long rx_countbits
;
31 void uart_tx(unsigned char tx
);
32 unsigned char uart_rx(void);
33 struct uart_tx_state
* uart_get_state(void);
34 void uart_restore(struct uart_tx_state
*);