SAM3/4: Fix GPIO pull-up/down code.

Enabling the pull-down resistor while the pull-up resistor is still enabled
is not possible. In this case, the write of PIO_PPDER for the relevant I/O
line is discarded. Likewise, enabling the pull-up resistor while the
pull-down resistor is still enabled is not possible. In this case, the
write of PIO_PUER for the relevant I/O line is discarded.
This commit is contained in:
Wolfgang Reißnegger 2016-09-20 13:24:39 -07:00
parent e5cffc40fc
commit 3f22b63321

View File

@ -190,6 +190,12 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
/* The pull-up on a pin can not be enabled if its pull-down is still
* active. Therefore, we need to disable the pull-down first before
* enabling the pull-up.
*/
putreg32(pin, base + SAM_PIO_PPDDR_OFFSET);
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -202,6 +208,12 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLDOWN) != 0)
{
/* The pull-down on a pin can not be enabled if its pull-up is still
* active. Therefore, we need to disable the pull-up first before
* enabling the pull-down.
*/
putreg32(pin, base + SAM_PIO_PUDR_OFFSET);
putreg32(pin, base + SAM_PIO_PPDER_OFFSET);
}
else