I have placed two active low circuits for PB5 and PA5 (SPI is never initialized). The following is the code extract:
void interrupt_handler() {
Serial.println("Interrupt!");
// running something...
}
void alert_handler() {
Serial.println("Alert!");
// running something...
}
//-------------------------------------------------------------
// Startup Function called in setup()
void startup_config() {
api.lorawan.band.set(RAK_REGION_AS923);
api.lorawan.deviceClass.set(CLASS);
api.lorawan.njm.set(JOINMODE);
api.lorawan.dr.set(DataRate_SET);
api.lorawan.adr.set(ADR_SET);
api.lorawan.rety.set(RETRYTIME);
api.lorawan.cfm.set(CONFIRM_ENABLE);
api.lorawan.registerRecvCallback(recvCallback);
api.lorawan.registerJoinCallback(joinCallback);
api.lorawan.registerSendCallback(sendCallback);
api.lorawan.linkcheck.set(2);
api.system.lpm.set(1);
delay(150);
pinMode(PB5, INPUT);
attachInterrupt(PB5, interrupt_handler, FALLING);
pinMode(PA5, INPUT);
attachInterrupt(PA5, alert_handler, FALLING);
delay(100);
}
I tried this code with manually altering the logic levels, but RAK3172 performs in an extremely wierd way as follows:
- When the code is run in the same init order, PB5 runs normally, but alert from PA5 can never be called.
- When the init code for PB5 is commented out, PA5 runs normally.
- When the init code order of the two pins interchanged, PA5 cannot be called but PB5 is calling the alert_handler of PA5.
I have no idea on why this happens only on the SPI pins. Is this situations impliing there is one and only one interrupt allowed for the GPIO5 family, or this is just a limitation of RUI3 init process of the I/O pins? Can I use both of them in the same time.