1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 23:11:19 +01:00

nrf5x: Extend gpio with exti channel retrieval

This commit is contained in:
Koen Zandberg 2020-05-18 19:17:29 +02:00
parent 720ccad7dd
commit 99a59c5dbd
No known key found for this signature in database
GPG Key ID: 0895A893E6D2985B
2 changed files with 19 additions and 5 deletions

View File

@ -184,6 +184,16 @@ typedef struct {
#define NWDT_TIME_UPPER_LIMIT ((UINT32_MAX >> 15) * US_PER_MS + 1)
/** @} */
/**
* @brief Retrieve the exti(GPIOTE) channel associated with a gpio
*
* @param pin GPIO pin to retrieve the channel for
*
* @return the channel number
* @return 0xff if no channel is found
*/
uint8_t gpio_int_get_exti(gpio_t pin);
#ifdef __cplusplus
}
#endif

View File

@ -146,17 +146,21 @@ void gpio_write(gpio_t pin, int value)
}
#ifdef MODULE_PERIPH_GPIO_IRQ
int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
gpio_cb_t cb, void *arg)
uint8_t gpio_int_get_exti(gpio_t pin)
{
uint8_t _pin_index = 0xff;
/* Looking for already known pin in exti table */
for (unsigned int i = 0; i < _gpiote_next_index; i++) {
if (_exti_pins[i] == pin) {
_pin_index = i;
break;
return i;
}
}
return 0xff;
}
int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank,
gpio_cb_t cb, void *arg)
{
uint8_t _pin_index = gpio_int_get_exti(pin);
/* New pin */
if (_pin_index == 0xff) {