diff --git a/arch/platform/zoul/dev/button-sensor.c b/arch/platform/zoul/dev/button-sensor.c index 80c7b75cb..9b410cdbf 100644 --- a/arch/platform/zoul/dev/button-sensor.c +++ b/arch/platform/zoul/dev/button-sensor.c @@ -43,6 +43,7 @@ #include "dev/nvic.h" #include "dev/ioc.h" #include "dev/gpio.h" +#include "dev/gpio-hal.h" #include "dev/button-sensor.h" #include "sys/timer.h" #include "sys/ctimer.h" @@ -94,15 +95,8 @@ value(int type) return 0; } /*---------------------------------------------------------------------------*/ -/** - * \brief Callback registered with the GPIO module. Gets fired with a button - * port/pin generates an interrupt - * \param port The port number that generated the interrupt - * \param pin The pin number that generated the interrupt. This is the pin - * absolute number (i.e. 0, 1, ..., 7), not a mask - */ static void -btn_callback(uint8_t port, uint8_t pin) +button_press_handler(gpio_hal_pin_mask_t pin_mask) { if(!timer_expired(&debouncetimer)) { return; @@ -123,6 +117,12 @@ btn_callback(uint8_t port, uint8_t pin) sensors_changed(&button_sensor); } /*---------------------------------------------------------------------------*/ +static gpio_hal_event_handler_t press_handler = { + .next = NULL, + .handler = button_press_handler, + .pin_mask = gpio_hal_pin_to_mask(BUTTON_USER_PIN) << (BUTTON_USER_PORT << 3), +}; +/*---------------------------------------------------------------------------*/ /** * \brief Init function for the User button. * \param type SENSORS_ACTIVE: Activate / Deactivate the sensor (value == 1 @@ -152,7 +152,7 @@ config_user(int type, int value) ioc_set_over(BUTTON_USER_PORT, BUTTON_USER_PIN, IOC_OVERRIDE_PUE); - gpio_register_callback(btn_callback, BUTTON_USER_PORT, BUTTON_USER_PIN); + gpio_hal_register_handler(&press_handler); break; case SENSORS_ACTIVE: if(value) { diff --git a/arch/platform/zoul/dev/cc1200-zoul-arch.c b/arch/platform/zoul/dev/cc1200-zoul-arch.c index 92e686a4e..1aff2ef40 100644 --- a/arch/platform/zoul/dev/cc1200-zoul-arch.c +++ b/arch/platform/zoul/dev/cc1200-zoul-arch.c @@ -52,6 +52,7 @@ #include "dev/spi.h" #include "dev/ssi.h" #include "dev/gpio.h" +#include "dev/gpio-hal.h" #include /*---------------------------------------------------------------------------*/ #define CC1200_SPI_CLK_PORT_BASE GPIO_PORT_TO_BASE(SPI0_CLK_PORT) @@ -92,7 +93,7 @@ extern int cc1200_rx_interrupt(void); /*---------------------------------------------------------------------------*/ void -cc1200_int_handler(uint8_t port, uint8_t pin) +cc1200_int_handler(gpio_hal_pin_mask_t pin_mask) { /* To keep the gpio_register_callback happy */ cc1200_rx_interrupt(); @@ -166,6 +167,14 @@ cc1200_arch_spi_rw(uint8_t *inbuf, const uint8_t *write_buf, uint16_t len) return 0; } /*---------------------------------------------------------------------------*/ +static gpio_hal_event_handler_t interrupt_handler = { + .next = NULL, + .handler = cc1200_int_handler, + .pin_mask = + (gpio_hal_pin_to_mask(CC1200_GDO0_PIN) << (CC1200_GDO0_PORT << 3)) | + (gpio_hal_pin_to_mask(CC1200_GDO2_PIN) << (CC1200_GDO2_PORT << 3)) +}; +/*---------------------------------------------------------------------------*/ void cc1200_arch_gpio0_setup_irq(int rising) { @@ -184,8 +193,7 @@ cc1200_arch_gpio0_setup_irq(int rising) GPIO_ENABLE_INTERRUPT(CC1200_GDO0_PORT_BASE, CC1200_GDO0_PIN_MASK); ioc_set_over(CC1200_GDO0_PORT, CC1200_GDO0_PIN, IOC_OVERRIDE_PUE); NVIC_EnableIRQ(CC1200_GPIOx_VECTOR); - gpio_register_callback(cc1200_int_handler, CC1200_GDO0_PORT, - CC1200_GDO0_PIN); + gpio_hal_register_handler(&interrupt_handler); } /*---------------------------------------------------------------------------*/ void @@ -206,8 +214,7 @@ cc1200_arch_gpio2_setup_irq(int rising) GPIO_ENABLE_INTERRUPT(CC1200_GDO2_PORT_BASE, CC1200_GDO2_PIN_MASK); ioc_set_over(CC1200_GDO2_PORT, CC1200_GDO2_PIN, IOC_OVERRIDE_PUE); NVIC_EnableIRQ(CC1200_GPIOx_VECTOR); - gpio_register_callback(cc1200_int_handler, CC1200_GDO2_PORT, - CC1200_GDO2_PIN); + gpio_hal_register_handler(&interrupt_handler); } /*---------------------------------------------------------------------------*/ void diff --git a/arch/platform/zoul/dev/rtcc.c b/arch/platform/zoul/dev/rtcc.c index b5cb116c3..d03413d5b 100644 --- a/arch/platform/zoul/dev/rtcc.c +++ b/arch/platform/zoul/dev/rtcc.c @@ -735,7 +735,7 @@ rtcc_print(uint8_t value) } /*---------------------------------------------------------------------------*/ static void -rtcc_interrupt_handler(uint8_t port, uint8_t pin) +rtcc_interrupt_handler(gpio_hal_pin_mask_t pin_mask) { process_poll(&rtcc_int_process); } @@ -912,6 +912,12 @@ rtcc_set_calibration(uint8_t mode, int32_t adjust) return AB08_SUCCESS; } /*---------------------------------------------------------------------------*/ +static gpio_hal_event_handler_t rtcc_handler = { + .next = NULL, + .handler = rtcc_interrupt_handler, + .pin_mask = gpio_hal_pin_to_mask(RTC_INT1_PIN) << (RTC_INT1_PORT << 3), +}; +/*---------------------------------------------------------------------------*/ int8_t rtcc_init(void) { @@ -937,7 +943,7 @@ rtcc_init(void) GPIO_DETECT_EDGE(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK); GPIO_TRIGGER_SINGLE_EDGE(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK); GPIO_DETECT_FALLING(RTC_INT1_PORT_BASE, RTC_INT1_PIN_MASK); - gpio_register_callback(rtcc_interrupt_handler, RTC_INT1_PORT, RTC_INT1_PIN); + gpio_hal_register_handler(&rtcc_handler); /* Spin process until an interrupt is received */ process_start(&rtcc_int_process, NULL);