ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Macros | Enumerations | Functions
uart.h File Reference

Go to the source code of this file.

Macros

#define UART0   0
 
#define UART1   1
 
#define UART_FIFO_LEN   128 /* define the tx fifo length */
 
#define FUNC_U0TXD   0
 
#define FUNC_U0RXD   0
 

Enumerations

enum  UartStopBitsNum { ONE_STOP_BIT = 0x1, TWO_STOP_BIT = 0x3 }
 
enum  UartParityMode { NO_PARITY = 0, EVEN_PARITY = UART_PARITY_EN, ODD_PARITY = UART_PARITY_EN | UART_PARITY }
 
enum  UartBaudRate {
  BIT_RATE_300 = 300, BIT_RATE_600 = 600, BIT_RATE_1200 = 1200, BIT_RATE_2400 = 2400,
  BIT_RATE_4800 = 4800, BIT_RATE_9600 = 9600, BIT_RATE_19200 = 19200, BIT_RATE_38400 = 38400,
  BIT_RATE_57600 = 57600, BIT_RATE_74880 = 74880, BIT_RATE_115200 = 115200, BIT_RATE_230400 = 230400,
  BIT_RATE_460800 = 460800, BIT_RATE_921600 = 921600, BIT_RATE_1843200 = 1843200, BIT_RATE_3686400 = 3686400
}
 

Functions

void uart_rx_enable (uint8 uart_no)
 Enable receive interrupts for a uart. More...
 
void uart_rx_disable (uint8 uart_no)
 Disable receive interrupts for a uart. More...
 
void uart_tx_enable (uint8_t uart_no)
 Enable transmit interrupts for a uart. More...
 
void uart_tx_disable (uint8_t uart_no)
 Disable transmit interrupts for a uart. More...
 
void tx_fifo_flush (int uart_no)
 Flush transmit fifo for a uart. More...
 
void rx_fifo_flush (int uart_no)
 Flush receive fifo for a uart. More...
 
MEMSPACE int tx_fifo_used (int uart_no)
 Get the number of bytes used in transmit fifo. More...
 
MEMSPACE int tx_fifo_free (int uart_no)
 Get the number of bytes free in transmit fifo. More...
 
MEMSPACE int tx_fifo_empty (int uart_no)
 Test if the transmit fifo is empty. More...
 
MEMSPACE int rx_fifo_used (int uart_no)
 Get the number of bytes used in receive fifo. More...
 
MEMSPACE int rx_fifo_free (int uart_no)
 Get the number of bytes free in receive fifo. More...
 
MEMSPACE int rx_fifo_empty (int uart_no)
 Test if the receive fifo is empty. More...
 
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! More...
 
MEMSPACE int rx_fifo_getb (int uart_no)
 Remove a byte from the receive fifo We assume that rx_fifo_used() was called! More...
 
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 free space to meet the request. So you must check that the return value matches the size. More...
 
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 free space to meet the request. So you must check that the return value matches the size. More...
 
LOCAL MEMSPACE int uart_putb (uint8 uart_no, uint8 data)
 Polled Blocking I/O functions that poll. More...
 
LOCAL MEMSPACE int uart_getb (int uart_no)
 Read a byte from a uart Note: This function waits/blocks util the read can happen. More...
 
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 can happen. More...
 
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 can happen. More...
 
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 happen. More...
 
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 happen. More...
 
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 happen. More...
 
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 happen. More...
 
MEMSPACE void uart_flush (uint8_t uart_no)
 Flush TX buffer Note: This function waits/blocks util the write happen. More...
 
LOCAL MEMSPACE int uart_queue_getb (uint8_t uart_no)
 
MEMSPACE uint8_t uart_queue_getc (uint8_t uart_no)
 
MEMSPACE uint8_t uart0_queue_getc (void)
 
MEMSPACE uint8_t uart1_queue_getc (void)
 
void uart_task (void)
 
LOCAL MEMSPACE void uart_queue_putb (uint8 uart_no, uint8 data)
 
MEMSPACE void uart_queue_putc (uint8_t uart_no, char c)
 
MEMSPACE void uart0_queue_putc (char c)
 
MEMSPACE void uart1_queue_putc (char c)
 
int kbhiteol (int uart_no)
 Has an EOL been read on stdin ? More...
 
int kbhit (int uart_no)
 Has ANY character been read in stdin. More...
 
void uart_callback (void *p)
 Uart interrupt callback function Process all receive and transmit events here. More...
 
MEMSPACE void UART_SetPrintPort (uint8 uart_no)
 Install debug uart. More...
 
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. More...
 
