Universal asynchronous receiver/transmitter (UART0/UART1) HW driver header file.
More...
#include <stdarg.h>
Go to the source code of this file.
|
int | neorv32_uart0_available (void) |
|
void | neorv32_uart0_setup (uint32_t baudrate, uint8_t parity, uint8_t flow_con) |
|
void | neorv32_uart0_disable (void) |
|
void | neorv32_uart0_enable (void) |
|
void | neorv32_uart0_putc (char c) |
|
int | neorv32_uart0_tx_busy (void) |
|
char | neorv32_uart0_getc (void) |
|
int | neorv32_uart0_char_received (void) |
|
int | neorv32_uart0_getc_safe (char *data) |
|
char | neorv32_uart0_char_received_get (void) |
|
void | neorv32_uart0_print (const char *s) |
|
void | neorv32_uart0_printf (const char *format,...) |
|
int | neorv32_uart0_scan (char *buffer, int max_size, int echo) |
|
int | neorv32_uart1_available (void) |
|
void | neorv32_uart1_setup (uint32_t baudrate, uint8_t parity, uint8_t flow_con) |
|
void | neorv32_uart1_disable (void) |
|
void | neorv32_uart1_enable (void) |
|
void | neorv32_uart1_putc (char c) |
|
int | neorv32_uart1_tx_busy (void) |
|
char | neorv32_uart1_getc (void) |
|
int | neorv32_uart1_char_received (void) |
|
int | neorv32_uart1_getc_safe (char *data) |
|
char | neorv32_uart1_char_received_get (void) |
|
void | neorv32_uart1_print (const char *s) |
|
void | neorv32_uart1_printf (const char *format,...) |
|
int | neorv32_uart1_scan (char *buffer, int max_size, int echo) |
|
Universal asynchronous receiver/transmitter (UART0/UART1) HW driver header file.
- Warning
- UART0 (primary UART) is used as default user console interface for all NEORV32 software framework/library functions.
- Note
- These functions should only be used if the UART0/UART1 unit was synthesized (IO_UART0_EN = true / IO_UART1_EN = true).
◆ neorv32_uart0_available()
int neorv32_uart0_available |
( |
void |
| ) |
|
Check if UART0 unit was synthesized.
- Returns
- 0 if UART0 was not synthesized, 1 if UART0 is available.
◆ neorv32_uart0_char_received()
int neorv32_uart0_char_received |
( |
void |
| ) |
|
◆ neorv32_uart0_char_received_get()
char neorv32_uart0_char_received_get |
( |
void |
| ) |
|
Get a received char from UART0.
- Note
- This function is non-blocking.
-
Should only be used in combination with neorv32_uart_char_received(void).
- Returns
- Received char.
◆ neorv32_uart0_disable()
void neorv32_uart0_disable |
( |
void |
| ) |
|
◆ neorv32_uart0_enable()
void neorv32_uart0_enable |
( |
void |
| ) |
|
◆ neorv32_uart0_getc()
char neorv32_uart0_getc |
( |
void |
| ) |
|
Get char from UART0.
- Note
- This function is blocking and does not check for UART frame/parity errors.
- Returns
- Received char.
◆ neorv32_uart0_getc_safe()
int neorv32_uart0_getc_safe |
( |
char * |
data | ) |
|
Get char from UART0 (and check errors).
- Note
- This function is non-blocking and checks for frame and parity errors.
- Parameters
-
[in,out] | data | Received char. |
- Returns
- Status code: 0 = char received without errors -1 = nothing received -2 = char received with frame error -3 = char received with parity error -4 = char received with overrun error.
◆ neorv32_uart0_print()
void neorv32_uart0_print |
( |
const char * |
s | ) |
|
Print string (zero-terminated) via UART0. Print full line break "\r\n" for every '
'.
- Note
- This function is blocking.
- Parameters
-
◆ neorv32_uart0_printf()
void neorv32_uart0_printf |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
Custom version of 'printf' function using UART0.
- Note
- This function is blocking.
- Parameters
-
[in] | format | Pointer to format string. |
s | String (array of chars, zero-terminated) |
c | Single char |
d/i | 32-bit signed number, printed as decimal |
u | 32-bit unsigned number, printed as decimal |
x | 32-bit number, printed as 8-char hexadecimal - lower-case |
X | 32-bit number, printed as 8-char hexadecimal - upper-case |
p | 32-bit pointer, printed as 8-char hexadecimal - lower-case |
◆ neorv32_uart0_putc()
void neorv32_uart0_putc |
( |
char |
c | ) |
|
Send single char via UART0.
- Note
- This function is blocking.
- Parameters
-
◆ neorv32_uart0_scan()
int neorv32_uart0_scan |
( |
char * |
buffer, |
|
|
int |
max_size, |
|
|
int |
echo |
|
) |
| |
Simplified custom version of 'scanf' function for UART0.
- Note
- This function is blocking.
- Parameters
-
[in,out] | buffer | Pointer to array of chars to store string. |
[in] | max_size | Maximum number of chars to sample. |
[in] | echo | Echo UART input when 1. |
- Returns
- Number of chars read.
◆ neorv32_uart0_setup()
void neorv32_uart0_setup |
( |
uint32_t |
baudrate, |
|
|
uint8_t |
parity, |
|
|
uint8_t |
flow_con |
|
) |
| |
Enable and configure primary UART (UART0).
- Note
- The 'UART0_SIM_MODE' compiler flag will configure UART0 for simulation mode: all UART0 TX data will be redirected to simulation output. Use this for simulations only!
-
To enable simulation mode add <USER_FLAGS+=-DUART0_SIM_MODE> when compiling.
- Warning
- The baud rate is computed using INTEGER operations (truncation errors might occur).
- Parameters
-
◆ neorv32_uart0_tx_busy()
int neorv32_uart0_tx_busy |
( |
void |
| ) |
|
Check if UART0 TX is busy (transmitter busy or data left in TX buffer).
- Note
- This function is blocking.
- Returns
- 0 if idle, 1 if busy
◆ neorv32_uart1_available()
int neorv32_uart1_available |
( |
void |
| ) |
|
Check if UART1 unit was synthesized.
- Returns
- 0 if UART1 was not synthesized, 1 if UART1 is available.
◆ neorv32_uart1_char_received()
int neorv32_uart1_char_received |
( |
void |
| ) |
|
◆ neorv32_uart1_char_received_get()
char neorv32_uart1_char_received_get |
( |
void |
| ) |
|
Get a received char from UART1.
- Note
- This function is non-blocking.
-
Should only be used in combination with neorv32_uart_char_received(void).
- Returns
- Received char.
◆ neorv32_uart1_disable()
void neorv32_uart1_disable |
( |
void |
| ) |
|
◆ neorv32_uart1_enable()
void neorv32_uart1_enable |
( |
void |
| ) |
|
◆ neorv32_uart1_getc()
char neorv32_uart1_getc |
( |
void |
| ) |
|
Get char from UART1.
- Note
- This function is blocking and does not check for UART frame/parity errors.
- Returns
- Received char.
◆ neorv32_uart1_getc_safe()
int neorv32_uart1_getc_safe |
( |
char * |
data | ) |
|
Get char from UART1 (and check errors).
- Note
- This function is non-blocking and checks for frame and parity errors.
- Parameters
-
[in,out] | data | Received char. |
- Returns
- Status code: 0 = char received without errors -1 = nothing received -2 = char received with frame error -3 = char received with parity error -4 = char received with overrun error.
◆ neorv32_uart1_print()
void neorv32_uart1_print |
( |
const char * |
s | ) |
|
Print string (zero-terminated) via UART1. Print full line break "\r\n" for every '
'.
- Note
- This function is blocking.
- Parameters
-
◆ neorv32_uart1_printf()
void neorv32_uart1_printf |
( |
const char * |
format, |
|
|
|
... |
|
) |
| |
Custom version of 'printf' function using UART1.
- Note
- This function is blocking.
- Parameters
-
[in] | format | Pointer to format string. |
s | String (array of chars, zero-terminated) |
c | Single char |
d/i | 32-bit signed number, printed as decimal |
u | 32-bit unsigned number, printed as decimal |
x | 32-bit number, printed as 8-char hexadecimal - lower-case |
X | 32-bit number, printed as 8-char hexadecimal - upper-case |
p | 32-bit pointer, printed as 8-char hexadecimal - lower-case |
◆ neorv32_uart1_putc()
void neorv32_uart1_putc |
( |
char |
c | ) |
|
Send single char via UART1.
- Note
- This function is blocking.
- Parameters
-
◆ neorv32_uart1_scan()
int neorv32_uart1_scan |
( |
char * |
buffer, |
|
|
int |
max_size, |
|
|
int |
echo |
|
) |
| |
Simplified custom version of 'scanf' function for UART1.
- Note
- This function is blocking.
- Parameters
-
[in,out] | buffer | Pointer to array of chars to store string. |
[in] | max_size | Maximum number of chars to sample. |
[in] | echo | Echo UART input when 1. |
- Returns
- Number of chars read.
◆ neorv32_uart1_setup()
void neorv32_uart1_setup |
( |
uint32_t |
baudrate, |
|
|
uint8_t |
parity, |
|
|
uint8_t |
flow_con |
|
) |
| |
Enable and configure secondary UART (UART1).
- Note
- The 'UART1_SIM_MODE' compiler flag will configure UART1 for simulation mode: all UART1 TX data will be redirected to simulation output. Use this for simulations only!
-
To enable simulation mode add <USER_FLAGS+=-DUART1_SIM_MODE> when compiling.
- Warning
- The baud rate is computed using INTEGER operations (truncation errors might occur).
- Parameters
-
◆ neorv32_uart1_tx_busy()
int neorv32_uart1_tx_busy |
( |
void |
| ) |
|
Check if UART1 TX is busy (transmitter busy or data left in TX buffer).
- Note
- This function is blocking.
- Returns
- 0 if idle, 1 if busy