mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-17 21:23:58 +00:00
revision: modify proposed pin HAL.
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
//go:build baremetal
|
||||
|
||||
package pin
|
||||
|
||||
import "machine"
|
||||
|
||||
func configureOutput(p Output) {
|
||||
configure(p, machine.PinOutput)
|
||||
}
|
||||
|
||||
func configureInputPulldown(p Input) {
|
||||
configure(p, pulldown) // some chips do not have pull down, in which case pulldown==machine.PinInput.
|
||||
}
|
||||
|
||||
func configureInput(p Input) {
|
||||
configure(p, machine.PinInput)
|
||||
}
|
||||
|
||||
func configureInputPullup(p Input) {
|
||||
configure(p, pullup) // some chips do not have pull up, in which case pullup==machine.PinInput.
|
||||
}
|
||||
|
||||
func isNotPin(a any) bool {
|
||||
p, ok := a.(machine.Pin)
|
||||
return ok && p == machine.NoPin
|
||||
}
|
||||
|
||||
func configure(p any, mode machine.PinMode) {
|
||||
machinePin, ok := p.(machine.Pin)
|
||||
if ok {
|
||||
machinePin.Configure(machine.PinConfig{Mode: mode})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user