Skip to content

Commit df0d0d2

Browse files
oflebbedeadprogram
authored andcommitted
ws2812: support thingplus-rp2040 board
Added 125 MHz rp2040 timing Added unsafe.Pointer for pointer conversion
1 parent 3bdab45 commit df0d0d2

File tree

7 files changed

+335
-11
lines changed

7 files changed

+335
-11
lines changed

examples/ws2812/others.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//go:build !digispark && !arduino && !qtpy && !m5stamp_c3
2-
// +build !digispark,!arduino,!qtpy,!m5stamp_c3
1+
//go:build !digispark && !arduino && !qtpy && !m5stamp_c3 && !thingplus_rp2040
2+
// +build !digispark,!arduino,!qtpy,!m5stamp_c3,!thingplus_rp2040
33

44
package main
55

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//go:build thingplus_rp2040
2+
// +build thingplus_rp2040
3+
4+
package main
5+
6+
import "machine"
7+
8+
// This is the pin assignment for the internal neopixel of the
9+
// Sparkfun thingplus rp2040.
10+
// Replace neo and led in the code below to match the pin
11+
// that you are using if different.
12+
var neo machine.Pin = machine.GPIO8
13+
var led = machine.LED

ws2812/gen-ws2812.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func writeGoWrapper(f *os.File, arch string, megahertz int) error {
252252
fmt.Fprintf(buf, " portClear, maskClear := d.Pin.PortMaskClear()\n")
253253
fmt.Fprintf(buf, "\n")
254254
fmt.Fprintf(buf, " mask := interrupt.Disable()\n")
255-
fmt.Fprintf(buf, " C.ws2812_writeByte%d(C.char(c), portSet, portClear, maskSet, maskClear)\n", megahertz)
255+
fmt.Fprintf(buf, " C.ws2812_writeByte%d(C.char(c), (*uint32)(unsafe.Pointer(portSet)), (*uint32)(unsafe.Pointer(portClear)), maskSet, maskClear)\n", megahertz)
256256
buf.WriteString(`
257257
interrupt.Restore(mask)
258258
}
@@ -293,6 +293,7 @@ package ws2812
293293
// gen-ws2812.go and run "go generate".
294294
295295
import "runtime/interrupt"
296+
import "unsafe"
296297
297298
/*
298299
#include <stdint.h>

0 commit comments

Comments
 (0)