Sapphire SoC DS Sapphire SoC UG Sapphire HP SoC DS Sapphire HP SoC UG RISC-V Embedded IDE UG Board Support Package
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
36
37
38/* ========================================================================== */
39/* SUB-GROUP : Data Types */
40/* ========================================================================== */
41
49 typedef enum {
50 BITS_6 = 6,
51 BITS_7 = 7,
52 BITS_8 = 8
54
56 typedef enum {
57 NONE = 0,
58 EVEN = 1,
59 ODD = 2
61
63 typedef enum {
64 ONE = 0,
65 TWO = 1
67
68
69/* ========================================================================== */
70/* SUB-GROUP : DATA STRUCTS */
71/* ========================================================================== */
97
108
122 // End of UART_Types group
124
125
126/* ========================================================================== */
127/* SUB-GROUP: FUNCTIONS */
128/* ========================================================================== */
129
136
143
150
160
170
176
177
186 void uart_write(uart_instance_t *inst, char data);
187
195 void uart_writeStr(uart_instance_t *inst, const char* str);
196
204 void uart_writeHex(uart_instance_t *inst, int value);
210 void uart_status_write(uart_instance_t *inst, u32 data);
211
218 void uart_TX_emptyInterruptEna(uart_instance_t *inst, char Ena);
219
226 void uart_RX_NotemptyInterruptEna(uart_instance_t *inst, char Ena);
227 // End of UART_Funcs group
229#ifdef __cplusplus
230}
231#endif
232 // End of MAIN UART Group
234
235#endif // UART_H
236
237
238
cfg_stopBits_t
UART Stop Bits.
Definition uart.h:63
cfg_dataLength_t
UART data Length.
Definition uart.h:49
cfg_dataParity_t
UART data Parity.
Definition uart.h:56
@ TWO
Two Stop Bits *‍/.
Definition uart.h:65
@ ONE
One Stop Bit *‍/.
Definition uart.h:64
@ BITS_7
7-bit data length *‍/
Definition uart.h:51
@ BITS_6
6-bit data length *‍/
Definition uart.h:50
@ BITS_8
8-bit data length *‍/
Definition uart.h:52
@ EVEN
Even Parity *‍/.
Definition uart.h:58
@ ODD
Odd Parity *‍/.
Definition uart.h:59
@ NONE
No Parity *‍/.
Definition uart.h:57
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_status_write(uart_instance_t *inst, u32 data)
Writes a value to the UART status register.
Definition uart.c:37
void uart_writeHex(uart_instance_t *inst, int value)
Write integer as decimal to UART.
Definition uart.c:60
u32 uart_status_read(uart_instance_t *inst)
Write 32-bit UART data.
Definition uart.c:31
void uart_RX_NotemptyInterruptEna(uart_instance_t *inst, char Ena)
Enable or Disable UART RX Not Empty Interrupt.
Definition uart.c:81
u32 uart_writeAvailability(uart_instance_t *inst)
Checks the availability of the UART buffer for writing data.
Definition uart.c:22
void uart_TX_emptyInterruptEna(uart_instance_t *inst, char Ena)
Enable or Disable UART TX Empty Interrupt.
Definition uart.c:75
u32 uart_readOccupancy(uart_instance_t *inst)
Checks the occupancy of the UART buffer for reading data.
Definition uart.c:26
u32 uart_read(uart_instance_t *inst)
Read 32-bit UART data.
Definition uart.c:43
void uart_applyConfig(uart_instance_t *inst)
Apply stored UART configuration to hardware.
Definition uart.c:68
UART hardware register map.
Definition uart.h:102
u32 CLOCK_DIVIDER
Address Offset: 0x08 - Clock Divider Register *‍/.
Definition uart.h:105
u32 DATA
Address Offset: 0x00 - Data Register *‍/.
Definition uart.h:103
u32 FRAME_CONFIG
Address Offset: 0x0C - Frame Configuration Register *‍/.
Definition uart.h:106
u32 STATUS
Address Offset: 0x04 - Status Register *‍/.
Definition uart.h:104
UART instance. Holds the software registers and hardware pointer.
Definition uart.h:114
u8 irqn
UART IRQ Number *‍/.
Definition uart.h:120
cfg_dataParity_t parity
Parity Configuration *‍/.
Definition uart.h:117
cfg_dataLength_t dataLength
Data Length Configuration *‍/.
Definition uart.h:116
uart_hwreg_t * hwreg
Pointer to Hardware Register Map *‍/.
Definition uart.h:115
u32 clockDivider
Clock Divider Value *‍/.
Definition uart.h:119
cfg_stopBits_t stop
Stop Bits Configuration *‍/.
Definition uart.h:118
uint8_t u8
Definition type.h:26
uint32_t u32
Definition type.h:22