File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,28 @@ IRQManager& IRQManager::getInstance() {
3838 return instance;
3939}
4040
41+ bool IRQManager::addGenericInterrupt (GenericIrqCfg_t &cfg, Irq_f fnc /* = nullptr*/ ){
42+ /* getting the address of the current location of the irq vector table */
43+ volatile uint32_t *irq_ptr = (volatile uint32_t *)SCB->VTOR ;
44+ /* set the displacement to the "programmable" part of the table */
45+ irq_ptr += FIXED_IRQ_NUM;
46+ bool rv = false ;
47+
48+ if (cfg.irq == FSP_INVALID_VECTOR) {
49+ if (fnc != nullptr ){
50+ R_ICU->IELSR [last_interrupt_index] = cfg.event ;
51+ *(irq_ptr + last_interrupt_index) = (uint32_t )fnc;
52+ R_BSP_IrqDisable ((IRQn_Type)last_interrupt_index);
53+ R_BSP_IrqStatusClear ((IRQn_Type)last_interrupt_index);
54+ NVIC_SetPriority ((IRQn_Type)last_interrupt_index, cfg.ipl );
55+ R_BSP_IrqEnable ((IRQn_Type)last_interrupt_index);
56+ cfg.irq = (IRQn_Type)last_interrupt_index;
57+ last_interrupt_index++;
58+ rv = true ;
59+ }
60+ }
61+ return rv;
62+ }
4163
4264bool IRQManager::addADCScanEnd (ADC_Container *adc, Irq_f fnc /* = nullptr*/ ) {
4365 /* getting the address of the current location of the irq vector table */
Original file line number Diff line number Diff line change @@ -125,6 +125,11 @@ typedef struct timer {
125125 agt_extended_cfg_t *agt_ext_cfg;
126126} TimerIrqCfg_t;
127127
128+ typedef struct genericIrq {
129+ IRQn_Type irq;
130+ uint8_t ipl;
131+ elc_event_t event;
132+ } GenericIrqCfg_t;
128133
129134
130135#ifdef __cplusplus
@@ -199,7 +204,8 @@ class IRQManager {
199204 it returns true if the interrupt is correctly added */
200205 bool addDMA (dmac_extended_cfg_t &cfg, Irq_f fnc = nullptr );
201206#endif
202-
207+
208+ bool addGenericInterrupt (GenericIrqCfg_t &cfg, Irq_f fnc = nullptr );
203209 bool addTimerOverflow (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
204210 bool addTimerUnderflow (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
205211 bool addTimerCompareCaptureA (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
You can’t perform that action at this time.
0 commit comments