machine: hide internal pin modes

Many pin modes are only for peripherals like SPI and PWM. Do not make
these part of the public API: the public API is the Configure method on
the peripheral, not the PinMode constant.
This commit is contained in:
Ayke van Laethem
2022-09-26 18:27:55 +02:00
parent fca2de21b1
commit 3b68f8f16a
30 changed files with 223 additions and 221 deletions
+12 -10
View File
@@ -81,11 +81,13 @@ const (
PinInput
PinInputPulldown
PinInputPullup
PinAnalog
PinUART
PinPWM
PinI2C
PinSPI
// internal pin modes
pinAnalog
pinUART
pinPWM
pinI2C
pinSPI
)
func (p Pin) PortMaskSet() (*uint32, uint32) {
@@ -188,20 +190,20 @@ func (p Pin) Configure(config PinConfig) {
case PinInputPullup:
p.setFunc(fnSIO)
p.pullup()
case PinAnalog:
case pinAnalog:
p.setFunc(fnNULL)
p.pulloff()
case PinUART:
case pinUART:
p.setFunc(fnUART)
case PinPWM:
case pinPWM:
p.setFunc(fnPWM)
case PinI2C:
case pinI2C:
// IO config according to 4.3.1.3 of rp2040 datasheet.
p.setFunc(fnI2C)
p.pullup()
p.setSchmitt(true)
p.setSlew(false)
case PinSPI:
case pinSPI:
p.setFunc(fnSPI)
}
}