Skip to content

Commit a0b892b

Browse files
pabigotcarlescufi
authored andcommitted
tests: gpio_basic_api: fix misplacement of debounce flag
The debounce flag is to be provided to the pin configuration, not the pin interrupt configuration. Signed-off-by: Peter Bigot <[email protected]>
1 parent 59a97c6 commit a0b892b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

include/drivers/gpio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,7 @@ static inline int gpio_pin_configure(struct device *port, u32_t pin,
687687
data->invert &= ~BIT(pin);
688688
}
689689
if (api->pin_interrupt_configure) {
690+
flags &= ~GPIO_INT_DEBOUNCE;
690691
ret = z_impl_gpio_pin_interrupt_configure(port, pin, flags);
691692
}
692693

tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ static int init_callback(struct device *dev,
5555

5656
if (rc == 0) {
5757
/* 2. configure PIN_IN callback, but don't enable */
58-
rc = gpio_pin_configure(dev, PIN_IN, GPIO_INPUT);
58+
rc = gpio_pin_configure(dev, PIN_IN,
59+
GPIO_INPUT | GPIO_INT_DEBOUNCE);
5960
}
6061

6162
if (rc == 0) {
@@ -79,9 +80,7 @@ static void trigger_callback(struct device *dev, int enable_cb)
7980
cb_cnt[0] = 0;
8081
cb_cnt[1] = 0;
8182
if (enable_cb == 1) {
82-
gpio_pin_interrupt_configure(dev, PIN_IN,
83-
GPIO_INT_EDGE_RISING
84-
| GPIO_INT_DEBOUNCE);
83+
gpio_pin_interrupt_configure(dev, PIN_IN, GPIO_INT_EDGE_RISING);
8584
} else {
8685
gpio_pin_interrupt_configure(dev, PIN_IN, GPIO_INT_DISABLE);
8786
}

tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static int test_callback(int mode)
7171
}
7272

7373
/* 2. configure PIN_IN callback and trigger condition */
74-
rc = gpio_pin_configure(dev, PIN_IN, GPIO_INPUT);
74+
rc = gpio_pin_configure(dev, PIN_IN, GPIO_INPUT | GPIO_INT_DEBOUNCE);
7575
if (rc != 0) {
7676
TC_ERROR("config PIN_IN fail: %d\n", rc);
7777
goto err_exit;
@@ -90,7 +90,7 @@ static int test_callback(int mode)
9090

9191
/* 3. enable callback, trigger PIN_IN interrupt by operate PIN_OUT */
9292
cb_cnt = 0;
93-
rc = gpio_pin_interrupt_configure(dev, PIN_IN, mode | GPIO_INT_DEBOUNCE);
93+
rc = gpio_pin_interrupt_configure(dev, PIN_IN, mode);
9494
if (rc == -ENOTSUP) {
9595
TC_PRINT("Mode %x not supported\n", mode);
9696
goto pass_exit;

0 commit comments

Comments
 (0)