From 0310c11c30a5282064136a5d08f762012d56c0a1 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 29 Jan 2024 23:31:33 +0100 Subject: [PATCH] Add support for GPIO input filtering activation --- drivers/gpio.c | 10 ++++++++++ include/drivers/gpio.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/drivers/gpio.c b/drivers/gpio.c index 99a49c6..c5ed653 100644 --- a/drivers/gpio.c +++ b/drivers/gpio.c @@ -76,6 +76,16 @@ void config_gpio(const struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini } } +/* + * This function enables filtering the GPIO input signal, using one of the filtering + * clock dividers which must be configured before calling this function by using the + * config_gpio_filtering_clk_divider() function. + */ +void config_gpio_add_filtering(const struct pio* gpio, uint8_t filt_cnt, uint8_t filt_clk) +{ + config_pio(gpio, LPC_IO_SAMPLE_MODE(filt_cnt) | LPC_IO_SAMPLE_CLK_DIV(filt_clk) | LPC_IO_DIGITAL); +} + /***************************************************************************** */ /* GPIO Interrupts Callbacks */ static void (*gpio_callbacks_port0[PORT0_NB_PINS]) (uint32_t); diff --git a/include/drivers/gpio.h b/include/drivers/gpio.h index 9d6a19b..18acdbf 100644 --- a/include/drivers/gpio.h +++ b/include/drivers/gpio.h @@ -138,6 +138,14 @@ static inline uint32_t gpio_read(const struct pio gpio) */ void config_gpio(const struct pio* gpio, uint32_t mode, uint8_t dir, uint8_t ini_val); +/* + * This function enables filtering the GPIO input signal, using one of the filtering + * clock dividers which must be configured before calling this function by using the + * config_gpio_filtering_clk_divider() function. + */ +void config_gpio_add_filtering(const struct pio* gpio, uint8_t filt_cnt, uint8_t filt_clk); + + /* GPIO Interrupts */ /* Add a callback on a GPIO interrupt. -- 2.43.0