Skip to content

Commit

Permalink
[sam] Do not reset peripheral mode in configure(InputMode) for SAM D21
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-durand committed Feb 9, 2022
1 parent 148f1f2 commit c868f59
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/modm/platform/gpio/sam/pin.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ template<class... PinConfigs>
struct PinCfgMixin
{
inline static void set(uint8_t){};
inline static void set(uint8_t, uint8_t){};
};

template<class PinConfig, class... PinConfigs>
Expand All @@ -292,6 +293,18 @@ struct PinCfgMixin<PinConfig, PinConfigs...>
%% endfor
PinCfgMixin<PinConfigs...>::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<PinConfigs...>::set(setBits, clearMask);
}
};

template<class... PinConfigs>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c868f59

Please sign in to comment.