G32R430 Device Driver Layer v1.0.4
G32R4xx Device Driver Layer API Reference
g32r4xx_ddl_nvic.c
Go to the documentation of this file.
1
42
43#if defined(USE_FULL_DDL_DRIVER)
44
45/* Includes ------------------------------------------------------------------*/
46#include "g32r4xx_ddl_nvic.h"
47#include "g32r4xx_ddl_rcm.h"
48#ifdef USE_FULL_ASSERT
49#include "g32_assert.h"
50#else
51#define ASSERT_PARAM(_PARAM_) ((void)0U)
52#endif
53
57
61
65
66#define DDL_AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
67#define DDL_VECTOR_SIZE 39
71
72/* Private function prototypes -----------------------------------------------*/
73
74/* Exported functions --------------------------------------------------------*/
75
79
83
95void DDL_NVIC_ConfigPriorityGroup(uint32_t priorityGroup)
96{
97 SCB->AIRCR = DDL_AIRCR_VECTKEY_MASK | priorityGroup;
98}
99
112void DDL_NVIC_EnableIRQRequest(IRQn_Type irq, uint8_t preemptionPriority, uint8_t subPriority)
113{
114 uint32_t tempPriority, tempPrePri, tempSubPri;
115 uint32_t priorityGrp;
116
117 /* Get priority group */
118 priorityGrp = (SCB->AIRCR) & (uint32_t)0x700U;
119
120 /* get pre-emption priority and subpriority */
121 switch(priorityGrp)
122 {
124 tempPrePri = 0;
125 tempSubPri = 4;
126 break;
127
129 tempPrePri = 1;
130 tempSubPri = 3;
131 break;
132
134 tempPrePri = 2;
135 tempSubPri = 2;
136 break;
137
139 tempPrePri = 3;
140 tempSubPri = 1;
141 break;
142
144 tempPrePri = 4;
145 tempSubPri = 0;
146 break;
147
148 default:
150 tempPrePri = 0;
151 tempSubPri = 4;
152 break;
153 }
154
155 tempPrePri = 4 - tempPrePri;
156 tempSubPri = 4 - tempSubPri;
157 tempPriority = preemptionPriority << tempPrePri;
158 tempPriority |= subPriority & (0x0f >> tempSubPri);
159 tempPriority <<= 4;
160 NVIC->IPR[irq] = (uint8_t)tempPriority;
161
162 /* enable the selected IRQ */
163 NVIC->ISER[irq >> 0x05U] = (uint32_t)0x01U << (irq & (uint8_t)0x1FU);
164}
165
173void DDL_NVIC_DisableIRQRequest(IRQn_Type irq)
174{
175 /* disable the selected IRQ.*/
176 NVIC->ICER[irq >> 0x05U] = (uint32_t)0x01U << (irq & (uint8_t)0x1FU);
177}
178
191void DDL_NVIC_ConfigVectorTable(uint32_t vectTab, uint32_t offset)
192{
193 SCB->VTOR = vectTab | (offset & (uint32_t)0x1FFFFF80);
194}
195
206void DDL_SysTick_ConfigCLKSource(uint32_t clkSource)
207{
208 if (clkSource == DDL_SYSTICK_CLK_SOURCE_HCLK)
209 {
210 SysTick->CTRL |= (uint32_t)BIT2;
211 }
212 else
213 {
214 SysTick->CTRL &= (uint32_t)(~BIT2);
215 }
216}
217
218#ifdef VECT_TAB_SRAM
232ErrorStatus DDL_Interrupt_Register(IRQn_Type irqn, Interrupt_Handler new_handler)
233{
234 uint32_t *vectors = (uint32_t *)SCB->VTOR;
235 uint32_t vtor_addr = (uint32_t)SCB->VTOR;
236
237 /* IRQ range check */
238 if (irqn < -15 || irqn >= DDL_VECTOR_SIZE)
239 {
240 return ERROR;
241 }
242
243 /* VTOR region check */
244 if (!((vtor_addr >= 0x20000000u && vtor_addr <= 0x20003FFFu) ||
245 (vtor_addr <= 0x00007FFFu)))
246 {
247 return ERROR;
248 }
249
250 vectors[irqn+16] = (uint32_t)new_handler;
251 __DSB();
252
253 return SUCCESS;
254}
255
256#endif
257
261
265
269
273
274#endif
G32 assert template file. This file should be copied to the application folder and renamed to g32_ass...
Header file of I2C DDL module.
Header file of RCM DDL module.
#define DDL_NVIC_PRIORITY_GROUP_4
#define DDL_NVIC_PRIORITY_GROUP_2
#define DDL_NVIC_PRIORITY_GROUP_0
#define DDL_NVIC_PRIORITY_GROUP_1
#define DDL_NVIC_PRIORITY_GROUP_3
#define DDL_SYSTICK_CLK_SOURCE_HCLK
void DDL_NVIC_ConfigVectorTable(uint32_t vectTab, uint32_t offset)
Configs the vector table location and Offset.
void DDL_NVIC_DisableIRQRequest(IRQn_Type irq)
Disable NVIC request.
void DDL_SysTick_ConfigCLKSource(uint32_t clkSource)
Configures the SysTick clock source.
void DDL_NVIC_ConfigPriorityGroup(uint32_t priorityGroup)
Configures the priority grouping: pre-emption priority and subpriority.
void DDL_NVIC_EnableIRQRequest(IRQn_Type irq, uint8_t preemptionPriority, uint8_t subPriority)
Enable NVIC request.
ErrorStatus DDL_Interrupt_Register(IRQn_Type irqn, Interrupt_Handler new_handler)
User-defined interrupt service function.
void(* Interrupt_Handler)(void)
#define DDL_VECTOR_SIZE
#define DDL_AIRCR_VECTKEY_MASK