mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-06 07:53:41 +00:00
Update DHT22 receive to use runtime/interrupt
Fixes #483 by updating the DHT22 device to use runtime/interrupt instead of machine.UART1 for interrupt disabling while receiving signals from the device.
This commit is contained in:
committed by
Ron Evans
parent
ea944c8933
commit
789bbbd89f
+3
-2
@@ -11,6 +11,7 @@ package dht // import "tinygo.org/x/drivers/dht"
|
||||
|
||||
import (
|
||||
"machine"
|
||||
"runtime/interrupt"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -160,8 +161,8 @@ func (t *device) read() error {
|
||||
// interrupts
|
||||
func receiveSignals(pin machine.Pin, result []counter) {
|
||||
i := uint8(0)
|
||||
machine.UART1.Interrupt.Disable()
|
||||
defer machine.UART1.Interrupt.Enable()
|
||||
mask := interrupt.Disable()
|
||||
defer interrupt.Restore(mask)
|
||||
for ; i < 40; i++ {
|
||||
result[i*2] = expectChange(pin, false)
|
||||
result[i*2+1] = expectChange(pin, true)
|
||||
|
||||
Reference in New Issue
Block a user