MEMSPACE void uart_init (UartBaudRate uart0_br, UartBaudRate uart1_br)
 initialize uart0 and uart1 Defaults: 8 = data bits, 1 = stop bits, no parity More...
 
MEMSPACE void uart_reattach (void)
 Reinitialize uart0 and uart1 calls uart_init() More...
 

Macro Definition Documentation

#define FUNC_U0RXD   0

Definition at line 73 of file uart.h.

#define FUNC_U0TXD   0

Definition at line 69 of file uart.h.

#define UART0   0

Definition at line 29 of file uart.h.

Referenced by rx_fifo_empty(), rx_fifo_free(), rx_fifo_getb(), rx_fifo_read(), and rx_fifo_used().

#define UART1   1

Definition at line 30 of file uart.h.

#define UART_FIFO_LEN   128 /* define the tx fifo length */

Definition at line 65 of file uart.h.

Referenced by rx_fifo_free(), and tx_fifo_free().

Enumeration Type Documentation

Enumerator
BIT_RATE_300 
BIT_RATE_600 
BIT_RATE_1200 
BIT_RATE_2400 
BIT_RATE_4800 
BIT_RATE_9600 
BIT_RATE_19200 
BIT_RATE_38400 
BIT_RATE_57600 
BIT_RATE_74880 
BIT_RATE_115200 
BIT_RATE_230400 
BIT_RATE_460800 
BIT_RATE_921600 
BIT_RATE_1843200 
BIT_RATE_3686400 

Definition at line 44 of file uart.h.

Enumerator
NO_PARITY 
EVEN_PARITY 
ODD_PARITY 

Definition at line 38 of file uart.h.

Enumerator
ONE_STOP_BIT 
TWO_STOP_BIT 

Definition at line 32 of file uart.h.

Function Documentation

int kbhit ( int  uart_no)

Has ANY character been read in stdin.

Parameters
[in]uart_nouart number
Returns
byte read

Definition at line 585 of file uart.c.

Referenced by testpage().

int kbhiteol ( int  uart_no)

Has an EOL been read on stdin ?

Parameters
[in]uart_nouart number
Returns
byte read

Definition at line 572 of file uart.c.

Referenced by user_tasks().

MEMSPACE int rx_fifo_empty ( int  uart_no)

Test if the receive fifo is empty.

Parameters
[in]uart_nouart number
Returns
1 if empty, 0 otherwise

Definition at line 182 of file uart.c.

Referenced by uart_getb().

void rx_fifo_flush ( int  uart_no)

Flush receive fifo for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 105 of file uart.c.

MEMSPACE int rx_fifo_free ( int  uart_no)

Get the number of bytes free in receive fifo.

Parameters
[in]uart_nouart number
Returns
bytes free

Definition at line 168 of file uart.c.

MEMSPACE int rx_fifo_getb ( int  uart_no)

Remove a byte from the receive fifo We assume that rx_fifo_used() was called!

Parameters
[in]uart_nouart number
Returns
c, (or 0 if fill user error)

Definition at line 217 of file uart.c.

Referenced by uart_getb().

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 free space to meet the request. So you must check that the return value matches the size.

Parameters
[in]uart_nouart number
[in]*bufoutput buffer
[in]sizesize of output buffer
Returns
number of bytes actually read from the fifo - may not be size!

Definition at line 264 of file uart.c.

MEMSPACE int rx_fifo_used ( int  uart_no)

Get the number of bytes used in receive fifo.

Parameters
[in]uart_nouart number
Returns
bytes in use

Definition at line 155 of file uart.c.

Referenced by rx_fifo_getb(), and rx_fifo_read().

MEMSPACE int tx_fifo_empty ( int  uart_no)

Test if the transmit fifo is empty.

Parameters
[in]uart_nouart number
Returns
1 if empty, 0 otherwise

Definition at line 143 of file uart.c.

Referenced by uart_flush().

void tx_fifo_flush ( int  uart_no)

Flush transmit fifo for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 94 of file uart.c.

MEMSPACE int tx_fifo_free ( int  uart_no)

Get the number of bytes free in transmit fifo.

Parameters
[in]uart_nouart number
Returns
bytes free

Definition at line 130 of file uart.c.

Referenced by tx_fifo_putb(), tx_fifo_write(), and uart_putb().

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!

Parameters
[in]uart_nouart number
[in]cbyte to add
Returns
c, (or 0 if full user error)

Definition at line 199 of file uart.c.

Referenced by uart_putb().

MEMSPACE int tx_fifo_used ( int  uart_no)

Get the number of bytes used in transmit fifo.

Parameters
[in]uart_nouart number
Returns
bytes in use

Definition at line 118 of file uart.c.

Referenced by uart_flush().

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 free space to meet the request. So you must check that the return value matches the size.

