Disable interrupts before sending ws2812 data

This commit is contained in:
Daniel Bridges
2021-05-30 12:48:08 -07:00
committed by Ron Evans
parent 5645eb3f91
commit 7b565e8cb0
6 changed files with 21 additions and 0 deletions
+3
View File
@@ -7,6 +7,7 @@ package ws2812
import (
"device/arm"
"runtime/interrupt"
)
// Send a single byte using the WS2812 protocol.
@@ -14,6 +15,7 @@ func (d Device) WriteByte(c byte) error {
// For the Cortex-M0 at 16MHz
portSet, maskSet := d.Pin.PortMaskSet()
portClear, maskClear := d.Pin.PortMaskClear()
mask := interrupt.Disable()
// See:
// https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/
@@ -48,5 +50,6 @@ func (d Device) WriteByte(c byte) error {
"maskClear": maskClear,
"portClear": portClear,
})
interrupt.Restore(mask)
return nil
}