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:
parent
720ccad7dd
commit
99a59c5dbd
@ -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
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user