Skip to content

Commit

Permalink
[sam] GPIO setOutput overrides peripheral control
Browse files Browse the repository at this point in the history
Calling setOutput now overrides peripheral control of the pin. This
behavior is consistent with the STM32 GPIO implementation, this commit also
ensures output value is set before the output drive is enabled to prevent
glitch.
  • Loading branch information
mcbridejc committed Feb 8, 2022
1 parent 3f3ff3d commit cfbd963
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/modm/platform/gpio/sam/pin.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,26 @@ public:
inline static void
setOutput()
{
// Enable PIO control of the pin (disables peripheral control)
setPortReg(PIO_PER_OFFSET);
// Enable output driver
setPortReg(PIO_OER_OFFSET);
}

inline static void
setOutput(bool status)
{
setOutput();
set(status);
setOutput();
}

static void
setInput()
{
setPortReg(PIO_ODR_OFFSET); // Disable output driver
// Enable PIO control of the pin (disables peripheral control)
setPortReg(PIO_PER_OFFSET);
// Disable output driver
setPortReg(PIO_ODR_OFFSET);
}

static void
Expand Down

0 comments on commit cfbd963

Please sign in to comment.