Parameters
[in]uart_nouart number
[in]*bufoutput buffer
[in]sizesize of input buffer
Returns
number of bytes sent

Definition at line 237 of file uart.c.

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 happen.

Returns
byte read

Definition at line 369 of file uart.c.

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 happen.

Parameters
[in]cbyte to write
Returns
void

Definition at line 358 of file uart.c.

MEMSPACE uint8_t uart0_queue_getc ( void  )

Referenced by uart_flush().

MEMSPACE void uart0_queue_putc ( char  c)

Referenced by uart_flush().

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 happen.

Returns
byte read

Definition at line 393 of file uart.c.

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 happen.

Parameters
[in]cbyte to write
Returns
void

Definition at line 382 of file uart.c.

MEMSPACE uint8_t uart1_queue_getc ( void  )

Referenced by uart_flush().

MEMSPACE void uart1_queue_putc ( char  c)

Referenced by uart_flush().

void uart_callback ( void *  p)

Uart interrupt callback function Process all receive and transmit events here.

=================================================================

/**

Parameters
[in]*pcallback pointer - currently unused
Returns
void

Definition at line 604 of file uart.c.

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.

Parameters
[in]uart_nouart number
[in]baudbaud
[in]data_bitsnumber of data bits, 5 .. 8
[in]stop_bitsnumber of stop bits, ONE_STOP_BIT|TWO_STOP_BIT
[in]parityparity, NO_PARITY,ODD_PARITY,EVEN_PARITY
Returns
void

Definition at line 714 of file uart.c.

MEMSPACE void uart_flush ( uint8_t  uart_no)

Flush TX buffer Note: This function waits/blocks util the write happen.

Returns
void

Definition at line 406 of file uart.c.

LOCAL MEMSPACE int uart_getb ( int  uart_no)

Read a byte from a uart Note: This function waits/blocks util the read can happen.

Parameters
[in]uart_nouart number
Returns
byte read

Definition at line 304 of file uart.c.

Referenced by uart_getc().

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 can happen.

Parameters
[in]uart_nouart number
Returns
byte read

Definition at line 337 of file uart.c.

Referenced by uart0_getc(), and uart1_getc().

MEMSPACE void uart_init ( UartBaudRate  uart0_br,
UartBaudRate  uart1_br 
)

initialize uart0 and uart1 Defaults: 8 = data bits, 1 = stop bits, no parity

Parameters
[in]uart0_brbaud rate for uart 0
[in]uart1_brbaud rate for uart 1
Returns
void

Definition at line 773 of file uart.c.

Referenced by setup().

LOCAL MEMSPACE int uart_putb ( uint8  uart_no,
uint8  data 
)

Polled Blocking I/O functions that poll.

Write a byte to a uart Note: This function waits/blocks util the write can happen

Parameters
[in]uart_nouart number
[in]databyte to write
Returns
void

Definition at line 289 of file uart.c.

Referenced by uart_putc().

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 can happen.

Parameters
[in]uart_nouart number
[in]ccharacter
Returns
void

Definition at line 323 of file uart.c.

Referenced by _uart0_fn(), fatfs_ls(), uart0_putc(), and uart1_putc().

LOCAL MEMSPACE int uart_queue_getb ( uint8_t  uart_no)

Referenced by uart_flush().

MEMSPACE uint8_t uart_queue_getc ( uint8_t  uart_no)

Referenced by uart_flush().

LOCAL MEMSPACE void uart_queue_putb ( uint8  uart_no,
uint8  data 
)

Referenced by uart_flush().

MEMSPACE void uart_queue_putc ( uint8_t  uart_no,
char  c 
)

Referenced by _uart0_fn(), and uart_flush().

MEMSPACE void uart_reattach ( void  )

Reinitialize uart0 and uart1 calls uart_init()

Returns
void

Definition at line 822 of file uart.c.

void uart_rx_disable ( uint8  uart_no)

Disable receive interrupts for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 62 of file uart.c.

void uart_rx_enable ( uint8  uart_no)

Enable receive interrupts for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 52 of file uart.c.

MEMSPACE void UART_SetPrintPort ( uint8  uart_no)

Install debug uart.

Returns
void

Definition at line 682 of file uart.c.

void uart_task ( void  )

Referenced by uart_flush().

void uart_tx_disable ( uint8_t  uart_no)

Disable transmit interrupts for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 82 of file uart.c.

void uart_tx_enable ( uint8_t  uart_no)

Enable transmit interrupts for a uart.

Parameters
[in]uart_nouart number
Returns
void

Definition at line 72 of file uart.c.

Referenced by tx_fifo_putb(), tx_fifo_write(), and uart_flush().