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.
Этот коммит содержится в:
родитель
6e6666519c
коммит
bc946f346d
5 изменённых файлов: 35 добавлений и 17 удалений
|
@ -23,11 +23,17 @@ type PinChange uint8
|
||||||
// Pin modes.
|
// Pin modes.
|
||||||
const (
|
const (
|
||||||
PinInput PinMode = iota
|
PinInput PinMode = iota
|
||||||
PinInputPullUp
|
PinInputPullup
|
||||||
PinInputPullDown
|
PinInputPulldown
|
||||||
PinOutput
|
PinOutput
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Deprecated: use PinInputPullup and PinInputPulldown instead.
|
||||||
|
const (
|
||||||
|
PinInputPullUp = PinInputPullup
|
||||||
|
PinInputPullDown = PinInputPulldown
|
||||||
|
)
|
||||||
|
|
||||||
// FPIOA internal pull resistors.
|
// FPIOA internal pull resistors.
|
||||||
const (
|
const (
|
||||||
fpioaPullNone fpioaPullMode = iota
|
fpioaPullNone fpioaPullMode = iota
|
||||||
|
@ -89,10 +95,10 @@ func (p Pin) Configure(config PinConfig) {
|
||||||
case PinInput:
|
case PinInput:
|
||||||
p.setFPIOAIOPull(fpioaPullNone)
|
p.setFPIOAIOPull(fpioaPullNone)
|
||||||
input = true
|
input = true
|
||||||
case PinInputPullUp:
|
case PinInputPullup:
|
||||||
p.setFPIOAIOPull(fpioaPullUp)
|
p.setFPIOAIOPull(fpioaPullUp)
|
||||||
input = true
|
input = true
|
||||||
case PinInputPullDown:
|
case PinInputPulldown:
|
||||||
p.setFPIOAIOPull(fpioaPullDown)
|
p.setFPIOAIOPull(fpioaPullDown)
|
||||||
input = true
|
input = true
|
||||||
case PinOutput:
|
case PinOutput:
|
||||||
|
|
|
@ -21,8 +21,8 @@ func CPUFrequency() uint32 {
|
||||||
const (
|
const (
|
||||||
// GPIO
|
// GPIO
|
||||||
PinInput PinMode = iota
|
PinInput PinMode = iota
|
||||||
PinInputPullUp
|
PinInputPullup
|
||||||
PinInputPullDown
|
PinInputPulldown
|
||||||
PinOutput
|
PinOutput
|
||||||
PinOutputOpenDrain
|
PinOutputOpenDrain
|
||||||
PinDisable
|
PinDisable
|
||||||
|
@ -45,6 +45,12 @@ const (
|
||||||
PinModeI2CSCL
|
PinModeI2CSCL
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Deprecated: use PinInputPullup and PinInputPulldown instead.
|
||||||
|
const (
|
||||||
|
PinInputPullUp = PinInputPullup
|
||||||
|
PinInputPullDown = PinInputPulldown
|
||||||
|
)
|
||||||
|
|
||||||
type PinChange uint8
|
type PinChange uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -259,11 +265,11 @@ func (p Pin) Configure(config PinConfig) {
|
||||||
gpio.GDIR.ClearBits(p.getMask())
|
gpio.GDIR.ClearBits(p.getMask())
|
||||||
pad.Set(dse(7))
|
pad.Set(dse(7))
|
||||||
|
|
||||||
case PinInputPullUp:
|
case PinInputPullup:
|
||||||
gpio.GDIR.ClearBits(p.getMask())
|
gpio.GDIR.ClearBits(p.getMask())
|
||||||
pad.Set(dse(7) | pke | pue | pup(3) | hys)
|
pad.Set(dse(7) | pke | pue | pup(3) | hys)
|
||||||
|
|
||||||
case PinInputPullDown:
|
case PinInputPulldown:
|
||||||
gpio.GDIR.ClearBits(p.getMask())
|
gpio.GDIR.ClearBits(p.getMask())
|
||||||
pad.Set(dse(7) | pke | pue | hys)
|
pad.Set(dse(7) | pke | pue | hys)
|
||||||
|
|
||||||
|
@ -746,7 +752,7 @@ func (p Pin) getMuxMode(config PinConfig) uint32 {
|
||||||
switch config.Mode {
|
switch config.Mode {
|
||||||
|
|
||||||
// GPIO
|
// GPIO
|
||||||
case PinInput, PinInputPullUp, PinInputPullDown,
|
case PinInput, PinInputPullup, PinInputPulldown,
|
||||||
PinOutput, PinOutputOpenDrain, PinDisable:
|
PinOutput, PinOutputOpenDrain, PinDisable:
|
||||||
mode := uint32(0x5) // GPIO is always alternate function 5
|
mode := uint32(0x5) // GPIO is always alternate function 5
|
||||||
if forcePath {
|
if forcePath {
|
||||||
|
|
|
@ -159,8 +159,8 @@ func (uart *UART) Disable() {
|
||||||
uart.Bus.CTRL.ClearBits(nxp.LPUART_CTRL_TE | nxp.LPUART_CTRL_RE)
|
uart.Bus.CTRL.ClearBits(nxp.LPUART_CTRL_TE | nxp.LPUART_CTRL_RE)
|
||||||
|
|
||||||
// put pins back into GPIO mode
|
// put pins back into GPIO mode
|
||||||
uart.rx.Configure(PinConfig{Mode: PinInputPullUp})
|
uart.rx.Configure(PinConfig{Mode: PinInputPullup})
|
||||||
uart.tx.Configure(PinConfig{Mode: PinInputPullUp})
|
uart.tx.Configure(PinConfig{Mode: PinInputPullup})
|
||||||
}
|
}
|
||||||
uart.configured = false
|
uart.configured = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,13 +42,19 @@ const deviceName = nxp.Device
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PinInput PinMode = iota
|
PinInput PinMode = iota
|
||||||
PinInputPullUp
|
PinInputPullup
|
||||||
PinInputPullDown
|
PinInputPulldown
|
||||||
PinOutput
|
PinOutput
|
||||||
PinOutputOpenDrain
|
PinOutputOpenDrain
|
||||||
PinDisable
|
PinDisable
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Deprecated: use PinInputPullup and PinInputPulldown instead.
|
||||||
|
const (
|
||||||
|
PinInputPullUp = PinInputPullup
|
||||||
|
PinInputPullDown = PinInputPulldown
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
PA00 Pin = iota
|
PA00 Pin = iota
|
||||||
PA01
|
PA01
|
||||||
|
@ -223,11 +229,11 @@ func (p Pin) Configure(config PinConfig) {
|
||||||
gpio.PDDR.ClearBits(1 << pos)
|
gpio.PDDR.ClearBits(1 << pos)
|
||||||
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos))
|
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos))
|
||||||
|
|
||||||
case PinInputPullUp:
|
case PinInputPullup:
|
||||||
gpio.PDDR.ClearBits(1 << pos)
|
gpio.PDDR.ClearBits(1 << pos)
|
||||||
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE | nxp.PORT_PCR0_PS)
|
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)
|
gpio.PDDR.ClearBits(1 << pos)
|
||||||
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE)
|
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE)
|
||||||
|
|
||||||
|
|
|
@ -203,8 +203,8 @@ func (u *UART) Disable() {
|
||||||
u.C2.Set(0)
|
u.C2.Set(0)
|
||||||
|
|
||||||
// reconfigure pin
|
// reconfigure pin
|
||||||
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullUp})
|
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullup})
|
||||||
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullUp})
|
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullup})
|
||||||
|
|
||||||
// clear flags
|
// clear flags
|
||||||
u.S1.Get()
|
u.S1.Get()
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче