[uart] add non-blocking TX functions
Some checks are pending
Processor / processor simulation (push) Waiting to run

This commit is contained in:
stnolting 2025-04-20 07:19:51 +02:00
parent e3b96cced0
commit 1eab05070d
2 changed files with 32 additions and 0 deletions

View file

@ -102,6 +102,8 @@ 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);
int neorv32_uart_tx_free(neorv32_uart_t *UARTx);
void neorv32_uart_tx_put(neorv32_uart_t *UARTx, char c);
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);
@ -128,6 +130,8 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ec
#define neorv32_uart0_rx_clear() neorv32_uart_rx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_clear() neorv32_uart_tx_clear(NEORV32_UART0)
#define neorv32_uart0_tx_busy() neorv32_uart_tx_busy(NEORV32_UART0)
#define neorv32_uart0_tx_free() neorv32_uart_tx_free(NEORV32_UART0)
#define neorv32_uart0_tx_put(c) neorv32_uart_tx_put(NEORV32_UART0, c)
#define neorv32_uart0_getc() neorv32_uart_getc(NEORV32_UART0)
#define neorv32_uart0_char_received() neorv32_uart_char_received(NEORV32_UART0)
#define neorv32_uart0_char_received_get() neorv32_uart_char_received_get(NEORV32_UART0)
@ -147,6 +151,8 @@ int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int ec
#define neorv32_uart1_rx_clear() neorv32_uart_rx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_clear() neorv32_uart_tx_clear(NEORV32_UART1)
#define neorv32_uart1_tx_busy() neorv32_uart_tx_busy(NEORV32_UART1)
#define neorv32_uart1_tx_free() neorv32_uart_tx_free(NEORV32_UART1)
#define neorv32_uart1_tx_put(c) neorv32_uart_tx_put(NEORV32_UART1, c)
#define neorv32_uart1_getc() neorv32_uart_getc(NEORV32_UART1)
#define neorv32_uart1_char_received() neorv32_uart_char_received(NEORV32_UART1)
#define neorv32_uart1_char_received_get() neorv32_uart_char_received_get(NEORV32_UART1)

View file

@ -194,6 +194,8 @@ void neorv32_uart_rtscts_disable(neorv32_uart_t *UARTx) {
/**********************************************************************//**
* Send single char via UART.
*
* @note This function is blocking.
*
* @param[in,out] UARTx Hardware handle to UART register struct, #neorv32_uart_t.
* @param[in] c Char to be send.
**************************************************************************/
@ -244,6 +246,30 @@ int neorv32_uart_tx_busy(neorv32_uart_t *UARTx) {
}
/**********************************************************************//**
* Check if there is free space in the TX output FIFO.
*
* @param[in,out] UARTx Hardware handle to UART register struct, #neorv32_uart_t.
* @return Zero if TX FIFO is full, non-zero if at least one free entry is left.
**************************************************************************/
int neorv32_uart_tx_free(neorv32_uart_t *UARTx) {
return (int)~(UARTx->CTRL & (1<<UART_CTRL_TX_FULL));
}
/**********************************************************************//**
* Put char to TX output FIFO.
*
* @param[in,out] UARTx Hardware handle to UART register struct, #neorv32_uart_t.
* @param[in] c Character to be send.
**************************************************************************/
void neorv32_uart_tx_put(neorv32_uart_t *UARTx, char c) {
UARTx->DATA = (uint32_t)c << UART_DATA_RTX_LSB;
}
/**********************************************************************//**
* Get char from UART.
*