API Reference
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32_uart.c File Reference

Universal asynchronous receiver/transmitter (UART0/UART1) HW driver source file. More...

#include <neorv32.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>

Functions

int neorv32_uart_available (neorv32_uart_t *uartx)
void neorv32_uart_setup (neorv32_uart_t *uartx, uint32_t baud, int rx_irq, int tx_irq)
void neorv32_uart_putc (neorv32_uart_t *uartx, char c)
char neorv32_uart_getc (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)

Detailed Description

Universal asynchronous receiver/transmitter (UART0/UART1) HW driver source file.

Function Documentation

◆ neorv32_uart_available()

int neorv32_uart_available ( neorv32_uart_t * uartx)

Check if UART module was synthesized.

Parameters
[in,out]uartxUART hardware struct.
Returns
0 if UART0/1 was not synthesized, non-zero if UART0/1 is available.

◆ neorv32_uart_getc()

char neorv32_uart_getc ( neorv32_uart_t * uartx)

Get received char.

Note
Blocking function (block until RX data available).
Parameters
[in,out]uartxUART hardware struct.
Returns
Received char.

◆ neorv32_uart_printf()

void neorv32_uart_printf ( neorv32_uart_t * uartx,
const char * format,
... )

Custom version of 'printf'. This functions only provides a minimal subset of the 'printf' formatting features.

Note
Blocking function.
Parameters
[in,out]uartxUART hardware struct.
[in]formatPointer to format string. See neorv32_uart_vprintf.

◆ neorv32_uart_putc()

void neorv32_uart_putc ( neorv32_uart_t * uartx,
char c )

Transmit char.

Note
Blocking function (block until transmission can be issued).
Parameters
[in,out]uartxUART hardware struct.
[in]cChar to be send.

◆ neorv32_uart_puts()

void neorv32_uart_puts ( neorv32_uart_t * uartx,
const char * s )

Print zero-terminated string. No trailing line break is added. Newline (LF) line breaks are automatically converted to CR-LF.

Note
Blocking function.
Parameters
[in,out]uartxUART hardware struct.
[in]sPointer to string.

◆ neorv32_uart_scan()

int neorv32_uart_scan ( neorv32_uart_t * uartx,
char * buffer,
int max_size,
int echo )

Custom version of 'scanf'.

Note
Blocking function.
Parameters
[in,out]uartxUART hardware struct.
[in,out]bufferPointer to array of chars to store string.
[in]max_sizeMaximum number of chars to sample (including zero-termination).
[in]echoEcho UART input when 1.
Returns
Number of chars read.

◆ neorv32_uart_setup()

void neorv32_uart_setup ( neorv32_uart_t * uartx,
uint32_t baud,
int rx_irq,
int tx_irq )

Reset, configure and enable UART.

Parameters
[in,out]uartxUART hardware struct.
[in]baudTargeted BAUD rate (e.g. 19200, must be greater than zero).
[in]rx_irqRX interrupt condition (NEORV32_UART_RX_IRQ_SEL_enum).
[in]tx_irqTX interrupt condition (NEORV32_UART_TX_IRQ_SEL_enum).

◆ neorv32_uart_vprintf()

void neorv32_uart_vprintf ( neorv32_uart_t * uartx,
const char * format,
va_list args )

Custom version of 'vprintf'. This functions only provides a minimal subset of the original formatting features. Newline (LF) line breaks are automatically converted to CR-LF.

Note
Blocking function.
Parameters
[in,out]uartxUART hardware struct.
[in]formatPointer to format string.
[in]argsA value identifying a variable arguments list.