machine: rename PinInputPullUp/PinInputPullDown

Some targets used capital PullUp/PullDown, while the documented standard
is Pullup/Pulldown. This commit fixes this mismatch, while preserving
compatibility with aliases that are marked deprecated.
This commit is contained in:
Ayke van Laethem
2022-09-18 18:11:54 +02:00
committed by Ron Evans
parent 6e6666519c
commit bc946f346d
5 changed files with 35 additions and 17 deletions
+10 -4
View File
@@ -23,11 +23,17 @@ type PinChange uint8
// Pin modes.
const (
PinInput PinMode = iota
PinInputPullUp
PinInputPullDown
PinInputPullup
PinInputPulldown
PinOutput
)
// Deprecated: use PinInputPullup and PinInputPulldown instead.
const (
PinInputPullUp = PinInputPullup
PinInputPullDown = PinInputPulldown
)
// FPIOA internal pull resistors.
const (
fpioaPullNone fpioaPullMode = iota
@@ -89,10 +95,10 @@ func (p Pin) Configure(config PinConfig) {
case PinInput:
p.setFPIOAIOPull(fpioaPullNone)
input = true
case PinInputPullUp:
case PinInputPullup:
p.setFPIOAIOPull(fpioaPullUp)
input = true
case PinInputPullDown:
case PinInputPulldown:
p.setFPIOAIOPull(fpioaPullDown)
input = true
case PinOutput:
+11 -5
View File
@@ -21,8 +21,8 @@ func CPUFrequency() uint32 {
const (
// GPIO
PinInput PinMode = iota
PinInputPullUp
PinInputPullDown
PinInputPullup
PinInputPulldown
PinOutput
PinOutputOpenDrain
PinDisable
@@ -45,6 +45,12 @@ const (
PinModeI2CSCL
)
// Deprecated: use PinInputPullup and PinInputPulldown instead.
const (
PinInputPullUp = PinInputPullup
PinInputPullDown = PinInputPulldown
)
type PinChange uint8
const (
@@ -259,11 +265,11 @@ func (p Pin) Configure(config PinConfig) {
gpio.GDIR.ClearBits(p.getMask())
pad.Set(dse(7))
case PinInputPullUp:
case PinInputPullup:
gpio.GDIR.ClearBits(p.getMask())
pad.Set(dse(7) | pke | pue | pup(3) | hys)
case PinInputPullDown:
case PinInputPulldown:
gpio.GDIR.ClearBits(p.getMask())
pad.Set(dse(7) | pke | pue | hys)
@@ -746,7 +752,7 @@ func (p Pin) getMuxMode(config PinConfig) uint32 {
switch config.Mode {
// GPIO
case PinInput, PinInputPullUp, PinInputPullDown,
case PinInput, PinInputPullup, PinInputPulldown,
PinOutput, PinOutputOpenDrain, PinDisable:
mode := uint32(0x5) // GPIO is always alternate function 5
if forcePath {
+2 -2
View File
@@ -159,8 +159,8 @@ func (uart *UART) Disable() {
uart.Bus.CTRL.ClearBits(nxp.LPUART_CTRL_TE | nxp.LPUART_CTRL_RE)
// put pins back into GPIO mode
uart.rx.Configure(PinConfig{Mode: PinInputPullUp})
uart.tx.Configure(PinConfig{Mode: PinInputPullUp})
uart.rx.Configure(PinConfig{Mode: PinInputPullup})
uart.tx.Configure(PinConfig{Mode: PinInputPullup})
}
uart.configured = false
}
+10 -4
View File
@@ -42,13 +42,19 @@ const deviceName = nxp.Device
const (
PinInput PinMode = iota
PinInputPullUp
PinInputPullDown
PinInputPullup
PinInputPulldown
PinOutput
PinOutputOpenDrain
PinDisable
)
// Deprecated: use PinInputPullup and PinInputPulldown instead.
const (
PinInputPullUp = PinInputPullup
PinInputPullDown = PinInputPulldown
)
const (
PA00 Pin = iota
PA01
@@ -223,11 +229,11 @@ func (p Pin) Configure(config PinConfig) {
gpio.PDDR.ClearBits(1 << pos)
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos))
case PinInputPullUp:
case PinInputPullup:
gpio.PDDR.ClearBits(1 << pos)
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE | nxp.PORT_PCR0_PS)
case PinInputPullDown:
case PinInputPulldown:
gpio.PDDR.ClearBits(1 << pos)
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE)
+2 -2
View File
@@ -203,8 +203,8 @@ func (u *UART) Disable() {
u.C2.Set(0)
// reconfigure pin
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullUp})
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullUp})
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullup})
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullup})
// clear flags
u.S1.Get()