Skip to content

Commit c868f59

Browse files
committed
[sam] Do not reset peripheral mode in configure(InputMode) for SAM D21
1 parent 148f1f2 commit c868f59

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/modm/platform/gpio/sam/pin.hpp.in

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ template<class... PinConfigs>
278278
struct PinCfgMixin
279279
{
280280
inline static void set(uint8_t){};
281+
inline static void set(uint8_t, uint8_t){};
281282
};
282283

283284
template<class PinConfig, class... PinConfigs>
@@ -292,6 +293,18 @@ struct PinCfgMixin<PinConfig, PinConfigs...>
292293
%% endfor
293294
PinCfgMixin<PinConfigs...>::set(cfg);
294295
}
296+
297+
inline static void
298+
set(uint8_t setBits, uint8_t clearMask)
299+
{
300+
%% for port in ports
301+
if constexpr (PinConfig::port == PortName::{{ port }}) {
302+
auto& reg = PORT->Group[{{loop.index0}}].PINCFG[PinConfig::pin].reg;
303+
reg = (reg & (~clearMask)) | setBits;
304+
}
305+
%% endfor
306+
PinCfgMixin<PinConfigs...>::set(setBits, clearMask);
307+
}
295308
};
296309

297310
template<class... PinConfigs>
@@ -371,7 +384,7 @@ public:
371384
configure(InputType type)
372385
{
373386
set(type == InputType::PullUp);
374-
PinCfg::set(PORT_PINCFG_INEN | (type != InputType::Floating) << PORT_PINCFG_PULLEN_Pos);
387+
PinCfg::set(PORT_PINCFG_INEN | (type != InputType::Floating) << PORT_PINCFG_PULLEN_Pos, PORT_PINCFG_PULLEN);
375388
}
376389

377390
static void

0 commit comments

Comments
 (0)