2 ** ###################################################################
3 ** Processors: RV32M1_ri5cy
6 ** Compilers: Keil ARM C/C++ Compiler
8 ** IAR ANSI C/C++ Compiler for ARM
11 ** Reference manual: RV32M1 Series Reference Manual, Rev. 1 , 8/10/2018
12 ** Version: rev. 1.0, 2018-10-02
16 ** Provides a system configuration function and a global variable that
17 ** contains the system frequency. It configures the device and initializes
18 ** the oscillator (PLL) that is part of the microcontroller device.
20 ** Copyright 2016 Freescale Semiconductor, Inc.
21 ** Copyright 2016-2018 NXP
22 ** All rights reserved.
24 ** SPDX-License-Identifier: BSD-3-Clause
27 ** mail: support@nxp.com
30 ** - rev. 1.0 (2018-10-02)
33 ** ###################################################################
40 * @brief Device specific configuration file for RV32M1_ri5cy (header file)
42 * Provides a system configuration function and a global variable that contains
43 * the system frequency. It configures the device and initializes the oscillator
44 * (PLL) that is part of the microcontroller device.
47 #ifndef _SYSTEM_RV32M1_ri5cy_H_
48 #define _SYSTEM_RV32M1_ri5cy_H_ /**< Symbol preventing repeated inclusion */
59 #define DISABLE_WDOG 1
62 /* Define clock source values */
63 #define CPU_XTAL_CLK_HZ 8000000u /* Value of the external crystal or oscillator clock frequency in Hz */
65 /* Low power mode enable */
66 /* SMC_PMPROT: AHSRUN=1, AVLP=1,ALLS=1,AVLLS=0x3 */
67 #define SYSTEM_SMC_PMPROT_VALUE 0xABu /* SMC_PMPROT */
68 #define SYSTEM_SMC_PMCTRL_VALUE 0x0u /* SMC_PMCTRL */
70 #define DEFAULT_SYSTEM_CLOCK 48000000u /* Default System clock value */
75 * @brief System clock frequency (core clock)
77 * The system clock frequency supplied to the SysTick timer and the processor
78 * core clock. This variable can be used by the user application to setup the
79 * SysTick timer or configure other parameters. It may also be used by debugger to
80 * query the frequency of the debug timer or configure the trace clock speed
81 * SystemCoreClock is initialized with a correct predefined value.
83 extern uint32_t SystemCoreClock;
86 * @brief Setup the microcontroller system.
88 * Typically this function configures the oscillator (PLL) that is part of the
89 * microcontroller device. For systems with variable clock speed it also updates
90 * the variable SystemCoreClock. SystemInit is called from startup_device file.
92 void SystemInit (void);
95 * @brief Updates the SystemCoreClock variable.
97 * It must be called whenever the core clock is changed during program
98 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
99 * the current core clock.
101 void SystemCoreClockUpdate (void);
104 * @brief SystemInit function hook.
106 * This weak function allows to call specific initialization code during the
107 * SystemInit() execution.This can be used when an application specific code needs
108 * to be called as close to the reset entry as possible (for example the Multicore
109 * Manager MCMGR_EarlyInit() function call).
110 * NOTE: No global r/w variables can be used in this hook function because the
111 * initialization of these variables happens after this function.
113 void SystemInitHook (void);
116 * @brief System IRQ handler which dispatches specific IRQ to corresponding registered handler.
118 * It is called from IRQ exception context and dispatches to registered handler according to
119 * MCAUSE interrupt number.
121 * @param mcause IRQ acknowledge value read from MCAUSE
123 void SystemIrqHandler(uint32_t mcause);
126 * @brief Get IRQ nesting level of current context.
128 * If the return value is 0, then the context is not ISR, otherwise the context is ISR.
130 * @return IRQ nesting level
132 uint32_t SystemGetIRQNestingLevel (void);
135 * @brief Setup systick for RTOS system.
137 * @param tickRateHz Tick number per second
138 * @param intPriority IRQ interrupt priority (the smaller, the higher priority)
140 void SystemSetupSystick (uint32_t tickRateHz, uint32_t intPriority);
143 * @brief Clear systick flag status so that next tick interrupt may occur.
145 void SystemClearSystickFlag (void);
148 * @brief Sysem is in ISR or not.
150 bool SystemInISR(void);
152 #define SysTick_Handler LPIT0_IRQHandler
155 * @brief Set interrupt priority in Event unit.
157 void EVENT_SetIRQPriority(IRQn_Type IRQn, uint8_t intPriority);
160 * @brief Get interrupt priority in Event unit.
162 uint8_t EVENT_GetIRQPriority(IRQn_Type IRQn);
165 * @brief Reset the system.
167 void EVENT_SystemReset(void);
169 #define NVIC_SystemReset EVENT_SystemReset
171 /* Priority setting macro remap. */
172 #define NVIC_SetPriority EVENT_SetIRQPriority
174 /* Priority getting macro remap. */
175 #define NVIC_GetPriority EVENT_GetIRQPriority
182 #endif /* _SYSTEM_RV32M1_ri5cy_H_ */