ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
uart.h
Go to the documentation of this file.
1 #ifndef _UART_H_
2 #define _UART_H_
3 
29 #define UART0 0
30 #define UART1 1
31 
32 typedef enum
33 {
34  ONE_STOP_BIT = 0x1,
37 
38 typedef enum {
39  NO_PARITY = 0,
43 
44 typedef enum
45 {
46  BIT_RATE_300 = 300,
47  BIT_RATE_600 = 600,
48  BIT_RATE_1200 = 1200,
49  BIT_RATE_2400 = 2400,
50  BIT_RATE_4800 = 4800,
51  BIT_RATE_9600 = 9600,
52  BIT_RATE_19200 = 19200,
53  BIT_RATE_38400 = 38400,
54  BIT_RATE_57600 = 57600,
55  BIT_RATE_74880 = 74880,
56  BIT_RATE_115200 = 115200,
57  BIT_RATE_230400 = 230400,
58  BIT_RATE_460800 = 460800,
59  BIT_RATE_921600 = 921600,
60  BIT_RATE_1843200 = 1843200,
61  BIT_RATE_3686400 = 3686400,
62 } UartBaudRate;
63 
64 #ifndef UART_FIFO_LEN
65  #define UART_FIFO_LEN 128 /* define the tx fifo length */
66 #endif
67 
68 #ifndef FUNC_U0TXD
69  #define FUNC_U0TXD 0
70 #endif
71 
72 #ifndef FUNC_U0RXD
73  #define FUNC_U0RXD 0
74 #endif
75 
76 
77 /* uart.c */
78 void uart_rx_enable ( uint8 uart_no );
79 void uart_rx_disable ( uint8 uart_no );
80 void uart_tx_enable ( uint8_t uart_no );
81 void uart_tx_disable ( uint8_t uart_no );
82 void tx_fifo_flush ( int uart_no );
83 void rx_fifo_flush ( int uart_no );
84 MEMSPACE int tx_fifo_used ( int uart_no );
85 MEMSPACE int tx_fifo_free ( int uart_no );
86 MEMSPACE int tx_fifo_empty ( int uart_no );
87 MEMSPACE int rx_fifo_used ( int uart_no );
88 MEMSPACE int rx_fifo_free ( int uart_no );
89 MEMSPACE int rx_fifo_empty ( int uart_no );
90 MEMSPACE int tx_fifo_putb ( int uart_no , uint8_t c );
91 MEMSPACE int rx_fifo_getb ( int uart_no );
92 MEMSPACE int tx_fifo_write ( int uart_no , uint8_t *buf , int size );
93 MEMSPACE int rx_fifo_read ( int uart_no , uint8_t *buf , int size );
94 LOCAL MEMSPACE int uart_putb ( uint8 uart_no , uint8 data );
95 LOCAL MEMSPACE int uart_getb ( int uart_no );
96 MEMSPACE int uart_putc ( uint8 uart_no , char c );
97 MEMSPACE int uart_getc ( int uart_no );
98 MEMSPACE int uart0_putc ( uint8 c );
99 MEMSPACE int uart0_getc ( void );
100 MEMSPACE int uart1_putc ( uint8 c );
101 MEMSPACE int uart1_getc ( void );
102 MEMSPACE void uart_flush ( uint8_t uart_no );
103 LOCAL MEMSPACE int uart_queue_getb ( uint8_t uart_no );
107 void uart_task ( void );
108 LOCAL MEMSPACE void uart_queue_putb ( uint8 uart_no , uint8 data );
109 MEMSPACE void uart_queue_putc ( uint8_t uart_no , char c );
110 MEMSPACE void uart0_queue_putc ( char c );
111 MEMSPACE void uart1_queue_putc ( char c );
112 int kbhiteol ( int uart_no );
113 int kbhit ( int uart_no );
114 void uart_callback ( void *p );
115 MEMSPACE void UART_SetPrintPort ( uint8 uart_no );
116 MEMSPACE void uart_config ( uint8 uart_no , uint32_t baud , uint8_t data_bits , uint8_t stop_bits , uint8_t parity );
117 MEMSPACE void uart_init ( UartBaudRate uart0_br , UartBaudRate uart1_br );
118 MEMSPACE void uart_reattach ( void );
119 
120 #endif
MEMSPACE int uart_getc(int uart_no)
Read a byte from a uart with NL to CR/NL conversion Note: This function waits/blocks util the read ca...
Definition: uart.c:337
void rx_fifo_flush(int uart_no)
Flush receive fifo for a uart.
Definition: uart.c:105
int kbhit(int uart_no)
Has ANY character been read in stdin.
Definition: uart.c:585
LOCAL MEMSPACE int uart_putb(uint8 uart_no, uint8 data)
Polled Blocking I/O functions that poll.
Definition: uart.c:289
MEMSPACE int uart0_getc(void)
Read a byte from uart0 with NL to CR/NL conversion Note: This function waits/blocks util the read can...
Definition: uart.c:369
MEMSPACE void uart1_queue_putc(char c)
void tx_fifo_flush(int uart_no)
Flush transmit fifo for a uart.
Definition: uart.c:94
MEMSPACE int uart0_putc(uint8 c)
Write a byte to uart0 with NL to CR/NL conversion Note: This function waits/blocks util the write can...
Definition: uart.c:358
MEMSPACE int uart_putc(uint8 uart_no, char c)
Write a byte from a uart with NL to CR/NL conversion Note: This function waits/blocks util the write ...
Definition: uart.c:323
MEMSPACE void uart_queue_putc(uint8_t uart_no, char c)
MEMSPACE int tx_fifo_empty(int uart_no)
Test if the transmit fifo is empty.
Definition: uart.c:143
MEMSPACE void uart_init(UartBaudRate uart0_br, UartBaudRate uart1_br)
initialize uart0 and uart1 Defaults: 8 = data bits, 1 = stop bits, no parity
Definition: uart.c:773
void uart_rx_enable(uint8 uart_no)
Enable receive interrupts for a uart.
Definition: uart.c:52
MEMSPACE void uart_reattach(void)
Reinitialize uart0 and uart1 calls uart_init()
Definition: uart.c:822
unsigned int uint32_t
Definition: send.c:19
MEMSPACE void uart0_queue_putc(char c)
MEMSPACE uint8_t uart1_queue_getc(void)
MEMSPACE int uart1_getc(void)
Read a byte from uart1 with NL to CR/NL conversion Note: This function waits/blocks util the read can...
Definition: uart.c:393
MEMSPACE void uart_flush(uint8_t uart_no)
Flush TX buffer Note: This function waits/blocks util the write happen.
Definition: uart.c:406
void uart_rx_disable(uint8 uart_no)
Disable receive interrupts for a uart.
Definition: uart.c:62
MEMSPACE int tx_fifo_putb(int uart_no, uint8_t c)
Add a byte to the trasmit fifo We assume that tx_fifo_free() was called!
Definition: uart.c:199
MEMSPACE int tx_fifo_write(int uart_no, uint8_t *buf, int size)
Write a data buffer to the transmit fifo Note: This function does not wait/block util there is enough...
Definition: uart.c:237
MEMSPACE void UART_SetPrintPort(uint8 uart_no)
Install debug uart.
Definition: uart.c:682
void uart_tx_enable(uint8_t uart_no)
Enable transmit interrupts for a uart.
Definition: uart.c:72
UartBaudRate
Definition: uart.h:44
UartParityMode
Definition: uart.h:38
MEMSPACE int rx_fifo_getb(int uart_no)
Remove a byte from the receive fifo We assume that rx_fifo_used() was called!
Definition: uart.c:217
MEMSPACE int rx_fifo_empty(int uart_no)
Test if the receive fifo is empty.
Definition: uart.c:182
MEMSPACE uint8_t uart0_queue_getc(void)
LOCAL MEMSPACE int uart_queue_getb(uint8_t uart_no)
MEMSPACE int tx_fifo_free(int uart_no)
Get the number of bytes free in transmit fifo.
Definition: uart.c:130
void uart_tx_disable(uint8_t uart_no)
Disable transmit interrupts for a uart.
Definition: uart.c:82
int kbhiteol(int uart_no)
Has an EOL been read on stdin ?
Definition: uart.c:572
#define MEMSPACE
Definition: cpu.h:25
MEMSPACE int rx_fifo_used(int uart_no)
Get the number of bytes used in receive fifo.
Definition: uart.c:155
MEMSPACE int rx_fifo_free(int uart_no)
Get the number of bytes free in receive fifo.
Definition: uart.c:168
UartStopBitsNum
Definition: uart.h:32
#define UART_PARITY
#define UART_PARITY_EN
MEMSPACE int rx_fifo_read(int uart_no, uint8_t *buf, int size)
Read a data buffer from the receive fifo Note: This function does not wait/block util there is enough...
Definition: uart.c:264
void uart_task(void)
LOCAL MEMSPACE int uart_getb(int uart_no)
Read a byte from a uart Note: This function waits/blocks util the read can happen.
Definition: uart.c:304
void uart_callback(void *p)
Uart interrupt callback function Process all receive and transmit events here.
Definition: uart.c:604
unsigned char uint8_t
Definition: send.c:17
MEMSPACE int tx_fifo_used(int uart_no)
Get the number of bytes used in transmit fifo.
Definition: uart.c:118
MEMSPACE int uart1_putc(uint8 c)
Write a byte to uart1 with NL to CR/NL conversion Note: This function waits/blocks util the write can...
Definition: uart.c:382
LOCAL MEMSPACE void uart_queue_putb(uint8 uart_no, uint8 data)
MEMSPACE uint8_t uart_queue_getc(uint8_t uart_no)
Definition: uart.h:39
MEMSPACE void uart_config(uint8 uart_no, uint32_t baud, uint8_t data_bits, uint8_t stop_bits, uint8_t parity)
Uart configuration, baud rate, data and stop bits, parity.
Definition: uart.c:714