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 IO_BASE_ADDRESS (0XFFE00000U)
41/**********************************************************************/
45#define NEORV32_BOOTROM_BASE (0xFFE00000U)
46//#define NEORV32_???_BASE (0xFFE10000U) /**< reserved */
47//#define NEORV32_???_BASE (0xFFE20000U) /**< reserved */
48//#define NEORV32_???_BASE (0xFFE30000U) /**< reserved */
49//#define NEORV32_???_BASE (0xFFE40000U) /**< reserved */
50//#define NEORV32_???_BASE (0xFFE50000U) /**< reserved */
51//#define NEORV32_???_BASE (0xFFE60000U) /**< reserved */
52//#define NEORV32_???_BASE (0xFFE70000U) /**< reserved */
53//#define NEORV32_???_BASE (0xFFE80000U) /**< reserved */
54//#define NEORV32_???_BASE (0xFFE90000U) /**< reserved */
55#define NEORV32_TWD_BASE (0xFFEA0000U)
56#define NEORV32_CFS_BASE (0xFFEB0000U)
57#define NEORV32_SLINK_BASE (0xFFEC0000U)
58#define NEORV32_DMA_BASE (0xFFED0000U)
59#define NEORV32_CRC_BASE (0xFFEE0000U)
60#define NEORV32_XIP_BASE (0xFFEF0000U)
61#define NEORV32_PWM_BASE (0xFFF00000U)
62#define NEORV32_GPTMR_BASE (0xFFF10000U)
63#define NEORV32_ONEWIRE_BASE (0xFFF20000U)
64#define NEORV32_XIRQ_BASE (0xFFF30000U)
65#define NEORV32_MTIME_BASE (0xFFF40000U)
66#define NEORV32_UART0_BASE (0xFFF50000U)
67#define NEORV32_UART1_BASE (0xFFF60000U)
68#define NEORV32_SDI_BASE (0xFFF70000U)
69#define NEORV32_SPI_BASE (0xFFF80000U)
70#define NEORV32_TWI_BASE (0xFFF90000U)
71#define NEORV32_TRNG_BASE (0xFFFA0000U)
72#define NEORV32_WDT_BASE (0xFFFB0000U)
73#define NEORV32_GPIO_BASE (0xFFFC0000U)
74#define NEORV32_NEOLED_BASE (0xFFFD0000U)
75#define NEORV32_SYSINFO_BASE (0xFFFE0000U)
76#define NEORV32_DM_BASE (0xFFFF0000U)
80/**********************************************************************/
86#define TWD_FIRQ_ENABLE CSR_MIE_FIRQ0E
87#define TWD_FIRQ_PENDING CSR_MIP_FIRQ0P
88#define TWD_RTE_ID RTE_TRAP_FIRQ_0
89#define TWD_TRAP_CODE TRAP_CODE_FIRQ_0
93#define CFS_FIRQ_ENABLE CSR_MIE_FIRQ1E
94#define CFS_FIRQ_PENDING CSR_MIP_FIRQ1P
95#define CFS_RTE_ID RTE_TRAP_FIRQ_1
96#define CFS_TRAP_CODE TRAP_CODE_FIRQ_1
100#define UART0_RX_FIRQ_ENABLE CSR_MIE_FIRQ2E
101#define UART0_RX_FIRQ_PENDING CSR_MIP_FIRQ2P
102#define UART0_RX_RTE_ID RTE_TRAP_FIRQ_2
103#define UART0_RX_TRAP_CODE TRAP_CODE_FIRQ_2
104#define UART0_TX_FIRQ_ENABLE CSR_MIE_FIRQ3E
105#define UART0_TX_FIRQ_PENDING CSR_MIP_FIRQ3P
106#define UART0_TX_RTE_ID RTE_TRAP_FIRQ_3
107#define UART0_TX_TRAP_CODE TRAP_CODE_FIRQ_3
111#define UART1_RX_FIRQ_ENABLE CSR_MIE_FIRQ4E
112#define UART1_RX_FIRQ_PENDING CSR_MIP_FIRQ4P
113#define UART1_RX_RTE_ID RTE_TRAP_FIRQ_4
114#define UART1_RX_TRAP_CODE TRAP_CODE_FIRQ_4
115#define UART1_TX_FIRQ_ENABLE CSR_MIE_FIRQ5E
116#define UART1_TX_FIRQ_PENDING CSR_MIP_FIRQ5P
117#define UART1_TX_RTE_ID RTE_TRAP_FIRQ_5
118#define UART1_TX_TRAP_CODE TRAP_CODE_FIRQ_5
122#define SPI_FIRQ_ENABLE CSR_MIE_FIRQ6E
123#define SPI_FIRQ_PENDING CSR_MIP_FIRQ6P
124#define SPI_RTE_ID RTE_TRAP_FIRQ_6
125#define SPI_TRAP_CODE TRAP_CODE_FIRQ_6
129#define TWI_FIRQ_ENABLE CSR_MIE_FIRQ7E
130#define TWI_FIRQ_PENDING CSR_MIP_FIRQ7P
131#define TWI_RTE_ID RTE_TRAP_FIRQ_7
132#define TWI_TRAP_CODE TRAP_CODE_FIRQ_7
136#define XIRQ_FIRQ_ENABLE CSR_MIE_FIRQ8E
137#define XIRQ_FIRQ_PENDING CSR_MIP_FIRQ8P
138#define XIRQ_RTE_ID RTE_TRAP_FIRQ_8
139#define XIRQ_TRAP_CODE TRAP_CODE_FIRQ_8
143#define NEOLED_FIRQ_ENABLE CSR_MIE_FIRQ9E
144#define NEOLED_FIRQ_PENDING CSR_MIP_FIRQ9P
145#define NEOLED_RTE_ID RTE_TRAP_FIRQ_9
146#define NEOLED_TRAP_CODE TRAP_CODE_FIRQ_9
150#define DMA_FIRQ_ENABLE CSR_MIE_FIRQ10E
151#define DMA_FIRQ_PENDING CSR_MIP_FIRQ10P
152#define DMA_RTE_ID RTE_TRAP_FIRQ_10
153#define DMA_TRAP_CODE TRAP_CODE_FIRQ_10
157#define SDI_FIRQ_ENABLE CSR_MIE_FIRQ11E
158#define SDI_FIRQ_PENDING CSR_MIP_FIRQ11P
159#define SDI_RTE_ID RTE_TRAP_FIRQ_11
160#define SDI_TRAP_CODE TRAP_CODE_FIRQ_11
164#define GPTMR_FIRQ_ENABLE CSR_MIE_FIRQ12E
165#define GPTMR_FIRQ_PENDING CSR_MIP_FIRQ12P
166#define GPTMR_RTE_ID RTE_TRAP_FIRQ_12
167#define GPTMR_TRAP_CODE TRAP_CODE_FIRQ_12
171#define ONEWIRE_FIRQ_ENABLE CSR_MIE_FIRQ13E
172#define ONEWIRE_FIRQ_PENDING CSR_MIP_FIRQ13P
173#define ONEWIRE_RTE_ID RTE_TRAP_FIRQ_13
174#define ONEWIRE_TRAP_CODE TRAP_CODE_FIRQ_13
178#define SLINK_RX_FIRQ_ENABLE CSR_MIE_FIRQ14E
179#define SLINK_RX_FIRQ_PENDING CSR_MIP_FIRQ14P
180#define SLINK_RX_RTE_ID RTE_TRAP_FIRQ_14
181#define SLINK_RX_TRAP_CODE TRAP_CODE_FIRQ_14
182#define SLINK_TX_FIRQ_ENABLE CSR_MIE_FIRQ15E
183#define SLINK_TX_FIRQ_PENDING CSR_MIP_FIRQ15P
184#define SLINK_TX_RTE_ID RTE_TRAP_FIRQ_15
185#define SLINK_TX_TRAP_CODE TRAP_CODE_FIRQ_15
190/**********************************************************************/
194extern char __heap_start[];
195extern char __heap_end[];
196extern char __crt0_max_heap[];
197// aliases
198#define neorv32_heap_begin_c ((uint32_t)&__heap_start[0])
199#define neorv32_heap_end_c ((uint32_t)&__heap_end[0])
200#define neorv32_heap_size_c ((uint32_t)&__crt0_max_heap[0])
204/**********************************************************************/
221/**********************************************************************/
226typedef union {
227 uint64_t uint64;
228 uint32_t uint32[sizeof(uint64_t)/sizeof(uint32_t)];
229 uint16_t uint16[sizeof(uint64_t)/sizeof(uint16_t)];
230 uint8_t uint8[ sizeof(uint64_t)/sizeof(uint8_t)];
233typedef union {
234 uint32_t uint32[sizeof(uint32_t)/sizeof(uint32_t)];
235 uint16_t uint16[sizeof(uint32_t)/sizeof(uint16_t)];
236 uint8_t uint8[ sizeof(uint32_t)/sizeof(uint8_t)];
239typedef union {
240 uint16_t uint16[sizeof(uint16_t)/sizeof(uint16_t)];
241 uint8_t uint8[ sizeof(uint16_t)/sizeof(uint8_t)];
246// ----------------------------------------------------------------------------
247// Include all system header files
248// ----------------------------------------------------------------------------
249// intrinsics
250#include "neorv32_intrinsics.h"
251
252// helper functions
253#include "neorv32_aux.h"
254
255// legacy compatibility layer
256#include "neorv32_legacy.h"
257
258// cpu core
259#include "neorv32_cpu.h"
260#include "neorv32_cpu_amo.h"
261#include "neorv32_cpu_csr.h"
262#include "neorv32_cpu_cfu.h"
263
264// NEORV32 runtime environment
265#include "neorv32_rte.h"
266
267// IO/peripheral devices
268#include "neorv32_cfs.h"
269#include "neorv32_crc.h"
270#include "neorv32_dma.h"
271#include "neorv32_gpio.h"
272#include "neorv32_gptmr.h"
273#include "neorv32_mtime.h"
274#include "neorv32_neoled.h"
275#include "neorv32_onewire.h"
276#include "neorv32_pwm.h"
277#include "neorv32_sdi.h"
278#include "neorv32_slink.h"
279#include "neorv32_spi.h"
280#include "neorv32_sysinfo.h"
281#include "neorv32_trng.h"
282#include "neorv32_twd.h"
283#include "neorv32_twi.h"
284#include "neorv32_uart.h"
285#include "neorv32_wdt.h"
286#include "neorv32_xip.h"
287#include "neorv32_xirq.h"
288
289
290#ifdef __cplusplus
291}
292#endif
293
294#endif // neorv32_h
char __heap_start[]
NEORV32_CLOCK_PRSC_enum
Definition neorv32.h:208
@ CLK_PRSC_4096
Definition neorv32.h:216
@ CLK_PRSC_1024
Definition neorv32.h:214
@ CLK_PRSC_64
Definition neorv32.h:212
@ CLK_PRSC_4
Definition neorv32.h:210
@ CLK_PRSC_128
Definition neorv32.h:213
@ CLK_PRSC_2048
Definition neorv32.h:215
@ CLK_PRSC_8
Definition neorv32.h:211
@ CLK_PRSC_2
Definition neorv32.h:209
char __crt0_max_heap[]
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 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.
System Information Memory (SYSINFO) HW driver header file.
True Random Number Generator (TRNG) HW driver header file.
Two-Wire Device Controller (TWD) 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:239
Definition neorv32.h:233
Definition neorv32.h:226