File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,28 @@ IRQManager& IRQManager::getInstance() {
38
38
return instance;
39
39
}
40
40
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) && (last_interrupt_index < PROG_IRQ_NUM)) {
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
+ }
41
63
42
64
bool IRQManager::addADCScanEnd (ADC_Container *adc, Irq_f fnc /* = nullptr*/ ) {
43
65
/* 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 {
125
125
agt_extended_cfg_t *agt_ext_cfg;
126
126
} TimerIrqCfg_t;
127
127
128
+ typedef struct genericIrq {
129
+ IRQn_Type irq;
130
+ uint8_t ipl;
131
+ elc_event_t event;
132
+ } GenericIrqCfg_t;
128
133
129
134
130
135
#ifdef __cplusplus
@@ -199,7 +204,8 @@ class IRQManager {
199
204
it returns true if the interrupt is correctly added */
200
205
bool addDMA (dmac_extended_cfg_t &cfg, Irq_f fnc = nullptr );
201
206
#endif
202
-
207
+
208
+ bool addGenericInterrupt (GenericIrqCfg_t &cfg, Irq_f fnc = nullptr );
203
209
bool addTimerOverflow (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
204
210
bool addTimerUnderflow (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
205
211
bool addTimerCompareCaptureA (TimerIrqCfg_t &cfg, Irq_f fnc = nullptr );
You can’t perform that action at this time.
0 commit comments