NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
neorv32_uart.h
Go to the documentation of this file.
1// #################################################################################################
2// # << NEORV32: neorv32_uart.h - Universal Asynchronous Receiver/Transmitter (UART) HW Driver >> #
3// # ********************************************************************************************* #
4// # BSD 3-Clause License #
5// # #
6// # Copyright (c) 2023, Stephan Nolting. All rights reserved. #
7// # #
8// # Redistribution and use in source and binary forms, with or without modification, are #
9// # permitted provided that the following conditions are met: #
10// # #
11// # 1. Redistributions of source code must retain the above copyright notice, this list of #
12// # conditions and the following disclaimer. #
13// # #
14// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
15// # conditions and the following disclaimer in the documentation and/or other materials #
16// # provided with the distribution. #
17// # #
18// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
19// # endorse or promote products derived from this software without specific prior written #
20// # permission. #
21// # #
22// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
23// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
24// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
25// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
26// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
27// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
28// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
29// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
30// # OF THE POSSIBILITY OF SUCH DAMAGE. #
31// # ********************************************************************************************* #
32// # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
33// #################################################################################################
34
35
36/**********************************************************************/
41#ifndef neorv32_uart_h
42#define neorv32_uart_h
43
44// Libs required by functions
45#include <stdarg.h>
46
47/**********************************************************************/
52typedef volatile struct __attribute__((packed,aligned(4))) {
53 uint32_t CTRL;
54 uint32_t DATA;
56
58#define NEORV32_UART0 ((neorv32_uart_t*) (NEORV32_UART0_BASE))
59
61#define NEORV32_UART1 ((neorv32_uart_t*) (NEORV32_UART1_BASE))
62
97};
101/**********************************************************************/
106void neorv32_uart_setup(neorv32_uart_t *UARTx, uint32_t baudrate, uint32_t irq_mask);
111void neorv32_uart_putc(neorv32_uart_t *UARTx, char c);
116void neorv32_uart_puts(neorv32_uart_t *UARTx, const char *s);
117void neorv32_uart_printf(neorv32_uart_t *UARTx, const char *format, ...);
118int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int echo);
122#endif // neorv32_uart_h
char neorv32_uart_getc(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:216
void neorv32_uart_puts(neorv32_uart_t *UARTx, const char *s)
Definition: neorv32_uart.c:269
void neorv32_uart_rtscts_enable(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:160
void neorv32_uart_rtscts_disable(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:171
void neorv32_uart_putc(neorv32_uart_t *UARTx, char c)
Definition: neorv32_uart.c:183
void neorv32_uart_setup(neorv32_uart_t *UARTx, uint32_t baudrate, uint32_t irq_mask)
Definition: neorv32_uart.c:81
char neorv32_uart_char_received_get(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:255
int neorv32_uart_tx_busy(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:197
void neorv32_uart_printf(neorv32_uart_t *UARTx, const char *format,...)
Definition: neorv32_uart.c:299
int neorv32_uart_available(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:60
int neorv32_uart_scan(neorv32_uart_t *UARTx, char *buffer, int max_size, int echo)
Definition: neorv32_uart.c:371
NEORV32_UART_CTRL_enum
Definition: neorv32_uart.h:64
@ UART_CTRL_BAUD8
Definition: neorv32_uart.h:79
@ UART_CTRL_TX_BUSY
Definition: neorv32_uart.h:96
@ UART_CTRL_IRQ_TX_EMPTY
Definition: neorv32_uart.h:92
@ UART_CTRL_PRSC0
Definition: neorv32_uart.h:68
@ UART_CTRL_BAUD1
Definition: neorv32_uart.h:72
@ UART_CTRL_RX_NEMPTY
Definition: neorv32_uart.h:82
@ UART_CTRL_BAUD2
Definition: neorv32_uart.h:73
@ UART_CTRL_TX_FULL
Definition: neorv32_uart.h:87
@ UART_CTRL_EN
Definition: neorv32_uart.h:65
@ UART_CTRL_RX_HALF
Definition: neorv32_uart.h:83
@ UART_CTRL_SIM_MODE
Definition: neorv32_uart.h:66
@ UART_CTRL_RX_FULL
Definition: neorv32_uart.h:84
@ UART_CTRL_IRQ_RX_NEMPTY
Definition: neorv32_uart.h:89
@ UART_CTRL_BAUD3
Definition: neorv32_uart.h:74
@ UART_CTRL_TX_NHALF
Definition: neorv32_uart.h:86
@ UART_CTRL_BAUD5
Definition: neorv32_uart.h:76
@ UART_CTRL_BAUD9
Definition: neorv32_uart.h:80
@ UART_CTRL_IRQ_TX_NHALF
Definition: neorv32_uart.h:93
@ UART_CTRL_RX_OVER
Definition: neorv32_uart.h:95
@ UART_CTRL_BAUD4
Definition: neorv32_uart.h:75
@ UART_CTRL_PRSC2
Definition: neorv32_uart.h:70
@ UART_CTRL_BAUD6
Definition: neorv32_uart.h:77
@ UART_CTRL_BAUD7
Definition: neorv32_uart.h:78
@ UART_CTRL_PRSC1
Definition: neorv32_uart.h:69
@ UART_CTRL_IRQ_RX_HALF
Definition: neorv32_uart.h:90
@ UART_CTRL_TX_EMPTY
Definition: neorv32_uart.h:85
@ UART_CTRL_HWFC_EN
Definition: neorv32_uart.h:67
@ UART_CTRL_BAUD0
Definition: neorv32_uart.h:71
@ UART_CTRL_IRQ_RX_FULL
Definition: neorv32_uart.h:91
int neorv32_uart_char_received(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:235
void neorv32_uart_disable(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:149
void neorv32_uart_enable(neorv32_uart_t *UARTx)
Definition: neorv32_uart.c:138
Definition: neorv32_uart.h:52
uint32_t CTRL
Definition: neorv32_uart.h:53
uint32_t DATA
Definition: neorv32_uart.h:54