1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/pulse_counter: make gpio_mode configurable

This commit is contained in:
Hyungsin 2018-06-19 13:05:07 -07:00
parent d49e0d2f79
commit 1b7345535c

View File

@ -38,7 +38,15 @@ static void pulse_counter_trigger(void *arg)
/* Initialize pulse counter */
int pulse_counter_init(pulse_counter_t *dev, const pulse_counter_params_t *params)
{
if (gpio_init_int(params->gpio, GPIO_IN_PU, params->gpio_flank, pulse_counter_trigger, dev)) {
gpio_mode_t gpio_mode;
if (params->gpio_flank == GPIO_FALLING) {
gpio_mode = GPIO_IN_PU;
}
else {
gpio_mode = GPIO_IN_PD;
}
if (gpio_init_int(params->gpio, gpio_mode, params->gpio_flank, pulse_counter_trigger, dev)) {
return -1;
}