From c868f59fdf1272e327b16e6cffdecd0faad9cc0a Mon Sep 17 00:00:00 2001 From: Christopher Durand Date: Tue, 8 Feb 2022 01:40:43 +0100 Subject: [PATCH] [sam] Do not reset peripheral mode in configure(InputMode) for SAM D21 --- src/modm/platform/gpio/sam/pin.hpp.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/modm/platform/gpio/sam/pin.hpp.in b/src/modm/platform/gpio/sam/pin.hpp.in index 3b1ceb3534..bbd4095f0a 100644 --- a/src/modm/platform/gpio/sam/pin.hpp.in +++ b/src/modm/platform/gpio/sam/pin.hpp.in @@ -278,6 +278,7 @@ template struct PinCfgMixin { inline static void set(uint8_t){}; + inline static void set(uint8_t, uint8_t){}; }; template @@ -292,6 +293,18 @@ struct PinCfgMixin %% endfor PinCfgMixin::set(cfg); } + + inline static void + set(uint8_t setBits, uint8_t clearMask) + { +%% for port in ports + if constexpr (PinConfig::port == PortName::{{ port }}) { + auto& reg = PORT->Group[{{loop.index0}}].PINCFG[PinConfig::pin].reg; + reg = (reg & (~clearMask)) | setBits; + } +%% endfor + PinCfgMixin::set(setBits, clearMask); + } }; template @@ -371,7 +384,7 @@ public: configure(InputType type) { set(type == InputType::PullUp); - PinCfg::set(PORT_PINCFG_INEN | (type != InputType::Floating) << PORT_PINCFG_PULLEN_Pos); + PinCfg::set(PORT_PINCFG_INEN | (type != InputType::Floating) << PORT_PINCFG_PULLEN_Pos, PORT_PINCFG_PULLEN); } static void