From 06a05370a203bc45a48c953910df2e2a3d9ea599 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Tue, 23 Jan 2024 08:15:28 +0100 Subject: [PATCH] cpu/sam0_common: Implement gpio_ll_switch_dir --- cpu/sam0_common/Makefile.features | 1 + cpu/sam0_common/include/gpio_ll_arch.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/cpu/sam0_common/Makefile.features b/cpu/sam0_common/Makefile.features index 8915115c6bc3..184942584b19 100644 --- a/cpu/sam0_common/Makefile.features +++ b/cpu/sam0_common/Makefile.features @@ -21,6 +21,7 @@ FEATURES_PROVIDED += periph_gpio_ll_irq FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_high FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low FEATURES_PROVIDED += periph_gpio_ll_irq_unmask +FEATURES_PROVIDED += periph_gpio_ll_switch_dir FEATURES_PROVIDED += periph_i2c_reconfigure FEATURES_PROVIDED += periph_rtt_overflow FEATURES_PROVIDED += periph_rtt_set_counter diff --git a/cpu/sam0_common/include/gpio_ll_arch.h b/cpu/sam0_common/include/gpio_ll_arch.h index 8f72b1997cd2..02b25c7c1e1f 100644 --- a/cpu/sam0_common/include/gpio_ll_arch.h +++ b/cpu/sam0_common/include/gpio_ll_arch.h @@ -106,6 +106,18 @@ static inline void gpio_ll_write(gpio_port_t port, uword_t mask) p->OUT.reg = mask; } +static inline void gpio_ll_switch_dir_output(gpio_port_t port, uword_t outputs) +{ + PortGroup *p = (PortGroup *)port; + p->DIRSET.reg = outputs; +} + +static inline void gpio_ll_switch_dir_input(gpio_port_t port, uword_t inputs) +{ + PortGroup *p = (PortGroup *)port; + p->DIRCLR.reg = inputs; +} + static inline gpio_port_t gpio_get_port(gpio_t pin) { return (gpio_port_t)(pin & ~(0x1f));