ws2812: support high-MHz ARMv6M chips like the RP2040

The possible branch distance is a lot shorter on ARMv6M (Cortex-M and
Cortex-M0+) for conditional branches. Therefore, convert this long
conditional branch into an unconditional branch.

This probably makes the code a little bit slower but because it is in
the low period of the WS2812 signal it shouldn't matter for the
protocol. And it avoids difficult workarounds specifically for the
RP2040.
This commit is contained in:
Ayke van Laethem
2022-03-01 13:14:17 +01:00
committed by Ron Evans
parent 9a98d1be55
commit 2d32995f6a
2 changed files with 19 additions and 12 deletions
+15 -10
View File
@@ -56,9 +56,10 @@ func (d Device) writeByte16(c byte) {
nop
nop
nop
nop
subs {i}, #1 @ [1]
bne.n 1b @ [1/3] send_bit
beq.n 3f @ [1/3] end
b 1b @ [1/3] send_bit
3: @ end
`, map[string]interface{}{
"value": value,
"i": 8,
@@ -186,9 +187,10 @@ func (d Device) writeByte48(c byte) {
nop
nop
nop
nop
subs {i}, #1 @ [1]
bne.n 1b @ [1/3] send_bit
beq.n 3f @ [1/3] end
b 1b @ [1/3] send_bit
3: @ end
`, map[string]interface{}{
"value": value,
"i": 8,
@@ -351,9 +353,10 @@ func (d Device) writeByte64(c byte) {
nop
nop
nop
nop
subs {i}, #1 @ [1]
bne.n 1b @ [1/3] send_bit
beq.n 3f @ [1/3] end
b 1b @ [1/3] send_bit
3: @ end
`, map[string]interface{}{
"value": value,
"i": 8,
@@ -638,9 +641,10 @@ func (d Device) writeByte120(c byte) {
nop
nop
nop
nop
subs {i}, #1 @ [1]
bne.n 1b @ [1/3] send_bit
beq.n 3f @ [1/3] end
b 1b @ [1/3] send_bit
3: @ end
`, map[string]interface{}{
"value": value,
"i": 8,
@@ -1032,9 +1036,10 @@ func (d Device) writeByte168(c byte) {
nop
nop
nop
nop
subs {i}, #1 @ [1]
bne.n 1b @ [1/3] send_bit
beq.n 3f @ [1/3] end
b 1b @ [1/3] send_bit
3: @ end
`, map[string]interface{}{
"value": value,
"i": 8,