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[];
199// aliases
200#define neorv32_heap_begin_c ((uint32_t)&__heap_start[0])
201#define neorv32_heap_end_c ((uint32_t)&__heap_end[0])
202#define neorv32_heap_size_c ((uint32_t)&__crt0_max_heap[0])
206/**********************************************************************/
223/**********************************************************************/
228typedef union {
229 uint64_t uint64;
230 uint32_t uint32[sizeof(uint64_t)/sizeof(uint32_t)];
231 uint16_t uint16[sizeof(uint64_t)/sizeof(uint16_t)];
232 uint8_t uint8[ sizeof(uint64_t)/sizeof(uint8_t)];
235typedef union {
236 uint32_t uint32[sizeof(uint32_t)/sizeof(uint32_t)];
237 uint16_t uint16[sizeof(uint32_t)/sizeof(uint16_t)];
238 uint8_t uint8[ sizeof(uint32_t)/sizeof(uint8_t)];
241typedef union {
242 uint16_t uint16[sizeof(uint16_t)/sizeof(uint16_t)];
243 uint8_t uint8[ sizeof(uint16_t)/sizeof(uint8_t)];
248// ----------------------------------------------------------------------------
249// Include all system header files
250// ----------------------------------------------------------------------------
251// intrinsics
252#include "neorv32_intrinsics.h"
253
254// helper functions
255#include "neorv32_aux.h"
256
257// legacy compatibility layer
258#include "neorv32_legacy.h"
259
260// cpu core
261#include "neorv32_cpu.h"
262#include "neorv32_cpu_amo.h"
263#include "neorv32_cpu_csr.h"
264#include "neorv32_cpu_cfu.h"
265
266// NEORV32 runtime environment
267#include "neorv32_rte.h"
268
269// IO/peripheral devices
270#include "neorv32_cfs.h"
271#include "neorv32_crc.h"
272#include "neorv32_dma.h"
273#include "neorv32_gpio.h"
274#include "neorv32_gptmr.h"
275#include "neorv32_mtime.h"
276#include "neorv32_neoled.h"
277#include "neorv32_onewire.h"
278#include "neorv32_pwm.h"
279#include "neorv32_sdi.h"
280#include "neorv32_slink.h"
281#include "neorv32_spi.h"
282#include "neorv32_sysinfo.h"
283#include "neorv32_trng.h"
284#include "neorv32_twi.h"
285#include "neorv32_uart.h"
286#include "neorv32_wdt.h"
287#include "neorv32_xip.h"
288#include "neorv32_xirq.h"
289
290
291#ifdef __cplusplus
292}
293#endif
294
295#endif // neorv32_h
char __heap_start[]
NEORV32_CLOCK_PRSC_enum
Definition neorv32.h:210
@ CLK_PRSC_4096
Definition neorv32.h:218
@ CLK_PRSC_1024
Definition neorv32.h:216
@ CLK_PRSC_64
Definition neorv32.h:214
@ CLK_PRSC_4
Definition neorv32.h:212
@ CLK_PRSC_128
Definition neorv32.h:215
@ CLK_PRSC_2048
Definition neorv32.h:217
@ CLK_PRSC_8
Definition neorv32.h:213
@ CLK_PRSC_2
Definition neorv32.h:211
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 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:241
Definition neorv32.h:235
Definition neorv32.h:228