diff --git a/cpu/atmega_common/periph/gpio.c b/cpu/atmega_common/periph/gpio.c index 52f1b9431a16..bab13fc6c842 100644 --- a/cpu/atmega_common/periph/gpio.c +++ b/cpu/atmega_common/periph/gpio.c @@ -145,9 +145,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int8_t int_num = _int_num(pin); /* mode not supported */ diff --git a/cpu/cc2538/include/periph_cpu.h b/cpu/cc2538/include/periph_cpu.h index 4511dd8ea44b..24f8a167b2e6 100644 --- a/cpu/cc2538/include/periph_cpu.h +++ b/cpu/cc2538/include/periph_cpu.h @@ -48,6 +48,14 @@ extern "C" { typedef uint32_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + /** * @name Power management configuration * @{ diff --git a/cpu/cc2538/periph/gpio.c b/cpu/cc2538/periph/gpio.c index 83a33c86c45d..d898abebcf4c 100644 --- a/cpu/cc2538/periph/gpio.c +++ b/cpu/cc2538/periph/gpio.c @@ -118,9 +118,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + if (gpio_init(pin, mode) != 0) { return -1; } diff --git a/cpu/cc26x0/periph/gpio.c b/cpu/cc26x0/periph/gpio.c index 7ca9090594b4..0ffd090709bc 100644 --- a/cpu/cc26x0/periph/gpio.c +++ b/cpu/cc26x0/periph/gpio.c @@ -51,9 +51,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int init = gpio_init(pin, mode); if (init != 0) return init; diff --git a/cpu/efm32/include/periph_cpu.h b/cpu/efm32/include/periph_cpu.h index 5a868ad57bc9..99ef7df97a19 100644 --- a/cpu/efm32/include/periph_cpu.h +++ b/cpu/efm32/include/periph_cpu.h @@ -129,6 +129,14 @@ typedef struct { typedef uint32_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value. */ diff --git a/cpu/efm32/periph/gpio.c b/cpu/efm32/periph/gpio.c index 0746bbb522af..ab846560bfc5 100644 --- a/cpu/efm32/periph/gpio.c +++ b/cpu/efm32/periph/gpio.c @@ -72,9 +72,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int result = gpio_init(pin, mode); if (result != 0) { diff --git a/cpu/ezr32wg/include/periph_cpu.h b/cpu/ezr32wg/include/periph_cpu.h index 338a7a0bbf6c..9a5c7afb5030 100644 --- a/cpu/ezr32wg/include/periph_cpu.h +++ b/cpu/ezr32wg/include/periph_cpu.h @@ -69,6 +69,14 @@ typedef struct { typedef uint32_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value */ diff --git a/cpu/ezr32wg/periph/gpio.c b/cpu/ezr32wg/periph/gpio.c index 2cabdb85f866..0d32b17a96c7 100644 --- a/cpu/ezr32wg/periph/gpio.c +++ b/cpu/ezr32wg/periph/gpio.c @@ -80,9 +80,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + uint32_t pin_pos = _pin_pos(pin); /* configure as input */ diff --git a/cpu/fe310/periph/gpio.c b/cpu/fe310/periph/gpio.c index 85e19349956a..749e54a23eab 100644 --- a/cpu/fe310/periph/gpio.c +++ b/cpu/fe310/periph/gpio.c @@ -99,9 +99,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + /* Configure pin */ if (gpio_init(pin, mode) != 0) { return -1; diff --git a/cpu/kinetis/include/periph_cpu.h b/cpu/kinetis/include/periph_cpu.h index 38e08a7bae8c..b02a3ad1c9b6 100644 --- a/cpu/kinetis/include/periph_cpu.h +++ b/cpu/kinetis/include/periph_cpu.h @@ -38,6 +38,14 @@ extern "C" { typedef uint16_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint16_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value */ diff --git a/cpu/kinetis/periph/gpio.c b/cpu/kinetis/periph/gpio.c index ec0155dfdc2b..ab3fe1eb99d7 100644 --- a/cpu/kinetis/periph/gpio.c +++ b/cpu/kinetis/periph/gpio.c @@ -197,9 +197,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + if (gpio_init(pin, mode) < 0) { return -1; } diff --git a/cpu/lm4f120/include/periph_cpu.h b/cpu/lm4f120/include/periph_cpu.h index 7cbbd7638865..98c520bab80c 100644 --- a/cpu/lm4f120/include/periph_cpu.h +++ b/cpu/lm4f120/include/periph_cpu.h @@ -37,6 +37,14 @@ typedef uint32_t gpio_t; #define GPIO_PIN(x,y) ((gpio_t)((x<<4) | y)) /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + #ifndef DOXYGEN /** * @brief Override GPIO modes diff --git a/cpu/lm4f120/periph/gpio.c b/cpu/lm4f120/periph/gpio.c index 0cb0bbd90d70..2abdd7223c6a 100644 --- a/cpu/lm4f120/periph/gpio.c +++ b/cpu/lm4f120/periph/gpio.c @@ -161,9 +161,11 @@ void isr_gpio_portf(void){ _isr_gpio(5); } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + const uint8_t port_num = _port_num(pin); const uint32_t port_addr = _port_base[port_num]; const uint32_t icr_reg_addr = port_addr + GPIO_ICR_R_OFF; diff --git a/cpu/lpc1768/include/periph_cpu.h b/cpu/lpc1768/include/periph_cpu.h index 4e3d33846d13..7e3ee2d9504f 100644 --- a/cpu/lpc1768/include/periph_cpu.h +++ b/cpu/lpc1768/include/periph_cpu.h @@ -36,6 +36,14 @@ extern "C" { typedef uint8_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint8_t cb_mux_cbid_t; +/** @} */ + /** * @brief Define a custom GPIO_PIN macro for the lpc1768 */ diff --git a/cpu/lpc1768/periph/gpio.c b/cpu/lpc1768/periph/gpio.c index 495e8027d317..01508a77b875 100644 --- a/cpu/lpc1768/periph/gpio.c +++ b/cpu/lpc1768/periph/gpio.c @@ -127,9 +127,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + /* only certain pins can be used as interrupt pins */ if (_port(pin) != 0 && _port(pin) != 2) { return -1; diff --git a/cpu/lpc2387/periph/gpio.c b/cpu/lpc2387/periph/gpio.c index 3891c50b7f61..a250e66381dc 100644 --- a/cpu/lpc2387/periph/gpio.c +++ b/cpu/lpc2387/periph/gpio.c @@ -94,9 +94,10 @@ int gpio_init_mux(unsigned pin, unsigned mux) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; (void)mode; DEBUG("gpio_init_int(): pin %u\n", pin); diff --git a/cpu/mips_pic32_common/periph/gpio.c b/cpu/mips_pic32_common/periph/gpio.c index 396d0d574be5..474bedcd6067 100644 --- a/cpu/mips_pic32_common/periph/gpio.c +++ b/cpu/mips_pic32_common/periph/gpio.c @@ -172,9 +172,10 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; (void)pin; (void)mode; (void)flank; diff --git a/cpu/msp430fxyz/include/periph_cpu.h b/cpu/msp430fxyz/include/periph_cpu.h index 4d4a15b5a2cc..d12f1eb291ab 100644 --- a/cpu/msp430fxyz/include/periph_cpu.h +++ b/cpu/msp430fxyz/include/periph_cpu.h @@ -36,6 +36,14 @@ extern "C" { typedef uint16_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint16_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value */ diff --git a/cpu/msp430fxyz/periph/gpio.c b/cpu/msp430fxyz/periph/gpio.c index e6682eb950a9..fb777448847c 100644 --- a/cpu/msp430fxyz/periph/gpio.c +++ b/cpu/msp430fxyz/periph/gpio.c @@ -99,9 +99,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + msp_port_isr_t *port = _isr_port(pin); /* check if port, pull resistor and flank configuration are valid */ diff --git a/cpu/native/periph/gpio.c b/cpu/native/periph/gpio.c index 156b2f42011b..c8e19f53b523 100644 --- a/cpu/native/periph/gpio.c +++ b/cpu/native/periph/gpio.c @@ -26,8 +26,10 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) { return -1; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg){ +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) +{ + (void) entry; (void) pin; (void) mode; (void) flank; diff --git a/cpu/nrf5x_common/periph/gpio.c b/cpu/nrf5x_common/periph/gpio.c index cacd1d9e8e4d..bb95e4cfcc74 100644 --- a/cpu/nrf5x_common/periph/gpio.c +++ b/cpu/nrf5x_common/periph/gpio.c @@ -84,9 +84,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + /* disable external interrupt in case one is active */ NRF_GPIOTE->INTENSET &= ~(GPIOTE_INTENSET_IN0_Msk); /* save callback */ diff --git a/cpu/sam0_common/include/periph_cpu_common.h b/cpu/sam0_common/include/periph_cpu_common.h index caa954f4c1d7..a4e314861fab 100644 --- a/cpu/sam0_common/include/periph_cpu_common.h +++ b/cpu/sam0_common/include/periph_cpu_common.h @@ -49,6 +49,14 @@ extern "C" { typedef uint32_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value */ diff --git a/cpu/sam0_common/periph/gpio.c b/cpu/sam0_common/periph/gpio.c index 62be9b8e4a2c..6a989db320eb 100644 --- a/cpu/sam0_common/periph/gpio.c +++ b/cpu/sam0_common/periph/gpio.c @@ -111,9 +111,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int exti = _exti(pin); /* make sure EIC channel is valid */ diff --git a/cpu/sam3/include/periph_cpu.h b/cpu/sam3/include/periph_cpu.h index abf279fe1c59..fe6b46a6d172 100644 --- a/cpu/sam3/include/periph_cpu.h +++ b/cpu/sam3/include/periph_cpu.h @@ -35,6 +35,14 @@ extern "C" { typedef uint32_t gpio_t; /** @} */ +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ + /** * @brief Definition of a fitting UNDEF value */ diff --git a/cpu/sam3/periph/gpio.c b/cpu/sam3/periph/gpio.c index ebe7d73a244c..000499ddd654 100644 --- a/cpu/sam3/periph/gpio.c +++ b/cpu/sam3/periph/gpio.c @@ -191,9 +191,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + Pio *port = _port(pin); int pin_num = _pin_num(pin); int port_num = _port_num(pin); diff --git a/cpu/stm32_common/include/periph_cpu_common.h b/cpu/stm32_common/include/periph_cpu_common.h index 56eac8b6d1cf..9ada0a7dd271 100644 --- a/cpu/stm32_common/include/periph_cpu_common.h +++ b/cpu/stm32_common/include/periph_cpu_common.h @@ -120,6 +120,14 @@ typedef enum { #define HAVE_GPIO_T typedef uint32_t gpio_t; /** @} */ + +/** + * @name Define a custom type for cb_mux cbid + * @{ + */ +#define HAVE_CB_MUX_CBID_T +typedef uint32_t cb_mux_cbid_t; +/** @} */ #endif /** diff --git a/cpu/stm32_common/periph/gpio.c b/cpu/stm32_common/periph/gpio.c index 7aa0eaba3b1c..6c89c0e4cb26 100644 --- a/cpu/stm32_common/periph/gpio.c +++ b/cpu/stm32_common/periph/gpio.c @@ -102,9 +102,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int pin_num = _pin_num(pin); int port_num = _port_num(pin); diff --git a/cpu/stm32f1/periph/gpio.c b/cpu/stm32f1/periph/gpio.c index 448791dc6223..7ebf39ee5833 100644 --- a/cpu/stm32f1/periph/gpio.c +++ b/cpu/stm32f1/periph/gpio.c @@ -99,9 +99,11 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) return 0; /* all OK */ } -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg) +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg) { + (void)entry; + int pin_num = _pin_num(pin); /* disable interrupts on the channel we want to edit (just in case) */ diff --git a/drivers/adcxx1c/adcxx1c.c b/drivers/adcxx1c/adcxx1c.c index e56afc58ed66..810a9049b27a 100644 --- a/drivers/adcxx1c/adcxx1c.c +++ b/drivers/adcxx1c/adcxx1c.c @@ -36,6 +36,9 @@ * value 0x20: cycle time = Tconvert x 64 */ #define CONF_TEST_VALUE (0x20) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + int adcxx1c_init(adcxx1c_t *dev, const adcxx1c_params_t *params) { assert(dev && params); @@ -114,7 +117,8 @@ int adcxx1c_enable_alert(adcxx1c_t *dev, adcxx1c_cb_t cb, void *arg) dev->cb = cb; dev->arg = arg; /* alert active low */ - gpio_init_int(dev->params.alert_pin, GPIO_IN, GPIO_FALLING, _alert_cb, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.alert_pin, GPIO_IN, + GPIO_FALLING, _alert_cb, dev); } return ADCXX1C_OK; diff --git a/drivers/ads101x/ads101x.c b/drivers/ads101x/ads101x.c index 1c03a475bfd4..5fc783ed40f9 100644 --- a/drivers/ads101x/ads101x.c +++ b/drivers/ads101x/ads101x.c @@ -40,6 +40,9 @@ #define I2C (dev->params.i2c) #define ADDR (dev->params.addr) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static int _ads101x_init_test(i2c_t i2c, uint8_t addr); int ads101x_init(ads101x_t *dev, const ads101x_params_t *params) @@ -174,7 +177,8 @@ int ads101x_enable_alert(ads101x_alert_t *dev, /* Enable interrupt */ dev->arg = arg; dev->cb = cb; - gpio_init_int(dev->params.alert_pin, GPIO_IN, GPIO_FALLING, cb, arg); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.alert_pin, + GPIO_IN, GPIO_FALLING, cb, arg); return ADS101X_OK; } diff --git a/drivers/at86rf2xx/at86rf2xx_netdev.c b/drivers/at86rf2xx/at86rf2xx_netdev.c index dd697483dcc2..d030a641c1d7 100644 --- a/drivers/at86rf2xx/at86rf2xx_netdev.c +++ b/drivers/at86rf2xx/at86rf2xx_netdev.c @@ -60,6 +60,9 @@ const netdev_driver_t at86rf2xx_driver = { .set = _set, }; +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void _irq_handler(void *arg) { netdev_t *dev = (netdev_t *) arg; @@ -79,7 +82,8 @@ static int _init(netdev_t *netdev) gpio_clear(dev->params.sleep_pin); gpio_init(dev->params.reset_pin, GPIO_OUT); gpio_set(dev->params.reset_pin); - gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, _irq_handler, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.int_pin, GPIO_IN, + GPIO_RISING, _irq_handler, dev); /* reset device to default values and put it into RX state */ at86rf2xx_reset(dev); diff --git a/drivers/ata8520e/ata8520e.c b/drivers/ata8520e/ata8520e.c index 7b1380cf5b62..8d2cdcc52e54 100644 --- a/drivers/ata8520e/ata8520e.c +++ b/drivers/ata8520e/ata8520e.c @@ -50,6 +50,9 @@ #define TX_TIMEOUT (8U) /* 8 s */ #define TX_RX_TIMEOUT (50U) /* 50 s */ +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void _print_atmel_status(uint8_t status) { DEBUG("[ata8520e] Atmel status: %d\n", status); @@ -242,7 +245,7 @@ int ata8520e_init(ata8520e_t *dev, const ata8520e_params_t *params) memcpy(&dev->params, params, sizeof(ata8520e_params_t)); /* Initialize pins*/ - if (gpio_init_int(INTPIN, GPIO_IN_PD, + if (gpio_init_int(GPIO_GET_ALLOC(0), INTPIN, GPIO_IN_PD, GPIO_FALLING, _irq_handler, dev) < 0 ) { DEBUG("[ata8520e] ERROR: Interrupt pin not initialized\n"); return -ATA8520E_ERR_GPIO_INT; diff --git a/drivers/cc110x/cc110x-netdev.c b/drivers/cc110x/cc110x-netdev.c index 99f3b58dacd1..f4f1d35e69df 100644 --- a/drivers/cc110x/cc110x-netdev.c +++ b/drivers/cc110x/cc110x-netdev.c @@ -37,6 +37,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static int _send(netdev_t *dev, const iolist_t *iolist) { DEBUG("%s:%u\n", __func__, __LINE__); @@ -200,8 +203,8 @@ static int _init(netdev_t *dev) cc110x_t *cc110x = &((netdev_cc110x_t*) dev)->cc110x; - gpio_init_int(cc110x->params.gdo2, GPIO_IN, GPIO_BOTH, - &_netdev_cc110x_isr, (void*)dev); + gpio_init_int(GPIO_GET_ALLOC(0), cc110x->params.gdo2, GPIO_IN, + GPIO_BOTH, &_netdev_cc110x_isr, (void*)dev); gpio_set(cc110x->params.gdo2); gpio_irq_disable(cc110x->params.gdo2); diff --git a/drivers/cc2420/cc2420_netdev.c b/drivers/cc2420/cc2420_netdev.c index fe1f42ccd300..6367d372e2c5 100644 --- a/drivers/cc2420/cc2420_netdev.c +++ b/drivers/cc2420/cc2420_netdev.c @@ -55,6 +55,9 @@ const netdev_driver_t cc2420_driver = { .set = _set, }; +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void _irq_handler(void *arg) { netdev_t *dev = (netdev_t *)arg; @@ -113,7 +116,8 @@ static int _init(netdev_t *netdev) gpio_init(dev->params.pin_cca, GPIO_IN); gpio_init(dev->params.pin_sfd, GPIO_IN); gpio_init(dev->params.pin_fifo, GPIO_IN); - gpio_init_int(dev->params.pin_fifop, GPIO_IN, GPIO_RISING, _irq_handler, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.pin_fifop, GPIO_IN, + GPIO_RISING, _irq_handler, dev); /* initialize the chip select line and the SPI bus */ spi_init_cs(dev->params.spi, dev->params.pin_cs); diff --git a/drivers/enc28j60/enc28j60.c b/drivers/enc28j60/enc28j60.c index 4471efe9855c..943d095cad3f 100644 --- a/drivers/enc28j60/enc28j60.c +++ b/drivers/enc28j60/enc28j60.c @@ -74,6 +74,8 @@ #define BUF_RX_START (0) #define BUF_RX_END (BUF_TX_START - 2) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); static void switch_bank(enc28j60_t *dev, int8_t bank) { @@ -325,7 +327,8 @@ static int nd_init(netdev_t *netdev) DEBUG("[enc28j60] init: error initializing the CS pin [%i]\n", res); return -1; } - gpio_init_int(dev->int_pin, GPIO_IN, GPIO_FALLING, on_int, (void *)dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->int_pin, GPIO_IN, + GPIO_FALLING, on_int, (void *)dev); /* wait at least 1ms and then release device from reset state */ xtimer_usleep(DELAY_RESET); diff --git a/drivers/encx24j600/encx24j600.c b/drivers/encx24j600/encx24j600.c index 4f8cd3818c3a..5fca2108d701 100644 --- a/drivers/encx24j600/encx24j600.c +++ b/drivers/encx24j600/encx24j600.c @@ -79,6 +79,9 @@ static const netdev_driver_t netdev_driver_encx24j600 = { .set = netdev_eth_set, }; +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static inline void lock(encx24j600_t *dev) { spi_acquire(dev->spi, dev->cs, SPI_MODE, SPI_CLK); } @@ -243,7 +246,8 @@ static int _init(netdev_t *encdev) if (spi_init_cs(dev->spi, dev->cs) != SPI_OK) { return -1; } - gpio_init_int(dev->int_pin, GPIO_IN_PU, GPIO_FALLING, encx24j600_isr, (void*)dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->int_pin, GPIO_IN_PU, + GPIO_FALLING, encx24j600_isr, (void*)dev); lock(dev); diff --git a/drivers/include/periph/gpio.h b/drivers/include/periph/gpio.h index 46c03ebc8f2a..73db9fc6cb96 100644 --- a/drivers/include/periph/gpio.h +++ b/drivers/include/periph/gpio.h @@ -55,6 +55,7 @@ #include +#include "cb_mux.h" #include "periph_cpu.h" #include "periph_conf.h" @@ -117,14 +118,34 @@ typedef enum { #endif /** - * @brief Signature of event callback functions triggered from interrupts + * @brief Structure to hold interrupt callback information + */ +typedef cb_mux_t gpio_int_t; + +/** + * @brief Memory allocation for interrupt callback information * - * @param[in] arg optional context for the callback + * This only enables memory allocation if periph_cpu.h enables it by defining + * GPIO_USE_INT_ENTRY, otherwise returns NULL. + */ +#ifdef GPIO_USE_INT_ENTRY +#define GPIO_ALLOC_INT(n) static gpio_int_t gpio_int_entry[n] +#define GPIO_GET_ALLOC(n) gpio_int_entry[n] +#else +/* no-op */ +#define GPIO_ALLOC_INT(n) ; +#define GPIO_GET_ALLOC(n) (NULL) +#endif + +/** + * @brief Signature of event callback functions triggered from interrupts */ -typedef void (*gpio_cb_t)(void *arg); +typedef cb_mux_cb_t gpio_cb_t; /** - * @brief Default interrupt context for GPIO pins + * @brief Default interrupt context for GPIO pins (DEPRECATED) + * + * @note In the process of being removed in favor of cb_mux entries */ #ifndef HAVE_GPIO_ISR_CTX_T typedef struct { @@ -156,6 +177,7 @@ int gpio_init(gpio_t pin, gpio_mode_t mode); * * The interrupt is activated automatically after the initialization. * + * @param[in] entry structure to hold callback information * @param[in] pin pin to initialize * @param[in] mode mode of the pin, see @c gpio_mode_t * @param[in] flank define the active flank(s) @@ -165,8 +187,8 @@ int gpio_init(gpio_t pin, gpio_mode_t mode); * @return 0 on success * @return -1 on error */ -int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, - gpio_cb_t cb, void *arg); +int gpio_init_int(gpio_int_t *entry, gpio_t pin, gpio_mode_t mode, + gpio_flank_t flank, gpio_cb_t cb, void *arg); /** * @brief Enable pin interrupt if configured as interrupt source diff --git a/drivers/isl29125/isl29125.c b/drivers/isl29125/isl29125.c index 39cbd22f65a7..94c3256237a4 100644 --- a/drivers/isl29125/isl29125.c +++ b/drivers/isl29125/isl29125.c @@ -32,6 +32,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + /*********************************************************************** * public API implementation **********************************************************************/ @@ -140,7 +143,8 @@ int isl29125_init_int(isl29125_t *dev, isl29125_interrupt_status_t interrupt_sta DEBUG("isl29125_init: i2c_write_reg(ISL29125_REG_HTHHB)\n"); (void) i2c_write_reg(dev->i2c, ISL29125_I2C_ADDRESS, ISL29125_REG_HTHHB, hthhb); - if (gpio_init_int(dev->gpio, GPIO_IN, GPIO_FALLING, cb, arg) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(0), dev->gpio, GPIO_IN, + GPIO_FALLING, cb, arg) < 0) { DEBUG("error: gpio_init_int failed\n"); return -1; } diff --git a/drivers/kw2xrf/kw2xrf.c b/drivers/kw2xrf/kw2xrf.c index 1d3db0f7ad90..e07d6eee1c5e 100644 --- a/drivers/kw2xrf/kw2xrf.c +++ b/drivers/kw2xrf/kw2xrf.c @@ -40,6 +40,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void kw2xrf_set_address(kw2xrf_t *dev) { DEBUG("[kw2xrf] set MAC addresses\n"); @@ -78,7 +81,8 @@ int kw2xrf_init(kw2xrf_t *dev, gpio_cb_t cb) kw2xrf_set_out_clk(dev); kw2xrf_disable_interrupts(dev); /* set up GPIO-pin used for IRQ */ - gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_FALLING, cb, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.int_pin, + GPIO_IN, GPIO_FALLING, cb, dev); kw2xrf_abort_sequence(dev); kw2xrf_update_overwrites(dev); diff --git a/drivers/lc709203f/lc709203f.c b/drivers/lc709203f/lc709203f.c index 6099707d5c47..362550e7f810 100644 --- a/drivers/lc709203f/lc709203f.c +++ b/drivers/lc709203f/lc709203f.c @@ -23,6 +23,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + /* * does a crc check and returns the checksum */ @@ -53,7 +56,8 @@ int lc709203f_init(lc709203f_t *dev, const lc709203f_params_t *params) dev->params = *params; dev->bus = params->bus; dev->addr = params->addr; - gpio_init_int(dev->params.alarm_pin, GPIO_IN, GPIO_FALLING, dev->cb, dev->arg); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.alarm_pin, GPIO_IN, + GPIO_FALLING, dev->cb, dev->arg); i2c_acquire(dev->bus); if (i2c_init_master(dev->bus, I2C_SPEED_FAST)) { i2c_release(dev->bus); diff --git a/drivers/mrf24j40/mrf24j40_netdev.c b/drivers/mrf24j40/mrf24j40_netdev.c index 10f534689b77..3d1129b6d3a3 100644 --- a/drivers/mrf24j40/mrf24j40_netdev.c +++ b/drivers/mrf24j40/mrf24j40_netdev.c @@ -39,6 +39,9 @@ #define _MAX_MHR_OVERHEAD (25) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void _irq_handler(void *arg) { netdev_t *dev = (netdev_t *) arg; @@ -57,7 +60,8 @@ static int _init(netdev_t *netdev) spi_init_cs(dev->params.spi, dev->params.cs_pin); gpio_init(dev->params.reset_pin, GPIO_OUT); gpio_set(dev->params.reset_pin); - gpio_init_int(dev->params.int_pin, GPIO_IN, GPIO_RISING, _irq_handler, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->params.int_pin, GPIO_IN, + GPIO_RISING, _irq_handler, dev); #ifdef MODULE_NETSTATS_L2 memset(&netdev->stats, 0, sizeof(netstats_t)); diff --git a/drivers/nrf24l01p/nrf24l01p.c b/drivers/nrf24l01p/nrf24l01p.c index f8ecf5d66fd4..6bbfdceb5d6d 100644 --- a/drivers/nrf24l01p/nrf24l01p.c +++ b/drivers/nrf24l01p/nrf24l01p.c @@ -34,6 +34,9 @@ #define SPI_MODE SPI_MODE_0 #define SPI_CLK SPI_CLK_400KHZ +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + int nrf24l01p_read_reg(const nrf24l01p_t *dev, char reg, char *answer) { /* Acquire exclusive access to the bus. */ @@ -81,7 +84,8 @@ int nrf24l01p_init(nrf24l01p_t *dev, spi_t spi, gpio_t ce, gpio_t cs, gpio_t irq spi_init_cs(dev->spi, dev->cs); /* Init IRQ pin */ - gpio_init_int(dev->irq, GPIO_IN_PU, GPIO_FALLING, nrf24l01p_rx_cb, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->irq, GPIO_IN_PU, + GPIO_FALLING, nrf24l01p_rx_cb, dev); /* Test the SPI connection */ if (spi_acquire(dev->spi, dev->cs, SPI_MODE, SPI_CLK) != SPI_OK) { diff --git a/drivers/pir/pir.c b/drivers/pir/pir.c index 2f01afe69b32..99ec3073cf6c 100644 --- a/drivers/pir/pir.c +++ b/drivers/pir/pir.c @@ -29,6 +29,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + /********************************************************************** * internal API declaration **********************************************************************/ @@ -60,7 +63,8 @@ int pir_init(pir_t *dev, const pir_params_t *params) gpio_mode = GPIO_IN_PU; } - if (gpio_init_int(dev->p.gpio, gpio_mode, GPIO_BOTH, pir_callback, dev)) { + if (gpio_init_int(GPIO_GET_ALLOC(0), dev->p.gpio, gpio_mode, + GPIO_BOTH, pir_callback, dev)) { return PIR_NOGPIO; } return PIR_OK; @@ -176,7 +180,8 @@ static int pir_activate_int(pir_t *dev) gpio_mode = GPIO_IN_PU; } - if (gpio_init_int(dev->p.gpio, gpio_mode, GPIO_BOTH, pir_callback, dev)) { + if (gpio_init_int(GPIO_GET_ALLOC(0), dev->p.gpio, gpio_mode, + GPIO_BOTH, pir_callback, dev)) { return PIR_NOGPIO; } return PIR_OK; diff --git a/drivers/pn532/pn532.c b/drivers/pn532/pn532.c index 908935709e2e..736df8bd1a14 100644 --- a/drivers/pn532/pn532.c +++ b/drivers/pn532/pn532.c @@ -78,6 +78,9 @@ /* Length for passive listings */ #define LIST_PASSIVE_LEN_14443(num) (num * 20) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + #if ENABLE_DEBUG #define PRINTBUFF printbuff static void printbuff(uint8_t *buff, unsigned len) @@ -114,27 +117,27 @@ int pn532_init(pn532_t *dev, const pn532_params_t *params, pn532_mode_t mode) dev->conf = params; - gpio_init_int(dev->conf->irq, GPIO_IN_PU, GPIO_FALLING, - _nfc_event, (void *)dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->conf->irq, GPIO_IN_PU, + GPIO_FALLING, _nfc_event, (void *)dev); gpio_init(dev->conf->reset, GPIO_OUT); gpio_set(dev->conf->reset); dev->mode = mode; - if (mode == PN532_I2C) { #ifdef PN532_SUPPORT_I2C + if (mode == PN532_I2C) { if (i2c_init_master(dev->conf->i2c, I2C_SPEED_FAST) != 0) { DEBUG("pn532: initialization of I2C bus failed\n"); return -1; } -#endif } - else { +#endif #ifdef PN532_SUPPORT_SPI + if (mode != PN532_I2C) { /* we handle the CS line manually... */ gpio_init(dev->conf->nss, GPIO_OUT); gpio_set(dev->conf->nss); -#endif } +#endif pn532_reset(dev); @@ -172,15 +175,15 @@ static int _write(const pn532_t *dev, uint8_t *buff, unsigned len) (void)buff; (void)len; - if (dev->mode == PN532_I2C) { #ifdef PN532_SUPPORT_I2C + if (dev->mode == PN532_I2C) { i2c_acquire(dev->conf->i2c); ret = i2c_write_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len); i2c_release(dev->conf->i2c); -#endif } - else { +#endif #ifdef PN532_SUPPORT_SPI + if (dev->mode != PN532_I2C) { spi_acquire(dev->conf->spi, SPI_CS_UNDEF, SPI_MODE, SPI_CLK); gpio_clear(dev->conf->nss); xtimer_usleep(SPI_WRITE_DELAY_US); @@ -190,8 +193,8 @@ static int _write(const pn532_t *dev, uint8_t *buff, unsigned len) gpio_set(dev->conf->nss); spi_release(dev->conf->spi); ret = (int)len; -#endif } +#endif DEBUG("pn532: -> "); PRINTBUFF(buff, len); return ret; @@ -204,16 +207,16 @@ static int _read(const pn532_t *dev, uint8_t *buff, unsigned len) (void)buff; (void)len; - if (dev->mode == PN532_I2C) { #ifdef PN532_SUPPORT_I2C + if (dev->mode == PN532_I2C) { i2c_acquire(dev->conf->i2c); /* len+1 for RDY after read is accepted */ ret = i2c_read_bytes(dev->conf->i2c, PN532_I2C_ADDRESS, buff, len + 1); i2c_release(dev->conf->i2c); -#endif } - else { +#endif #ifdef PN532_SUPPORT_SPI + if (dev->mode != PN532_I2C) { spi_acquire(dev->conf->spi, SPI_CS_UNDEF, SPI_MODE, SPI_CLK); gpio_clear(dev->conf->nss); spi_transfer_byte(dev->conf->spi, SPI_CS_UNDEF, true, SPI_DATA_READ); @@ -224,8 +227,8 @@ static int _read(const pn532_t *dev, uint8_t *buff, unsigned len) buff[0] = 0x80; reverse(buff, len); ret = (int)len + 1; -#endif } +#endif DEBUG("pn532: <- "); PRINTBUFF(buff, len); return ret; diff --git a/drivers/pulse_counter/pulse_counter.c b/drivers/pulse_counter/pulse_counter.c index 0a8fc10d612c..088ba664be24 100644 --- a/drivers/pulse_counter/pulse_counter.c +++ b/drivers/pulse_counter/pulse_counter.c @@ -26,6 +26,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + /* Accumulate pulse count */ static void pulse_counter_trigger(void *arg) { @@ -46,7 +49,8 @@ int pulse_counter_init(pulse_counter_t *dev, const pulse_counter_params_t *param gpio_mode = GPIO_IN_PD; } - if (gpio_init_int(params->gpio, gpio_mode, params->gpio_flank, pulse_counter_trigger, dev)) { + if (gpio_init_int(GPIO_GET_ALLOC(0), params->gpio, gpio_mode, + params->gpio_flank, pulse_counter_trigger, dev)) { return -1; } diff --git a/drivers/sx127x/sx127x.c b/drivers/sx127x/sx127x.c index e7347d2d0e34..37612560840c 100644 --- a/drivers/sx127x/sx127x.c +++ b/drivers/sx127x/sx127x.c @@ -40,6 +40,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(4); + /* Internal functions */ static int _init_spi(sx127x_t *dev); static int _init_gpios(sx127x_t *dev); @@ -210,29 +213,29 @@ static void sx127x_on_dio3_isr(void *arg) /* Internal event handlers */ static int _init_gpios(sx127x_t *dev) { - int res = gpio_init_int(dev->params.dio0_pin, GPIO_IN, GPIO_RISING, - sx127x_on_dio0_isr, dev); + int res = gpio_init_int(GPIO_GET_ALLOC(0), dev->params.dio0_pin, GPIO_IN, + GPIO_RISING, sx127x_on_dio0_isr, dev); if (res < 0) { DEBUG("[sx127x] error: failed to initialize DIO0 pin\n"); return res; } - res = gpio_init_int(dev->params.dio1_pin, GPIO_IN, GPIO_RISING, - sx127x_on_dio1_isr, dev); + res = gpio_init_int(GPIO_GET_ALLOC(1), dev->params.dio1_pin, GPIO_IN, + GPIO_RISING, sx127x_on_dio1_isr, dev); if (res < 0) { DEBUG("[sx127x] error: failed to initialize DIO1 pin\n"); return res; } - res = gpio_init_int(dev->params.dio2_pin, GPIO_IN, GPIO_RISING, - sx127x_on_dio2_isr, dev); + res = gpio_init_int(GPIO_GET_ALLOC(2), dev->params.dio2_pin, GPIO_IN, + GPIO_RISING, sx127x_on_dio2_isr, dev); if (res < 0) { DEBUG("[sx127x] error: failed to initialize DIO2 pin\n"); return res; } - res = gpio_init_int(dev->params.dio3_pin, GPIO_IN, GPIO_RISING, - sx127x_on_dio3_isr, dev); + res = gpio_init_int(GPIO_GET_ALLOC(3), dev->params.dio3_pin, GPIO_IN, + GPIO_RISING, sx127x_on_dio3_isr, dev); if (res < 0) { DEBUG("[sx127x] error: failed to initialize DIO3 pin\n"); return res; diff --git a/drivers/w5100/w5100.c b/drivers/w5100/w5100.c index e391752fa996..2806dc4cdfdb 100644 --- a/drivers/w5100/w5100.c +++ b/drivers/w5100/w5100.c @@ -45,6 +45,9 @@ static const netdev_driver_t netdev_driver_w5100; +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static inline void send_addr(w5100_t *dev, uint16_t addr) { #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ @@ -123,7 +126,8 @@ void w5100_setup(w5100_t *dev, const w5100_params_t *params) /* initialize the chip select pin and the external interrupt pin */ spi_init_cs(dev->p.spi, dev->p.cs); - gpio_init_int(dev->p.evt, GPIO_IN, GPIO_FALLING, extint, dev); + gpio_init_int(GPIO_GET_ALLOC(0), dev->p.evt, GPIO_IN, + GPIO_FALLING, extint, dev); } static int init(netdev_t *netdev) diff --git a/tests/buttons/main.c b/tests/buttons/main.c index de18b9528dac..795889ed157b 100644 --- a/tests/buttons/main.c +++ b/tests/buttons/main.c @@ -27,6 +27,9 @@ #define TEST_FLANK GPIO_FALLING +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(4); + #ifdef BTN0_PIN /* assuming that first button is always BTN0 */ static void cb(void *arg) { @@ -39,28 +42,32 @@ int main(void) int cnt = 0; /* get the number of available buttons and init interrupt handler */ #ifdef BTN0_PIN - if (gpio_init_int(BTN0_PIN, BTN0_MODE, TEST_FLANK, cb, (void *)cnt) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(0), BTN0_PIN, BTN0_MODE, + TEST_FLANK, cb, (void *)cnt) < 0) { puts("[FAILED] init BTN0!"); return 1; } ++cnt; #endif #ifdef BTN1_PIN - if (gpio_init_int(BTN1_PIN, BTN1_MODE, TEST_FLANK, cb, (void *)cnt) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(1), BTN1_PIN, BTN1_MODE, + TEST_FLANK, cb, (void *)cnt) < 0) { puts("[FAILED] init BTN1!"); return 1; } ++cnt; #endif #ifdef BTN2_PIN - if (gpio_init_int(BTN2_PIN, BTN2_MODE, TEST_FLANK, cb, (void *)cnt) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(2), BTN2_PIN, BTN2_MODE, + TEST_FLANK, cb, (void *)cnt) < 0) { puts("[FAILED] init BTN2!"); return 1; } ++cnt; #endif #ifdef BTN3_PIN - if (gpio_init_int(BTN3_PIN, BTN3_MODE, TEST_FLANK, cb, (void *)cnt) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(3), BTN3_PIN, BTN3_MODE, + TEST_FLANK, cb, (void *)cnt) < 0) { puts("[FAILED] init BTN3!"); return 1; } diff --git a/tests/cb_mux/main.c b/tests/cb_mux/main.c index 872834ed7b57..be81ab75ce27 100644 --- a/tests/cb_mux/main.c +++ b/tests/cb_mux/main.c @@ -53,7 +53,7 @@ int main(void) for (num = 0; num < 5; num++) { entries[num].cb = cb; - entries[num].arg = (void *)num; + entries[num].arg = (void *)(uintptr_t)num; entries[num].cbid = num; } @@ -114,7 +114,7 @@ int main(void) while (num < 5) { cb_mux_add(&cb_mux_head, &(entries[num])); - printf("Added entry %i\n", num); + printf("Added entry %u\n", (unsigned)num); num = cb_mux_find_free_id(cb_mux_head); } @@ -125,7 +125,7 @@ int main(void) for (num = 0; num < 5; num++) { if ((uintptr_t)entries[num].info & (1 << ITER_TEST)) { - printf("Entry %i was updated correctly\n", num); + printf("Entry %u was updated correctly\n", (unsigned)num); } } diff --git a/tests/driver_lis3dh/main.c b/tests/driver_lis3dh/main.c index 7abe5e3601d4..c13fb2fa4646 100644 --- a/tests/driver_lis3dh/main.c +++ b/tests/driver_lis3dh/main.c @@ -33,6 +33,9 @@ static volatile int int1_count = 0; +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void test_int1(void *arg) { volatile int *int1_count_ptr = arg; @@ -110,8 +113,8 @@ int main(void) } puts("Set INT1 callback"); - if (gpio_init_int(lis3dh_params[0].int1, GPIO_IN, GPIO_RISING, - test_int1, (void*)&int1_count) == 0) { + if (gpio_init_int(GPIO_GET_ALLOC(0), lis3dh_params[0].int1, GPIO_IN, + GPIO_RISING, test_int1, (void*)&int1_count) == 0) { puts("[OK]"); } else { diff --git a/tests/periph_gpio/main.c b/tests/periph_gpio/main.c index 56bfd33b831f..f46bdb2cea07 100644 --- a/tests/periph_gpio/main.c +++ b/tests/periph_gpio/main.c @@ -28,6 +28,9 @@ #define BENCH_RUNS_DEFAULT (1000UL * 1000) +/* Memory allocation for GPIO interrupt entry (if enabled) */ +GPIO_ALLOC_INT(1); + static void cb(void *arg) { printf("INT: external interrupt from pin %i\n", (int)arg); @@ -140,7 +143,8 @@ static int init_int(int argc, char **argv) } } - if (gpio_init_int(GPIO_PIN(po, pi), mode, flank, cb, (void *)pi) < 0) { + if (gpio_init_int(GPIO_GET_ALLOC(0), GPIO_PIN(po, pi), mode, + flank, cb, (void *)pi) < 0) { printf("error: init_int of GPIO_PIN(%i, %i) failed\n", po, pi); return 1; }