NEORV32 Software Framework Documentation
The NEORV32 RISC-V Processor
Loading...
Searching...
No Matches
neorv32.h
Go to the documentation of this file.
1// ================================================================================ //
2// The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32 //
3// Copyright (c) NEORV32 contributors. //
4// Copyright (c) 2020 - 2024 Stephan Nolting. All rights reserved. //
5// Licensed under the BSD-3-Clause license, see LICENSE for details. //
6// SPDX-License-Identifier: BSD-3-Clause //
7// ================================================================================ //
8
16#ifndef neorv32_h
17#define neorv32_h
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23// Standard libraries
24#include <stdint.h>
25#include <inttypes.h>
26#include <unistd.h>
27#include <stdlib.h>
28
29
30/**********************************************************************/
35#define XIP_MEM_BASE_ADDRESS (0xE0000000U)
37#define BOOTLOADER_BASE_ADDRESS (0xFFFFC000U)
39#define IO_BASE_ADDRESS (0xFFFFE000U)
43/**********************************************************************/
47//#define NEORV32_???_BASE (0xFFFFE000U) /**< reserved */
48//#define NEORV32_???_BASE (0xFFFFE100U) /**< reserved */
49//#define NEORV32_???_BASE (0xFFFFE200U) /**< reserved */
50//#define NEORV32_???_BASE (0xFFFFE300U) /**< reserved */
51//#define NEORV32_???_BASE (0xFFFFE400U) /**< reserved */
52//#define NEORV32_???_BASE (0xFFFFE500U) /**< reserved */
53//#define NEORV32_???_BASE (0xFFFFE600U) /**< reserved */
54//#define NEORV32_???_BASE (0xFFFFE700U) /**< reserved */
55//#define NEORV32_???_BASE (0xFFFFE800U) /**< reserved */
56//#define NEORV32_???_BASE (0xFFFFE900U) /**< reserved */
57//#define NEORV32_???_BASE (0xFFFFEA00U) /**< reserved */
58#define NEORV32_CFS_BASE (0xFFFFEB00U)
59#define NEORV32_SLINK_BASE (0xFFFFEC00U)
60#define NEORV32_DMA_BASE (0xFFFFED00U)
61#define NEORV32_CRC_BASE (0xFFFFEE00U)
62#define NEORV32_XIP_BASE (0xFFFFEF00U)
63#define NEORV32_PWM_BASE (0xFFFFF000U)
64#define NEORV32_GPTMR_BASE (0xFFFFF100U)
65#define NEORV32_ONEWIRE_BASE (0xFFFFF200U)
66#define NEORV32_XIRQ_BASE (0xFFFFF300U)
67#define NEORV32_MTIME_BASE (0xFFFFF400U)
68#define NEORV32_UART0_BASE (0xFFFFF500U)
69#define NEORV32_UART1_BASE (0xFFFFF600U)
70#define NEORV32_SDI_BASE (0xFFFFF700U)
71#define NEORV32_SPI_BASE (0xFFFFF800U)
72#define NEORV32_TWI_BASE (0xFFFFF900U)
73#define NEORV32_TRNG_BASE (0xFFFFFA00U)
74#define NEORV32_WDT_BASE (0xFFFFFB00U)
75#define NEORV32_GPIO_BASE (0xFFFFFC00U)
76#define NEORV32_NEOLED_BASE (0xFFFFFD00U)
77#define NEORV32_SYSINFO_BASE (0xFFFFFE00U)
78#define NEORV32_DM_BASE (0xFFFFFF00U)
82/**********************************************************************/
88#define TRNG_FIRQ_ENABLE CSR_MIE_FIRQ0E
89#define TRNG_FIRQ_PENDING CSR_MIP_FIRQ0P
90#define TRNG_RTE_ID RTE_TRAP_FIRQ_0
91#define TRNG_TRAP_CODE TRAP_CODE_FIRQ_0
95#define CFS_FIRQ_ENABLE CSR_MIE_FIRQ1E
96#define CFS_FIRQ_PENDING CSR_MIP_FIRQ1P
97#define CFS_RTE_ID RTE_TRAP_FIRQ_1
98#define CFS_TRAP_CODE TRAP_CODE_FIRQ_1
102#define UART0_RX_FIRQ_ENABLE CSR_MIE_FIRQ2E
103#define UART0_RX_FIRQ_PENDING CSR_MIP_FIRQ2P
104#define UART0_RX_RTE_ID RTE_TRAP_FIRQ_2
105#define UART0_RX_TRAP_CODE TRAP_CODE_FIRQ_2
106#define UART0_TX_FIRQ_ENABLE CSR_MIE_FIRQ3E
107#define UART0_TX_FIRQ_PENDING CSR_MIP_FIRQ3P
108#define UART0_TX_RTE_ID RTE_TRAP_FIRQ_3
109#define UART0_TX_TRAP_CODE TRAP_CODE_FIRQ_3
113#define UART1_RX_FIRQ_ENABLE CSR_MIE_FIRQ4E
114#define UART1_RX_FIRQ_PENDING CSR_MIP_FIRQ4P
115#define UART1_RX_RTE_ID RTE_TRAP_FIRQ_4
116#define UART1_RX_TRAP_CODE TRAP_CODE_FIRQ_4
117#define UART1_TX_FIRQ_ENABLE CSR_MIE_FIRQ5E
118#define UART1_TX_FIRQ_PENDING CSR_MIP_FIRQ5P
119#define UART1_TX_RTE_ID RTE_TRAP_FIRQ_5
120#define UART1_TX_TRAP_CODE TRAP_CODE_FIRQ_5
124#define SPI_FIRQ_ENABLE CSR_MIE_FIRQ6E
125#define SPI_FIRQ_PENDING CSR_MIP_FIRQ6P
126#define SPI_RTE_ID RTE_TRAP_FIRQ_6
127#define SPI_TRAP_CODE TRAP_CODE_FIRQ_6
131#define TWI_FIRQ_ENABLE CSR_MIE_FIRQ7E
132#define TWI_FIRQ_PENDING CSR_MIP_FIRQ7P
133#define TWI_RTE_ID RTE_TRAP_FIRQ_7
134#define TWI_TRAP_CODE TRAP_CODE_FIRQ_7
138#define XIRQ_FIRQ_ENABLE CSR_MIE_FIRQ8E
139#define XIRQ_FIRQ_PENDING CSR_MIP_FIRQ8P
140#define XIRQ_RTE_ID RTE_TRAP_FIRQ_8
141#define XIRQ_TRAP_CODE TRAP_CODE_FIRQ_8
145#define NEOLED_FIRQ_ENABLE CSR_MIE_FIRQ9E
146#define NEOLED_FIRQ_PENDING CSR_MIP_FIRQ9P
147#define NEOLED_RTE_ID RTE_TRAP_FIRQ_9
148#define NEOLED_TRAP_CODE TRAP_CODE_FIRQ_9
152#define DMA_FIRQ_ENABLE CSR_MIE_FIRQ10E
153#define DMA_FIRQ_PENDING CSR_MIP_FIRQ10P
154#define DMA_RTE_ID RTE_TRAP_FIRQ_10
155#define DMA_TRAP_CODE TRAP_CODE_FIRQ_10
159#define SDI_FIRQ_ENABLE CSR_MIE_FIRQ11E
160#define SDI_FIRQ_PENDING CSR_MIP_FIRQ11P
161#define SDI_RTE_ID RTE_TRAP_FIRQ_11
162#define SDI_TRAP_CODE TRAP_CODE_FIRQ_11
166#define GPTMR_FIRQ_ENABLE CSR_MIE_FIRQ12E
167#define GPTMR_FIRQ_PENDING CSR_MIP_FIRQ12P
168#define GPTMR_RTE_ID RTE_TRAP_FIRQ_12
169#define GPTMR_TRAP_CODE TRAP_CODE_FIRQ_12
173#define ONEWIRE_FIRQ_ENABLE CSR_MIE_FIRQ13E
174#define ONEWIRE_FIRQ_PENDING CSR_MIP_FIRQ13P
175#define ONEWIRE_RTE_ID RTE_TRAP_FIRQ_13
176#define ONEWIRE_TRAP_CODE TRAP_CODE_FIRQ_13
180#define SLINK_RX_FIRQ_ENABLE CSR_MIE_FIRQ14E
181#define SLINK_RX_FIRQ_PENDING CSR_MIP_FIRQ14P
182#define SLINK_RX_RTE_ID RTE_TRAP_FIRQ_14
183#define SLINK_RX_TRAP_CODE TRAP_CODE_FIRQ_14
184#define SLINK_TX_FIRQ_ENABLE CSR_MIE_FIRQ15E
185#define SLINK_TX_FIRQ_PENDING CSR_MIP_FIRQ15P
186#define SLINK_TX_RTE_ID RTE_TRAP_FIRQ_15
187#define SLINK_TX_TRAP_CODE TRAP_CODE_FIRQ_15
192/**********************************************************************/
196extern char __heap_start[];
197extern char __heap_end[];
198extern char __crt0_max_heap[];
199extern char __crt0_imem_begin[];
200extern char __crt0_dmem_begin[];
201extern char __crt0_stack_end[];
202extern char __crt0_bss_start[];
203extern char __crt0_bss_end[];
204extern char __crt0_copy_data_dst_begin[];
205extern char __crt0_copy_data_dst_end[];
207// aliases
208#define neorv32_heap_begin_c ((uint32_t)&__heap_start[0])
209#define neorv32_heap_end_c ((uint32_t)&__heap_end[0])
210#define neorv32_heap_size_c ((uint32_t)&__crt0_max_heap[0])
211#define neorv32_imem_begin_c ((uint32_t)&__crt0_imem_begin[0])
212#define neorv32_dmem_begin_c ((uint32_t)&__crt0_dmem_begin[0])
213#define neorv32_stack_end_c ((uint32_t)&__crt0_stack_end[0])
214#define neorv32_bss_start_c ((uint32_t)&__crt0_bss_start[0])
215#define neorv32_bss_end_c ((uint32_t)&__crt0_bss_end[0])
216#define neorv32_data_start_c ((uint32_t)&__crt0_copy_data_dst_begin[0])
217#define neorv32_data_end_c ((uint32_t)&__crt0_copy_data_dst_end[0])
221/**********************************************************************/
238/**********************************************************************/
243typedef union {
244 uint64_t uint64;
245 uint32_t uint32[sizeof(uint64_t)/sizeof(uint32_t)];
246 uint16_t uint16[sizeof(uint64_t)/sizeof(uint16_t)];
247 uint8_t uint8[ sizeof(uint64_t)/sizeof(uint8_t)];
250typedef union {
251 uint32_t uint32[sizeof(uint32_t)/sizeof(uint32_t)];
252 uint16_t uint16[sizeof(uint32_t)/sizeof(uint16_t)];
253 uint8_t uint8[ sizeof(uint32_t)/sizeof(uint8_t)];
256typedef union {
257 uint16_t uint16[sizeof(uint16_t)/sizeof(uint16_t)];
258 uint8_t uint8[ sizeof(uint16_t)/sizeof(uint8_t)];
263// ----------------------------------------------------------------------------
264// Include all system header files
265// ----------------------------------------------------------------------------
266// intrinsics
267#include "neorv32_intrinsics.h"
268
269// helper functions
270#include "neorv32_aux.h"
271
272// legacy compatibility layer
273#include "neorv32_legacy.h"
274
275// cpu core
276#include "neorv32_cpu.h"
277#include "neorv32_cpu_amo.h"
278#include "neorv32_cpu_csr.h"
279#include "neorv32_cpu_cfu.h"
280
281// NEORV32 runtime environment
282#include "neorv32_rte.h"
283
284// IO/peripheral devices
285#include "neorv32_cfs.h"
286#include "neorv32_crc.h"
287#include "neorv32_dma.h"
288#include "neorv32_gpio.h"
289#include "neorv32_gptmr.h"
290#include "neorv32_mtime.h"
291#include "neorv32_neoled.h"
292#include "neorv32_onewire.h"
293#include "neorv32_pwm.h"
294#include "neorv32_sdi.h"
295#include "neorv32_slink.h"
296#include "neorv32_spi.h"
297#include "neorv32_sysinfo.h"
298#include "neorv32_trng.h"
299#include "neorv32_twi.h"
300#include "neorv32_uart.h"
301#include "neorv32_wdt.h"
302#include "neorv32_xip.h"
303#include "neorv32_xirq.h"
304
305
306#ifdef __cplusplus
307}
308#endif
309
310#endif // neorv32_h
char __heap_start[]
NEORV32_CLOCK_PRSC_enum
Definition neorv32.h:225
@ CLK_PRSC_4096
Definition neorv32.h:233
@ CLK_PRSC_1024
Definition neorv32.h:231
@ CLK_PRSC_64
Definition neorv32.h:229
@ CLK_PRSC_4
Definition neorv32.h:227
@ CLK_PRSC_128
Definition neorv32.h:230
@ CLK_PRSC_2048
Definition neorv32.h:232
@ CLK_PRSC_8
Definition neorv32.h:228
@ CLK_PRSC_2
Definition neorv32.h:226
char __crt0_bss_start[]
char __crt0_copy_data_dst_begin[]
char __crt0_imem_begin[]
char __crt0_bss_end[]
char __crt0_dmem_begin[]
char __crt0_max_heap[]
char __crt0_stack_end[]
char __crt0_copy_data_dst_end[]
char __heap_end[]
General auxiliary functions header file.
Custom Functions Subsystem (CFS) HW driver header file.
CPU Core Functions HW driver header file.
Atomic memory access (read-modify-write) emulation functions using LR/SC pairs - header file.
CPU Core custom functions unit HW driver header file.
Control and Status Registers (CSR) definitions.
Cyclic redundancy check unit (CRC) HW driver header file.
Direct Memory Access Controller (DMA) HW driver header file.
General purpose input/output port unit (GPIO) HW driver header file.
General purpose timer (GPTMR) HW driver header file.
Helper functions and macros for custom "intrinsics" / instructions.
Legacy compatibility layer.
Machine System Timer (MTIME) HW driver header file.
Smart LED Interface (NEOLED) HW driver header file.
1-Wire Interface Controller (ONEWIRE) HW driver header file.
Pulse-Width Modulation Controller (PWM) HW driver header file.
NEORV32 Runtime Environment.
Serial data interface controller (SPPI) HW driver header file.
Serial peripheral interface controller (SPI) HW driver header file.
True Random Number Generator (TRNG) HW driver header file.
Two-Wire Interface Controller (TWI) HW driver header file.
Universal asynchronous receiver/transmitter (UART0/UART1) HW driver header file.
Watchdog Timer (WDT) HW driver header file.
Execute in place module (XIP) HW driver header file.
External Interrupt controller HW driver header file.
Definition neorv32.h:256
Definition neorv32.h:250
Definition neorv32.h:243