Pin HAL to break dependency of drivers from TinyGo's machine package

This commit is contained in:
Yurii Soldak
2025-09-21 04:38:21 +02:00
parent 3fa08112db
commit c6d83b783f
15 changed files with 328 additions and 88 deletions
+5 -4
View File
@@ -3,21 +3,22 @@
package dht // import "tinygo.org/x/drivers/dht"
import (
"machine"
"time"
"tinygo.org/x/drivers"
)
// Check if the pin is disabled
func powerUp(p machine.Pin) bool {
func powerUp(p drivers.Pin) bool {
state := p.Get()
if !state {
p.High()
p.Set(true)
time.Sleep(startTimeout)
}
return state
}
func expectChange(p machine.Pin, oldState bool) counter {
func expectChange(p drivers.PinInput, oldState bool) counter {
cnt := counter(0)
for ; p.Get() == oldState && cnt != timeout; cnt++ {
}