mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-07 00:13:42 +00:00
feature: some additional changes to drivers.Pin HAL for clarity and readability.
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -3,7 +3,7 @@ package legacy
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
"tinygo.org/x/drivers"
|
||||
)
|
||||
|
||||
// ConfigurePinOut is a legacy function used to configure pins as outputs.
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
// Deprecated: Do not configure pins in drivers.
|
||||
// This is a legacy feature and should only be used by drivers that
|
||||
// previously configured pins in initialization to avoid breaking users.
|
||||
func ConfigurePinOut(po pin.Output) {
|
||||
func ConfigurePinOut(po drivers.PinOutput) {
|
||||
configurePinOut(po)
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ func ConfigurePinOut(po pin.Output) {
|
||||
// Deprecated: Do not configure pins in drivers.
|
||||
// This is a legacy feature and should only be used by drivers that
|
||||
// previously configured pins in initialization to avoid breaking users.
|
||||
func ConfigurePinInputPulldown(pi pin.Input) {
|
||||
func ConfigurePinInputPulldown(pi drivers.PinInput) {
|
||||
configurePinInputPulldown(pi)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func ConfigurePinInputPulldown(pi pin.Input) {
|
||||
// Deprecated: Do not configure pins in drivers.
|
||||
// This is a legacy feature and should only be used by drivers that
|
||||
// previously configured pins in initialization to avoid breaking users.
|
||||
func ConfigurePinInput(pi pin.Input) {
|
||||
func ConfigurePinInput(pi drivers.PinInput) {
|
||||
configurePinInput(pi)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func ConfigurePinInput(pi pin.Input) {
|
||||
// Deprecated: Do not configure pins in drivers.
|
||||
// This is a legacy feature and should only be used by drivers that
|
||||
// previously configured pins in initialization to avoid breaking users.
|
||||
func ConfigurePinInputPullup(pi pin.Input) {
|
||||
func ConfigurePinInputPullup(pi drivers.PinInput) {
|
||||
configurePinInputPullup(pi)
|
||||
}
|
||||
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
package legacy
|
||||
|
||||
import "tinygo.org/x/drivers/internal/pin"
|
||||
import (
|
||||
"tinygo.org/x/drivers"
|
||||
)
|
||||
|
||||
func configurePinOut(p pin.Output) {}
|
||||
func configurePinInput(p pin.Input) {}
|
||||
func configurePinInputPulldown(p pin.Input) {}
|
||||
func configurePinInputPullup(p pin.Input) {}
|
||||
func pinIsNoPin(a any) bool { return false }
|
||||
func configurePinOut(p drivers.PinOutput) {}
|
||||
func configurePinInput(p drivers.PinInput) {}
|
||||
func configurePinInputPulldown(p drivers.PinInput) {}
|
||||
func configurePinInputPullup(p drivers.PinInput) {}
|
||||
func pinIsNoPin(a any) bool { return false }
|
||||
|
||||
@@ -5,22 +5,22 @@ package legacy
|
||||
import (
|
||||
"machine"
|
||||
|
||||
"tinygo.org/x/drivers/internal/pin"
|
||||
"tinygo.org/x/drivers"
|
||||
)
|
||||
|
||||
func configurePinOut(po pin.Output) {
|
||||
func configurePinOut(po drivers.PinOutput) {
|
||||
configurePin(po, machine.PinOutput)
|
||||
}
|
||||
|
||||
func configurePinInputPulldown(pi pin.Input) {
|
||||
func configurePinInputPulldown(pi drivers.PinInput) {
|
||||
configurePin(pi, pulldown) // some chips do not have pull down, in which case pulldown==machine.PinInput.
|
||||
}
|
||||
|
||||
func configurePinInput(pi pin.Input) {
|
||||
func configurePinInput(pi drivers.PinInput) {
|
||||
configurePin(pi, machine.PinInput)
|
||||
}
|
||||
|
||||
func configurePinInputPullup(pi pin.Input) {
|
||||
func configurePinInputPullup(pi drivers.PinInput) {
|
||||
configurePin(pi, pullup) // some chips do not have pull up, in which case pullup==machine.PinInput.
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package pin
|
||||
|
||||
import "tinygo.org/x/drivers"
|
||||
|
||||
// Here to aid relevant documentation links of [drivers.PinOutput] and [drivers.PinInput].
|
||||
var _ drivers.PinOutput
|
||||
|
||||
// Output represents a pin hardware abstraction layer for a pin that can output a digital signal.
|
||||
//
|
||||
// This is an alternative to [drivers.PinOutput] abstraction which is a function type and has
|
||||
// not been standardized as of yet as a standard HAL in the drivers package,
|
||||
// [discussion ongoing here].
|
||||
//
|
||||
// [discussion ongoing here]: https://github.com/orgs/tinygo-org/discussions/5043
|
||||
type Output interface {
|
||||
Set(level bool)
|
||||
}
|
||||
|
||||
// Input represents a pin hardware abstraction layer.
|
||||
// See [Output] for more information on why this type exists separate to drivers.
|
||||
type Input interface {
|
||||
Get() (level bool)
|
||||
}
|
||||
Reference in New Issue
Block a user