NonArduino: Tock: Fixup the GPIO interrupt callbacks
Previously we only supported a single interrupt callback function, which could cause issues. Fix this up so instead we support interrupt callbacks on all 4 GPIOs. Signed-off-by: Alistair Francis <alistair@alistair23.me>
This commit is contained in:
parent
71a7ebf86e
commit
416df1c50d
1 changed files with 6 additions and 2 deletions
|
@ -55,6 +55,8 @@
|
|||
|
||||
typedef void (*gpioIrqFn)(void);
|
||||
|
||||
gpioIrqFn gpio_funcs[4] = { NULL, NULL, NULL, NULL};
|
||||
|
||||
/*
|
||||
* Get the the timer frequency in Hz.
|
||||
*/
|
||||
|
@ -73,7 +75,7 @@ static void lora_phy_gpio_Callback (int gpioPin,
|
|||
__attribute__ ((unused)) int arg3,
|
||||
void* userdata)
|
||||
{
|
||||
gpioIrqFn fn = *(gpioIrqFn*)(&userdata);
|
||||
gpioIrqFn fn = gpio_funcs[gpioPin - 1];
|
||||
|
||||
if (fn != NULL ) {
|
||||
fn();
|
||||
|
@ -136,7 +138,8 @@ class TockHal : public RadioLibHal {
|
|||
return;
|
||||
}
|
||||
|
||||
libtock_lora_phy_gpio_command_interrupt_callback(lora_phy_gpio_Callback, &interruptCb);
|
||||
gpio_funcs[interruptNum - 1] = interruptCb;
|
||||
libtock_lora_phy_gpio_command_interrupt_callback(lora_phy_gpio_Callback, NULL);
|
||||
|
||||
// set GPIO as input and enable interrupts on it
|
||||
libtock_lora_phy_gpio_enable_input(interruptNum, libtock_pull_down);
|
||||
|
@ -148,6 +151,7 @@ class TockHal : public RadioLibHal {
|
|||
return;
|
||||
}
|
||||
|
||||
gpio_funcs[interruptNum - 1] = NULL;
|
||||
libtock_lora_phy_gpio_disable_interrupt(interruptNum);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue