From bc946f346dc2c0f718e7fd826c139b353f0b15f0 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Sun, 18 Sep 2022 18:11:54 +0200 Subject: [PATCH] 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. --- src/machine/machine_k210.go | 14 ++++++++++---- src/machine/machine_mimxrt1062.go | 16 +++++++++++----- src/machine/machine_mimxrt1062_uart.go | 4 ++-- src/machine/machine_nxpmk66f18.go | 14 ++++++++++---- src/machine/machine_nxpmk66f18_uart.go | 4 ++-- 5 files changed, 35 insertions(+), 17 deletions(-) diff --git a/src/machine/machine_k210.go b/src/machine/machine_k210.go index 1a622f0c..7a453195 100644 --- a/src/machine/machine_k210.go +++ b/src/machine/machine_k210.go @@ -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: diff --git a/src/machine/machine_mimxrt1062.go b/src/machine/machine_mimxrt1062.go index 3e20bd67..acac9501 100644 --- a/src/machine/machine_mimxrt1062.go +++ b/src/machine/machine_mimxrt1062.go @@ -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 { diff --git a/src/machine/machine_mimxrt1062_uart.go b/src/machine/machine_mimxrt1062_uart.go index 98bf477b..c366fd45 100644 --- a/src/machine/machine_mimxrt1062_uart.go +++ b/src/machine/machine_mimxrt1062_uart.go @@ -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 } diff --git a/src/machine/machine_nxpmk66f18.go b/src/machine/machine_nxpmk66f18.go index a8257b0b..af6d7f1f 100644 --- a/src/machine/machine_nxpmk66f18.go +++ b/src/machine/machine_nxpmk66f18.go @@ -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) diff --git a/src/machine/machine_nxpmk66f18_uart.go b/src/machine/machine_nxpmk66f18_uart.go index ccbb18ed..742ee312 100644 --- a/src/machine/machine_nxpmk66f18_uart.go +++ b/src/machine/machine_nxpmk66f18_uart.go @@ -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()