NEORV32 - Software Framework Documentation
Loading...
Searching...
No Matches
neorv32.h
Go to the documentation of this file.
1// #################################################################################################
2// # << NEORV32: neorv32.h - Main Core Library / HAL Include File >> #
3// # ********************************************************************************************* #
4// # BSD 3-Clause License #
5// # #
6// # Copyright (c) 2024, Stephan Nolting. All rights reserved. #
7// # #
8// # Redistribution and use in source and binary forms, with or without modification, are #
9// # permitted provided that the following conditions are met: #
10// # #
11// # 1. Redistributions of source code must retain the above copyright notice, this list of #
12// # conditions and the following disclaimer. #
13// # #
14// # 2. Redistributions in binary form must reproduce the above copyright notice, this list of #
15// # conditions and the following disclaimer in the documentation and/or other materials #
16// # provided with the distribution. #
17// # #
18// # 3. Neither the name of the copyright holder nor the names of its contributors may be used to #
19// # endorse or promote products derived from this software without specific prior written #
20// # permission. #
21// # #
22// # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS #
23// # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF #
24// # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE #
25// # COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, #
26// # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
27// # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED #
28// # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING #
29// # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED #
30// # OF THE POSSIBILITY OF SUCH DAMAGE. #
31// # ********************************************************************************************* #
32// # The NEORV32 Processor - https://github.com/stnolting/neorv32 (c) Stephan Nolting #
33// #################################################################################################
34
35
36/**********************************************************************/
43#ifndef neorv32_h
44#define neorv32_h
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
50// Standard libraries
51#include <stdint.h>
52#include <inttypes.h>
53#include <limits.h>
54#include <unistd.h>
55#include <stdlib.h>
56
57
58/**********************************************************************/
71
72
73/**********************************************************************/
79#define CFS_FIRQ_ENABLE CSR_MIE_FIRQ1E
80#define CFS_FIRQ_PENDING CSR_MIP_FIRQ1P
81#define CFS_RTE_ID RTE_TRAP_FIRQ_1
82#define CFS_TRAP_CODE TRAP_CODE_FIRQ_1
86#define UART0_RX_FIRQ_ENABLE CSR_MIE_FIRQ2E
87#define UART0_RX_FIRQ_PENDING CSR_MIP_FIRQ2P
88#define UART0_RX_RTE_ID RTE_TRAP_FIRQ_2
89#define UART0_RX_TRAP_CODE TRAP_CODE_FIRQ_2
90#define UART0_TX_FIRQ_ENABLE CSR_MIE_FIRQ3E
91#define UART0_TX_FIRQ_PENDING CSR_MIP_FIRQ3P
92#define UART0_TX_RTE_ID RTE_TRAP_FIRQ_3
93#define UART0_TX_TRAP_CODE TRAP_CODE_FIRQ_3
97#define UART1_RX_FIRQ_ENABLE CSR_MIE_FIRQ4E
98#define UART1_RX_FIRQ_PENDING CSR_MIP_FIRQ4P
99#define UART1_RX_RTE_ID RTE_TRAP_FIRQ_4
100#define UART1_RX_TRAP_CODE TRAP_CODE_FIRQ_4
101#define UART1_TX_FIRQ_ENABLE CSR_MIE_FIRQ5E
102#define UART1_TX_FIRQ_PENDING CSR_MIP_FIRQ5P
103#define UART1_TX_RTE_ID RTE_TRAP_FIRQ_5
104#define UART1_TX_TRAP_CODE TRAP_CODE_FIRQ_5
108#define SPI_FIRQ_ENABLE CSR_MIE_FIRQ6E
109#define SPI_FIRQ_PENDING CSR_MIP_FIRQ6P
110#define SPI_RTE_ID RTE_TRAP_FIRQ_6
111#define SPI_TRAP_CODE TRAP_CODE_FIRQ_6
115#define TWI_FIRQ_ENABLE CSR_MIE_FIRQ7E
116#define TWI_FIRQ_PENDING CSR_MIP_FIRQ7P
117#define TWI_RTE_ID RTE_TRAP_FIRQ_7
118#define TWI_TRAP_CODE TRAP_CODE_FIRQ_7
122#define XIRQ_FIRQ_ENABLE CSR_MIE_FIRQ8E
123#define XIRQ_FIRQ_PENDING CSR_MIP_FIRQ8P
124#define XIRQ_RTE_ID RTE_TRAP_FIRQ_8
125#define XIRQ_TRAP_CODE TRAP_CODE_FIRQ_8
129#define NEOLED_FIRQ_ENABLE CSR_MIE_FIRQ9E
130#define NEOLED_FIRQ_PENDING CSR_MIP_FIRQ9P
131#define NEOLED_RTE_ID RTE_TRAP_FIRQ_9
132#define NEOLED_TRAP_CODE TRAP_CODE_FIRQ_9
136#define DMA_FIRQ_ENABLE CSR_MIE_FIRQ10E
137#define DMA_FIRQ_PENDING CSR_MIP_FIRQ10P
138#define DMA_RTE_ID RTE_TRAP_FIRQ_10
139#define DMA_TRAP_CODE TRAP_CODE_FIRQ_10
143#define SDI_FIRQ_ENABLE CSR_MIE_FIRQ11E
144#define SDI_FIRQ_PENDING CSR_MIP_FIRQ11P
145#define SDI_RTE_ID RTE_TRAP_FIRQ_11
146#define SDI_TRAP_CODE TRAP_CODE_FIRQ_11
150#define GPTMR_FIRQ_ENABLE CSR_MIE_FIRQ12E
151#define GPTMR_FIRQ_PENDING CSR_MIP_FIRQ12P
152#define GPTMR_RTE_ID RTE_TRAP_FIRQ_12
153#define GPTMR_TRAP_CODE TRAP_CODE_FIRQ_12
157#define ONEWIRE_FIRQ_ENABLE CSR_MIE_FIRQ13E
158#define ONEWIRE_FIRQ_PENDING CSR_MIP_FIRQ13P
159#define ONEWIRE_RTE_ID RTE_TRAP_FIRQ_13
160#define ONEWIRE_TRAP_CODE TRAP_CODE_FIRQ_13
164#define SLINK_RX_FIRQ_ENABLE CSR_MIE_FIRQ14E
165#define SLINK_RX_FIRQ_PENDING CSR_MIP_FIRQ14P
166#define SLINK_RX_RTE_ID RTE_TRAP_FIRQ_14
167#define SLINK_RX_TRAP_CODE TRAP_CODE_FIRQ_14
168#define SLINK_TX_FIRQ_ENABLE CSR_MIE_FIRQ15E
169#define SLINK_TX_FIRQ_PENDING CSR_MIP_FIRQ15P
170#define SLINK_TX_RTE_ID RTE_TRAP_FIRQ_15
171#define SLINK_TX_TRAP_CODE TRAP_CODE_FIRQ_15
176/**********************************************************************/
181#define XIP_MEM_BASE_ADDRESS (0xE0000000U)
183#define BOOTLOADER_BASE_ADDRESS (0xFFFFC000U)
185#define IO_BASE_ADDRESS (0xFFFFE000U)
189/**********************************************************************/
193#define NEORV32_CFS_BASE (0xFFFFEB00U)
194#define NEORV32_SLINK_BASE (0xFFFFEC00U)
195#define NEORV32_DMA_BASE (0xFFFFED00U)
196#define NEORV32_CRC_BASE (0xFFFFEE00U)
197#define NEORV32_XIP_BASE (0xFFFFEF00U)
198#define NEORV32_PWM_BASE (0xFFFFF000U)
199#define NEORV32_GPTMR_BASE (0xFFFFF100U)
200#define NEORV32_ONEWIRE_BASE (0xFFFFF200U)
201#define NEORV32_XIRQ_BASE (0xFFFFF300U)
202#define NEORV32_MTIME_BASE (0xFFFFF400U)
203#define NEORV32_UART0_BASE (0xFFFFF500U)
204#define NEORV32_UART1_BASE (0xFFFFF600U)
205#define NEORV32_SDI_BASE (0xFFFFF700U)
206#define NEORV32_SPI_BASE (0xFFFFF800U)
207#define NEORV32_TWI_BASE (0xFFFFF900U)
208#define NEORV32_TRNG_BASE (0xFFFFFA00U)
209#define NEORV32_WDT_BASE (0xFFFFFB00U)
210#define NEORV32_GPIO_BASE (0xFFFFFC00U)
211#define NEORV32_NEOLED_BASE (0xFFFFFD00U)
212#define NEORV32_SYSINFO_BASE (0xFFFFFE00U)
213#define NEORV32_DM_BASE (0xFFFFFF00U)
217// ----------------------------------------------------------------------------
218// Include all system header files
219// ----------------------------------------------------------------------------
220// intrinsics
221#include "neorv32_intrinsics.h"
222
223// cpu core
224#include "neorv32_cpu.h"
225#include "neorv32_cpu_amo.h"
226#include "neorv32_cpu_csr.h"
227#include "neorv32_cpu_cfu.h"
228
229// NEORV32 runtime environment
230#include "neorv32_rte.h"
231
232// IO/peripheral devices
233#include "neorv32_cfs.h"
234#include "neorv32_crc.h"
235#include "neorv32_dm.h"
236#include "neorv32_dma.h"
237#include "neorv32_gpio.h"
238#include "neorv32_gptmr.h"
239#include "neorv32_mtime.h"
240#include "neorv32_neoled.h"
241#include "neorv32_onewire.h"
242#include "neorv32_pwm.h"
243#include "neorv32_sdi.h"
244#include "neorv32_slink.h"
245#include "neorv32_spi.h"
246#include "neorv32_sysinfo.h"
247#include "neorv32_trng.h"
248#include "neorv32_twi.h"
249#include "neorv32_uart.h"
250#include "neorv32_wdt.h"
251#include "neorv32_xip.h"
252#include "neorv32_xirq.h"
253
254// backwards compatibility layer
255#include "legacy.h"
256
257#ifdef __cplusplus
258}
259#endif
260
261#endif // neorv32_h
Wrappers and functions for backwards compatibility.
NEORV32_CLOCK_PRSC_enum
Definition neorv32.h:61
@ CLK_PRSC_4096
Definition neorv32.h:69
@ CLK_PRSC_1024
Definition neorv32.h:67
@ CLK_PRSC_64
Definition neorv32.h:65
@ CLK_PRSC_4
Definition neorv32.h:63
@ CLK_PRSC_128
Definition neorv32.h:66
@ CLK_PRSC_2048
Definition neorv32.h:68
@ CLK_PRSC_8
Definition neorv32.h:64
@ CLK_PRSC_2
Definition neorv32.h:62
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.
On-Chip Debugger (CANNOT be accessed by application software!)
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.
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.