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
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
8#include "rv64_platform.h"
9#include "clint/clint.h"
10#include "gpio/gpio.h"
11#include "plic/plic.h"
12#include "uart/uart.h"
13#include "debug.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
20 /*
21 * Default main peripherals for SoC.
22 */
24
25#define BSP_PLIC SYSTEM_PLIC_CTRL
26#define BSP_PLIC_CPU_0 SYSTEM_PLIC_CPU_0_MEI
27#define BSP_UART_BAUDRATE 115200
28#define BSP_UART_DATA_LEN 8
29#define BSP_CLINT SYSTEM_CLINT_CTRL
30#define BSP_CLINT_HZ SYSTEM_CLINT_HZ
31#define bsp_uDelay(usec) clint_uDelay(usec, SYSTEM_CLINT_HZ);
32
33#if (SYSTEM_UART_0_IO_CTRL)
34 // Real UART Hardware
35 extern uart_instance_t uart0;
36 #define BSP_UART_TERMINAL SYSTEM_UART_0_IO_CTRL
37 #define bsp_putChar(c) uart_write(&uart0, c)
38 #define bsp_getChar() uart_read(&uart0)
39#else
40 // Dummy Implementation
41 #define BSP_UART_TERMINAL 0
42 #define bsp_putChar(c) ((void)0)
43 #define bsp_getChar() (0)
44#endif
45
46
47
48
49// #define BSP_UART_TERMINAL SYSTEM_UART_0_IO_CTRL
50// #define BSP_UART_BAUDRATE 115200
51// #define BSP_UART_DATA_LEN 8
52// #define bsp_putChar(c) uart_write(&uart0, c);
53// #define bsp_getChar() uart_read(&uart0);
54
55void bsp_init();
56
58 /*
59 * BSP_PRINTF -> Enable when switch to nosys.spec
60 */
62
63#if(USELIB == 0)
64 static int bsp_printf(const char *format, ...);
65 #define printf(...) (bsp_printf(__VA_ARGS__))
66
68 /*
69 * Support printing for char, string , decimal and hexadecinaml specifier.
70 * Support print_float and print_dec function.
71 * Uses moderate memory resource.
72 */
74#define ENABLE_BSP_PRINTF 1
75
77 /*
78 * Full support for printf function, including flag and precisions.
79 * Uses more memory resource.
80 */
82#define ENABLE_BSP_PRINTF_FULL 1
83
85 /*
86 * Enable the function sharing between 'full' and 'lite' printing.
87 */
89#define ENABLE_BRIDGE_FULL_TO_LITE 1
90
92 /*
93 * Enable more printing specifier like floating point, exponential,
94 * pointer difference and long long data type.
95 */
97#define ENABLE_FLOATING_POINT_SUPPORT 0 //Printing only
98#define ENABLE_FP_EXPONENTIAL_SUPPORT 0
99#define ENABLE_PTRDIFF_SUPPORT 0
100#define ENABLE_LONG_LONG_SUPPORT 1
101
103 /*
104 * Warning message when specifier is not supported.
105 */
107#define ENABLE_PRINTF_WARNING 1
108
110 /*
111 * Enable printing with semihosting.
112 */
114#define ENABLE_SEMIHOSTING_PRINT 0
115
116
117#if (ENABLE_BSP_PRINTF)
118 #include "print.h"
119#endif
120
121#if (ENABLE_BSP_PRINTF_FULL)
122 #if (!ENABLE_FLOATING_POINT_SUPPORT)
123 #define PRINTF_DISABLE_SUPPORT_FLOAT 1
124 #endif
125
126 #if (!ENABLE_FP_EXPONENTIAL_SUPPORT)
127 #define PRINTF_DISABLE_SUPPORT_EXPONENTIAL 1
128 #endif
129
130 #if (!ENABLE_PTRDIFF_SUPPORT)
131 #define PRINTF_DISABLE_SUPPORT_PTRDIFF_T 1
132 #endif
133
134 #if (!ENABLE_LONG_LONG_SUPPORT)
135 #define PRINTF_DISABLE_SUPPORT_LONG_LONG 1
136 #endif
137
138 #if(ENABLE_BRIDGE_FULL_TO_LITE)
139 #if (!ENABLE_BSP_PRINTF)
140 #define bsp_printf bsp_printf_full
141 #endif
142 #endif
143
144 #include "print_full.h"
145
146#endif
147#endif
148
149
150#ifdef __cplusplus
151}
152#endif
153
154#endif
uart_instance_t uart0
Definition bsp.c:4
void bsp_init()
Definition bsp.c:6
CLINT driver API definitions.
DEBUG driver API definitions.
GPIO driver API definitions.
PLIC driver API definitions.
UART instance. Holds the software registers and hardware pointer.
Definition uart.h:114
UART driver API definitions.