I am having a hard time enabling an interrupt from an SPI device, which brings GPIOD_PIN2 low on my STM32F405. I have in my code:
Code: Select all
palEnableLineEvent(GPIOD_PIN2_SPI3_INT, PAL_EVENT_MODE_FALLING_EDGE);
palSetLineCallback(GPIOD_PIN2_SPI3_INT, rfm22b_int_cb, NULL);
The device is an RFM22b transceiver. During the operation I enable the interrupts, but my callback is never called. I do check that the GPIO pin in question is initially high, then it is brought low by the device:
Code: Select all
rfm22b_data_ready = 0; // this is set to 1 in the callback
chprintf(current_chp, "INT gpio pad is %d\r\n", palReadPad(GPIOD, GPIOD_PIN2_SPI3_INT));
// Enable the transmitter.
rfm22_write(RFM22_op_and_func_ctrl1, RFM22_opfc1_pllon | RFM22_opfc1_txon);
// wait for end of transmission
uint32_t cnt = 0;
while(palReadPad(GPIOD, GPIOD_PIN2_SPI3_INT)) cnt++;
chprintf(current_chp, "counter %d, data ready %d, INT gpio pad is %d\r\n", cnt, rfm22b_data_ready, palReadPad(GPIOD, GPIOD_PIN2_SPI3_INT));
The above prints the following output
Code: Select all
INT gpio pad is 1
counter 50063, data ready 0, INT gpio pad is 0
So initially my GPIO pin is high, after 50k loop iterations it was brought down by the device, but the callback was not called.
I have used this method for another device, connected to another SPI bus, and it works correctly there. I really have no idea why it's not working in this case. Could you help out? Do you have any idea what I could be doing wrong?
Thanks!