Skip to content

Commit bc946f3

Browse files
aykevldeadprogram
authored andcommitted
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.
1 parent 6e66665 commit bc946f3

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

src/machine/machine_k210.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,17 @@ type PinChange uint8
2323
// Pin modes.
2424
const (
2525
PinInput PinMode = iota
26-
PinInputPullUp
27-
PinInputPullDown
26+
PinInputPullup
27+
PinInputPulldown
2828
PinOutput
2929
)
3030

31+
// Deprecated: use PinInputPullup and PinInputPulldown instead.
32+
const (
33+
PinInputPullUp = PinInputPullup
34+
PinInputPullDown = PinInputPulldown
35+
)
36+
3137
// FPIOA internal pull resistors.
3238
const (
3339
fpioaPullNone fpioaPullMode = iota
@@ -89,10 +95,10 @@ func (p Pin) Configure(config PinConfig) {
8995
case PinInput:
9096
p.setFPIOAIOPull(fpioaPullNone)
9197
input = true
92-
case PinInputPullUp:
98+
case PinInputPullup:
9399
p.setFPIOAIOPull(fpioaPullUp)
94100
input = true
95-
case PinInputPullDown:
101+
case PinInputPulldown:
96102
p.setFPIOAIOPull(fpioaPullDown)
97103
input = true
98104
case PinOutput:

src/machine/machine_mimxrt1062.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ func CPUFrequency() uint32 {
2121
const (
2222
// GPIO
2323
PinInput PinMode = iota
24-
PinInputPullUp
25-
PinInputPullDown
24+
PinInputPullup
25+
PinInputPulldown
2626
PinOutput
2727
PinOutputOpenDrain
2828
PinDisable
@@ -45,6 +45,12 @@ const (
4545
PinModeI2CSCL
4646
)
4747

48+
// Deprecated: use PinInputPullup and PinInputPulldown instead.
49+
const (
50+
PinInputPullUp = PinInputPullup
51+
PinInputPullDown = PinInputPulldown
52+
)
53+
4854
type PinChange uint8
4955

5056
const (
@@ -259,11 +265,11 @@ func (p Pin) Configure(config PinConfig) {
259265
gpio.GDIR.ClearBits(p.getMask())
260266
pad.Set(dse(7))
261267

262-
case PinInputPullUp:
268+
case PinInputPullup:
263269
gpio.GDIR.ClearBits(p.getMask())
264270
pad.Set(dse(7) | pke | pue | pup(3) | hys)
265271

266-
case PinInputPullDown:
272+
case PinInputPulldown:
267273
gpio.GDIR.ClearBits(p.getMask())
268274
pad.Set(dse(7) | pke | pue | hys)
269275

@@ -746,7 +752,7 @@ func (p Pin) getMuxMode(config PinConfig) uint32 {
746752
switch config.Mode {
747753

748754
// GPIO
749-
case PinInput, PinInputPullUp, PinInputPullDown,
755+
case PinInput, PinInputPullup, PinInputPulldown,
750756
PinOutput, PinOutputOpenDrain, PinDisable:
751757
mode := uint32(0x5) // GPIO is always alternate function 5
752758
if forcePath {

src/machine/machine_mimxrt1062_uart.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ func (uart *UART) Disable() {
159159
uart.Bus.CTRL.ClearBits(nxp.LPUART_CTRL_TE | nxp.LPUART_CTRL_RE)
160160

161161
// put pins back into GPIO mode
162-
uart.rx.Configure(PinConfig{Mode: PinInputPullUp})
163-
uart.tx.Configure(PinConfig{Mode: PinInputPullUp})
162+
uart.rx.Configure(PinConfig{Mode: PinInputPullup})
163+
uart.tx.Configure(PinConfig{Mode: PinInputPullup})
164164
}
165165
uart.configured = false
166166
}

src/machine/machine_nxpmk66f18.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@ const deviceName = nxp.Device
4242

4343
const (
4444
PinInput PinMode = iota
45-
PinInputPullUp
46-
PinInputPullDown
45+
PinInputPullup
46+
PinInputPulldown
4747
PinOutput
4848
PinOutputOpenDrain
4949
PinDisable
5050
)
5151

52+
// Deprecated: use PinInputPullup and PinInputPulldown instead.
53+
const (
54+
PinInputPullUp = PinInputPullup
55+
PinInputPullDown = PinInputPulldown
56+
)
57+
5258
const (
5359
PA00 Pin = iota
5460
PA01
@@ -223,11 +229,11 @@ func (p Pin) Configure(config PinConfig) {
223229
gpio.PDDR.ClearBits(1 << pos)
224230
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos))
225231

226-
case PinInputPullUp:
232+
case PinInputPullup:
227233
gpio.PDDR.ClearBits(1 << pos)
228234
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE | nxp.PORT_PCR0_PS)
229235

230-
case PinInputPullDown:
236+
case PinInputPulldown:
231237
gpio.PDDR.ClearBits(1 << pos)
232238
pcr.Set((1 << nxp.PORT_PCR0_MUX_Pos) | nxp.PORT_PCR0_PE)
233239

src/machine/machine_nxpmk66f18_uart.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,8 @@ func (u *UART) Disable() {
203203
u.C2.Set(0)
204204

205205
// reconfigure pin
206-
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullUp})
207-
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullUp})
206+
u.DefaultRX.Configure(PinConfig{Mode: PinInputPullup})
207+
u.DefaultTX.Configure(PinConfig{Mode: PinInputPullup})
208208

209209
// clear flags
210210
u.S1.Get()

0 commit comments

Comments
 (0)