Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws2812: support high-MHz ARMv6M chips like the RP2040 #391

Merged
merged 1 commit into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ws2812/gen-ws2812.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var architectures = map[string]architectureImpl{
maxBaseCyclesT0H: 1 + 3 + 2, // shift + branch (not taken) + store
minBaseCyclesT1H: 1 + 1 + 2, // shift + branch (taken) + store
maxBaseCyclesT1H: 1 + 3 + 2, // shift + branch (taken) + store
minBaseCyclesTLD: 1 + 1 + 2, // subtraction + branch + store (in next cycle)
minBaseCyclesTLD: 1 + 2 + 2, // subtraction + branch x2 + store (in next cycle)
valueTemplate: "uint32(c) << 24",
template: `
1: @ send_bit
Expand All @@ -73,7 +73,9 @@ var architectures = map[string]architectureImpl{
str {maskClear}, {portClear} @ [2] T1H -> T1L transition
@DELAY3
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
`,
},
"tinygoriscv": {
Expand Down
25 changes: 15 additions & 10 deletions ws2812/ws2812-asm_cortexm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down