mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-07-26 10:38:41 +00:00
5fb935001e
* first commit: add HAL and uc8151 driver demo * unexport drivers.PinOutput/Input HAL * fix non-tinygo pin config build * change of heart * docs: corrected some comments that were not changed at the same time as recent renaming
38 lines
805 B
Go
38 lines
805 B
Go
//go:build baremetal
|
|
|
|
package legacy
|
|
|
|
import (
|
|
"machine"
|
|
|
|
"tinygo.org/x/drivers/internal/pin"
|
|
)
|
|
|
|
func configurePinOut(po pin.Output) {
|
|
configurePin(po, machine.PinOutput)
|
|
}
|
|
|
|
func configurePinInputPulldown(pi pin.Input) {
|
|
configurePin(pi, pulldown) // some chips do not have pull down, in which case pulldown==machine.PinInput.
|
|
}
|
|
|
|
func configurePinInput(pi pin.Input) {
|
|
configurePin(pi, machine.PinInput)
|
|
}
|
|
|
|
func configurePinInputPullup(pi pin.Input) {
|
|
configurePin(pi, pullup) // some chips do not have pull up, in which case pullup==machine.PinInput.
|
|
}
|
|
|
|
func pinIsNoPin(a any) bool {
|
|
p, ok := a.(machine.Pin)
|
|
return ok && p == machine.NoPin
|
|
}
|
|
|
|
func configurePin(p any, mode machine.PinMode) {
|
|
machinePin, ok := p.(machine.Pin)
|
|
if ok {
|
|
machinePin.Configure(machine.PinConfig{Mode: mode})
|
|
}
|
|
}
|