RV32 SoC DS UG
High-Perf RV32 SoC DS UG
RV64 SoC DS UG API and Examples
Embedded IDE UG
Loading...
Searching...
No Matches
bsp.h
Go to the documentation of this file.
1
2// Copyright (C) 2013-2026 Efinix Inc. All rights reserved.
3//
5#ifndef BSP_H
6#define BSP_H
7
18
19/* --- Board & Peripheral Drivers --- */
20#include "boards/rv64_platform.h"
21#include "clint/clint.h"
22#include "uart/uart.h"
23#include "debug.h"
24#include "soc.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
35
36/* ========================================================================== */
37/* DEFAULT MAIN PERIPHERALS FOR SOC */
38/* ========================================================================== */
39 //
50 #define BSP_PLIC SYSTEM_PLIC_CTRL
51 #define BSP_PLIC_CPU_0 SYSTEM_PLIC_CPU_0_MEI
52 #define BSP_CLINT SYSTEM_CLINT_CTRL
53 #define BSP_CLINT_HZ SYSTEM_CLINT_HZ
54 #define BSP_UART_BAUDRATE 115200
55 #define BSP_UART_DATA_LEN 8
56 #define ENABLE_SEMIHOSTING_PRINT 0
57
58 #if (SYSTEM_UART_0_IO_CTRL || defined(__DOXYGEN__))
59 /* Hardware UART is enabled in Efinix Sapphire Soc */
60 extern uart_instance_t uart0;
61 #define BSP_UART_TERMINAL SYSTEM_UART_0_IO_CTRL
62 #else
63 // No Hardware UART present. Provide safe dummy macros.
64 #define BSP_UART_TERMINAL 0
65 #endif
66 //
68
75
79 void bsp_init();
80
84 #define bsp_uDelay(usec) clint_uDelay(usec, SYSTEM_CLINT_HZ)
85
86 #if (SYSTEM_UART_0_IO_CTRL || defined(__DOXYGEN__))
87 /* Hardware UART is enabled in Efinix Sapphire Soc */
95 #define bsp_putChar(c) uart_write(&uart0, c)
103 #define bsp_getChar() uart_read(&uart0)
104 #else
105 /* No Hardware UART present. Provide safe dummy macros. */
106 #define bsp_putChar(c) ((void)0)
107 #define bsp_getChar() (0)
108 #endif //
110
111/* ========================================================================== */
112/* Internal Module Inclusion Logic (SemiHosting) */
113/* ========================================================================== */
114
115 #if (ENABLE_SEMIHOSTING_PRINT == 1)
116 #include "semihosting.h"
117 #endif
118
119/* ========================================================================== */
120/* TINY PRINTF CONFIG (USELIB == 0, NEWLIB=NOSTD) */
121/* ========================================================================== */
122
123#if(USELIB == 0)
139 static int bsp_printf(const char *format, ...);
140
145 #define printf(...) (bsp_printf(__VA_ARGS__))
147
154 #define ENABLE_BSP_PRINTF 1
155
157 #define ENABLE_BSP_PRINTF_FULL 1
158
160 #define ENABLE_BRIDGE_FULL_TO_LITE 1
161
163 #define ENABLE_PRINTF_WARNING 1
165
171 #define ENABLE_FLOATING_POINT_SUPPORT 0
172 #define ENABLE_FP_EXPONENTIAL_SUPPORT 0
173 #define ENABLE_PTRDIFF_SUPPORT 0
174 #define ENABLE_LONG_LONG_SUPPORT 1
176
177
178 /* ========================================================================== */
179 /* Internal Module Inclusion Logic (SemiHosting) */
180 /* ========================================================================== */
182 #if (ENABLE_BSP_PRINTF)
183 #include "print.h"
184 #endif
185
186 #if (ENABLE_BSP_PRINTF_FULL)
187
188 #if (!ENABLE_FLOATING_POINT_SUPPORT)
189 #define PRINTF_DISABLE_SUPPORT_FLOAT 1
190 #endif
191
192 #if (!ENABLE_FP_EXPONENTIAL_SUPPORT)
193 #define PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1
194 #endif
195
196 #if (!ENABLE_PTRDIFF_SUPPORT)
197 #define PRINTF_DISABLE_SUPPORT_PTRDIFF_T 1
198 #endif
199
200 #if (!ENABLE_LONG_LONG_SUPPORT)
201 #define PRINTF_DISABLE_SUPPORT_LONG_LONG 1
202 #endif
203
204 #if (ENABLE_BRIDGE_FULL_TO_LITE)
205 #if (!ENABLE_BSP_PRINTF)
206 #define bsp_printf bsp_printf_full
207 #endif
208 #endif
209
210 #include "print_full.h"
211 #endif
213#endif // USELIB == 0
214 //
216#ifdef __cplusplus
217}
218#endif
219
220#endif // BSP_H
CLINT driver API definitions.
Debug, logging, and assertion API.
void bsp_init()
Initialize Board Support Package Peripherals.
Definition bsp.c:6
uart_instance_t uart0
Primary UART instance for standard I/O mapping.
Definition bsp.c:4
UART instance. Holds the software registers and hardware pointer.
Definition uart.h:140
UART driver API definitions.