Universal asynchronous receiver/transmitter (UART0/UART1) HW driver source file.
More...
#include <neorv32.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
|
int | neorv32_uart_available (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_setup (neorv32_uart_t *UARTx, uint32_t baudrate, uint32_t irq_mask) |
|
int | neorv32_uart_get_rx_fifo_depth (neorv32_uart_t *UARTx) |
|
int | neorv32_uart_get_tx_fifo_depth (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_enable (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_disable (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_rtscts_enable (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_rtscts_disable (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_putc (neorv32_uart_t *UARTx, char c) |
|
void | neorv32_uart_rx_clear (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_tx_clear (neorv32_uart_t *UARTx) |
|
int | neorv32_uart_tx_busy (neorv32_uart_t *UARTx) |
|
char | neorv32_uart_getc (neorv32_uart_t *UARTx) |
|
int | neorv32_uart_char_received (neorv32_uart_t *UARTx) |
|
char | neorv32_uart_char_received_get (neorv32_uart_t *UARTx) |
|
void | neorv32_uart_puts (neorv32_uart_t *UARTx, const char *s) |
|
void | neorv32_uart_vprintf (neorv32_uart_t *UARTx, const char *format, va_list args) |
|
void | neorv32_uart_printf (neorv32_uart_t *UARTx, const char *format,...) |
|
int | neorv32_uart_scan (neorv32_uart_t *UARTx, char *buffer, int max_size, int echo) |
|
Universal asynchronous receiver/transmitter (UART0/UART1) HW driver source file.
- Note
- These functions should only be used if the UART0/UART1 unit was synthesized.
- See also
- https://stnolting.github.io/neorv32/sw/files.html
◆ neorv32_uart_available()
Check if UART unit was synthesized.
- Parameters
-
- Returns
- 0 if UART0/1 was not synthesized, 1 if UART0/1 is available.
◆ neorv32_uart_char_received()
Check if UART has received a char.
- Note
- This function is non-blocking.
-
Use neorv32_uart_char_received_get(void) to get the char.
- Parameters
-
- Returns
- 1 when a char has been received, 0 otherwise.
◆ neorv32_uart_char_received_get()
Get a received char from UART.
- Note
- This function is non-blocking.
-
Should only be used in combination with neorv32_uart_char_received(void).
- Parameters
-
- Returns
- Received char.
◆ neorv32_uart_disable()
◆ neorv32_uart_enable()
◆ neorv32_uart_get_rx_fifo_depth()
Get UART RX FIFO depth.
- Parameters
-
- Returns
- FIFO depth (number of entries)
◆ neorv32_uart_get_tx_fifo_depth()
Get UART TX FIFO depth.
- Parameters
-
- Returns
- FIFO depth (number of entries)
◆ neorv32_uart_getc()
Get char from UART.
- Note
- This function is blocking.
- Parameters
-
- Returns
- Received char.
◆ neorv32_uart_printf()
void neorv32_uart_printf |
( |
neorv32_uart_t * | UARTx, |
|
|
const char * | format, |
|
|
| ... ) |
Custom version of 'printf' printing to UART.
- Warning
- : This functions only provides a minimal subset of the 'printf' formatting features!
- Note
- This function is blocking.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in] | format | Pointer to format string. See neorv32_uart_vprintf. |
◆ neorv32_uart_putc()
Send single char via UART.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in] | c | Char to be send. |
◆ neorv32_uart_puts()
Print string (zero-terminated) via UART. Print full line break "\r\n" for every '
'.
- Note
- This function is blocking.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in] | s | Pointer to string. |
◆ neorv32_uart_rtscts_disable()
Disable RTS/CTS hardware flow-control.
- Parameters
-
◆ neorv32_uart_rtscts_enable()
Enable RTS/CTS hardware flow-control.
- Parameters
-
◆ neorv32_uart_rx_clear()
Clear RX FIFO.
- Parameters
-
◆ neorv32_uart_scan()
int neorv32_uart_scan |
( |
neorv32_uart_t * | UARTx, |
|
|
char * | buffer, |
|
|
int | max_size, |
|
|
int | echo ) |
Simplified custom version of 'scanf' reading from UART.
- Note
- This function is blocking.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in,out] | buffer | Pointer to array of chars to store string. |
[in] | max_size | Maximum number of chars to sample (including zero-termination). |
[in] | echo | Echo UART input when 1. |
- Returns
- Number of chars read.
◆ neorv32_uart_setup()
void neorv32_uart_setup |
( |
neorv32_uart_t * | UARTx, |
|
|
uint32_t | baudrate, |
|
|
uint32_t | irq_mask ) |
Reset, configure and enable UART.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in] | baudrate | Targeted BAUD rate (e.g. 19200). |
[in] | irq_mask | Interrupt configuration mask (CTRL's irq_* bits). |
◆ neorv32_uart_tx_busy()
Check if UART TX is busy (transmitter busy or data left in TX buffer).
- Parameters
-
- Returns
- 0 if idle, 1 if busy
◆ neorv32_uart_tx_clear()
Clear TX FIFO.
- Parameters
-
◆ neorv32_uart_vprintf()
void neorv32_uart_vprintf |
( |
neorv32_uart_t * | UARTx, |
|
|
const char * | format, |
|
|
va_list | args ) |
Custom version of 'vprintf' printing to UART.
- Warning
- : This functions only provides a minimal subset of the 'vprintf' formating features!
- Note
- This function is blocking.
- Parameters
-
[in,out] | UARTx | Hardware handle to UART register struct, neorv32_uart_t. |
[in] | format | Pointer to format string. |
[in] | args | A value identifying a variable arguments list. |