SAM GPIO: Apply Wolfgang's change for SAM3/4 to SAMA5 and SAMV7

This commit is contained in:
Gregory Nutt 2016-09-20 15:33:31 -06:00
parent 0441c53aec
commit 1c20376e39
3 changed files with 114 additions and 0 deletions

View File

@ -190,12 +190,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -286,6 +288,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -298,6 +308,12 @@ static inline int sam_configoutput(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
@ -357,6 +373,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -369,6 +393,12 @@ static inline int sam_configperiph(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

View File

@ -349,6 +349,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_CFG_PULLUP) != 0)
{
#ifdef PIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -361,6 +369,12 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_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
@ -464,6 +478,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_CFG_PULLUP) != 0)
{
#ifdef PIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -476,6 +498,12 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_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
@ -546,6 +574,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_CFG_PULLUP) != 0)
{
#ifdef PIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -558,6 +594,12 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
if ((cfgset & PIO_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

View File

@ -152,6 +152,14 @@ static inline int sam_configinput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -164,6 +172,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
@ -243,6 +257,14 @@ static inline int sam_configoutput(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -255,6 +277,12 @@ static inline int sam_configoutput(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
@ -330,6 +358,14 @@ static inline int sam_configperiph(uintptr_t base, uint32_t pin,
if ((cfgset & GPIO_CFG_PULLUP) != 0)
{
#ifdef GPIO_HAVE_PULLDOWN
/* 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);
#endif
putreg32(pin, base + SAM_PIO_PUER_OFFSET);
}
else
@ -342,6 +378,12 @@ static inline int sam_configperiph(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