mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-17 11:13:27 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user