RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
uart.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3// Full license header bsp/efinix/EfxSapphireSocRV64/include/LICENSE.MD
5
6#ifndef UART_H
7#define UART_H
8
19
20#include "type.h"
21#include "io.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
62
63
64/* ========================================================================== */
65/* SUB-GROUP : Data Types */
66/* ========================================================================== */
67
75 typedef enum {
76 BITS_6 = 6,
77 BITS_7 = 7,
78 BITS_8 = 8
80
82 typedef enum {
83 NONE = 0,
84 EVEN = 1,
85 ODD = 2
87
89 typedef enum {
90 ONE = 0,
91 TWO = 1
93
94
95/* ========================================================================== */
96/* SUB-GROUP : DATA STRUCTS */
97/* ========================================================================== */
123
134
148 // End of UART_Types group
150
151
152/* ========================================================================== */
153/* SUB-GROUP: FUNCTIONS */
154/* ========================================================================== */
155
162
169
176
186
196
202
203
212 void uart_write(uart_instance_t *inst, char data);
213
221 void uart_writeStr(uart_instance_t *inst, const char* str);
222
230 void uart_writeHex(uart_instance_t *inst, int value);
236 void uart_writeStatus(uart_instance_t *inst, u32 data);
237
244 void uart_setTxInterruptEnable(uart_instance_t *inst, char Ena);
245
252 void uart_setRxInterruptEnable(uart_instance_t *inst, char Ena);
253 // End of UART_Funcs group
255#ifdef __cplusplus
256}
257#endif
258 // End of MAIN UART Group
260
261#endif // UART_H
262
263
264
cfg_stopBits_t
UART Stop Bits.
Definition uart.h:89
cfg_dataLength_t
UART data Length.
Definition uart.h:75
cfg_dataParity_t
UART data Parity.
Definition uart.h:82
@ TWO
Two Stop Bits *‍/.
Definition uart.h:91
@ ONE
One Stop Bit *‍/.
Definition uart.h:90
@ BITS_7
7-bit data length *‍/
Definition uart.h:77
@ BITS_6
6-bit data length *‍/
Definition uart.h:76
@ BITS_8
8-bit data length *‍/
Definition uart.h:78
@ EVEN
Even Parity *‍/.
Definition uart.h:84
@ ODD
Odd Parity *‍/.
Definition uart.h:85
@ NONE
No Parity *‍/.
Definition uart.h:83
u32 uart_readStatus(uart_instance_t *inst)
Write 32-bit UART data.
Definition uart.c:31
void uart_writeStr(uart_instance_t *inst, const char *str)
Write string to UART.
Definition uart.c:55
void uart_write(uart_instance_t *inst, char data)
Writes a single character to the UART data register.
Definition uart.c:49
void uart_writeHex(uart_instance_t *inst, int value)
Write integer as decimal to UART.
Definition uart.c:60
void uart_setTxInterruptEnable(uart_instance_t *inst, char Ena)
Enable or Disable UART TX Empty Interrupt.
Definition uart.c:75
u32 uart_getReadOccupancy(uart_instance_t *inst)
Get the occupancy of the UART buffer for reading data.
Definition uart.c:26
u32 uart_getWriteAvailability(uart_instance_t *inst)
Get the availability of the UART buffer for writing data.
Definition uart.c:22
void uart_writeStatus(uart_instance_t *inst, u32 data)
Writes a value to the UART status register.
Definition uart.c:37
u32 uart_read(uart_instance_t *inst)
Read 32-bit UART data.
Definition uart.c:43
void uart_setRxInterruptEnable(uart_instance_t *inst, char Ena)
Enable or Disable UART RX Not Empty Interrupt.
Definition uart.c:81
void uart_applyConfig(uart_instance_t *inst)
Apply stored UART configuration to hardware.
Definition uart.c:68
UART hardware register map.
Definition uart.h:128
u32 CLOCK_DIVIDER
Address Offset: 0x08 - Clock Divider Register *‍/.
Definition uart.h:131
u32 DATA
Address Offset: 0x00 - Data Register *‍/.
Definition uart.h:129
u32 FRAME_CONFIG
Address Offset: 0x0C - Frame Configuration Register *‍/.
Definition uart.h:132
u32 STATUS
Address Offset: 0x04 - Status Register *‍/.
Definition uart.h:130
UART instance. Holds the software registers and hardware pointer.
Definition uart.h:140
u8 irqn
UART IRQ Number *‍/.
Definition uart.h:146
cfg_dataParity_t parity
Parity Configuration *‍/.
Definition uart.h:143
cfg_dataLength_t dataLength
Data Length Configuration *‍/.
Definition uart.h:142
uart_hwreg_t * hwreg
Pointer to Hardware Register Map *‍/.
Definition uart.h:141
u32 clockDivider
Clock Divider Value *‍/.
Definition uart.h:145
cfg_stopBits_t stop
Stop Bits Configuration *‍/.
Definition uart.h:144
uint8_t u8
Definition type.h:30
uint32_t u32
Definition type.h:26