The new renesas-uno platform 1.2.0 has a new function for attaching generic interrupts that aren't covered elsewhere in the IRQManager.h
Here's a test sketch that attaches IRQ0 using the new function. This could be done with attachInterrupt instead, but pin interrupts are easy to set up so I used this for illustration. The function will be handy for things like the CAC and CTSU that aren't implemented in the Arduino core and aren't covered in IRQManger.h
#include "IRQManager.h"
volatile bool interruptFired = false;
GenericIrqCfg_t cfg;
void setup() {
Serial.begin(115200);
while (!Serial)
;
Serial.println("\n\n *** " __FILE__ " ***\n\n");
R_ICU->IRQCR[0] = 0xB0; // Configure some peripheral for an interrupt
// Create a generic interrupt configuration and attach
cfg.irq = FSP_INVALID_VECTOR;
cfg.ipl = 12;
cfg.event = ELC_EVENT_ICU_IRQ0;
IRQManager::getInstance().addGenericInterrupt(cfg, Myirq0_callback);
// Enable the interrupt at the peripheral.
R_PFS->PORT[1].PIN[5].PmnPFS = (1 << R_PFS_PORT_PIN_PmnPFS_PCR_Pos) | (1 << R_PFS_PORT_PIN_PmnPFS_ISEL_Pos);
}
void loop() {
Serial.println("Loop Running");
delay(500);
if (interruptFired) {
interruptFired = false;
Serial.println("Interrupt Fired");
}
}
void Myirq0_callback() {
R_ICU->IELSR[cfg.irq] &= ~(R_ICU_IELSR_IR_Msk);
interruptFired = true;
}
The configuration struct has three members. The irq needs to be set to FSP_INVALID_VECTOR
or your interrupt won't be attached. The function from IRQManager will give you back the irq number here once it is attached.
The ipl is the interrupt priority. If you're not sure then use 12.
The event is the ELC event code from section 13.4 in the hardware manual. That part is covered above in this thread. A list of the defines can be found in the variants folder in elc_defines.h