Commit Graph

46 Commits

Author SHA1 Message Date
Ayke van Laethem 9717f365d9 ws2812: add RP2350 support
Adding 150MHz support for the RP2350
2025-09-16 19:16:01 +02:00
Leon Matthews 462a0de10a ws2812: add 200MHz support for the Cortex-M0/rp2040 2025-09-16 19:16:01 +02:00
SoftTacos 3b183ad6ed added support for SK6812 to WS2812 device (#610)
sk6812: added support for SK6812 to WS2812 device
2023-12-04 11:17:20 +01:00
Ayke van Laethem 715c33d4b0 all: prepare for CGo changes in TinyGo
For details, see: https://github.com/tinygo-org/tinygo/pull/3927
This change just means we need to be more careful to use the right type,
now that types like C.uint32_t don't match to the Go equivalent (like
uint32).
2023-10-05 10:01:25 +02:00
deadprogram 8b3075fdba build: remove older format build tags
Signed-off-by: deadprogram <ron@hybridgroup.com>
2022-12-21 17:47:14 -05:00
Olaf Flebbe df0d0d29a4 ws2812: support thingplus-rp2040 board
Added 125 MHz rp2040 timing
  Added unsafe.Pointer for pointer conversion
2022-05-28 10:22:26 +02:00
Ayke van Laethem f0a260be66 ws2812: convert AVR assembly to C inline assembly
See https://github.com/tinygo-org/drivers/pull/401 for details.
I haven't converted it to autogenerated assembly because AVR is
different from many other architectures (8-bit, among others) and it
didn't seem worth the effort as many chips run at 16MHz anyway.

I ran the two AVR smoke tests for the ws2812 driver and the resulting
binary is exactly the same.
2022-04-21 11:10:18 +02:00
Ayke van Laethem 06e298c514 ws2812: write inline assembly using C instead of Go
This is better for various reasons:

  * I don't like the inline assembly implementation in TinyGo. It kinda
    works, but it's hard to use correctly.
  * The Go version had a subtle bug: the i and value variables weren't
    marked as modified. The compiler produced correct code by chance. In
    GCC-style inline assembly, it's possible to correctly mark it as an
    input+output operand.
  * LLVM 14 has some changes to inline assembly that change how memory
    operands can be created. Instead of supporting that, I'd like to get
    rid of memory operands entirely (and possibly inline assembly in
    general).

I did some light testing: the ARM assembly changed a bit but not in any
way that should have a practical effect, and the RISC-V assembly didn't
change at all.
2022-04-21 11:10:18 +02:00
Ayke van Laethem 2d32995f6a 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.
2022-03-10 10:50:12 +01:00
BCG 0ced12683c Revert "Added support for 125MHz to WS2812 for RP2040"
This reverts commit b4eb406a43 (erroneous
push).
2022-02-14 01:06:23 -05:00
BCG b4eb406a43 Added support for 125MHz to WS2812 for RP2040 2022-02-14 00:48:33 -05:00
Ayke van Laethem 94729a4f7d ws2812: add support for RISC-V
This commit adds support for two new chips using the RISC-V
architecture: the FE310 (used in the HiFive 1) and the ESP32-C3 from
Espressif.
2021-11-03 19:14:32 +01:00
Ayke van Laethem 050cf4dbbc ws2812: make assembly generator architecture independent 2021-11-03 19:14:32 +01:00
Ayke van Laethem 259593e608 ws2812: add support for 168MHz (e.g. Adafruit Feather STM32F405) 2021-09-17 10:19:21 +02:00
Ayke van Laethem 7a2b1b8c90 ws2812: improve timings to be compatible with the WS2811
The WS2811 has a slightly slower data rate, but it is close enough that
a single library can support both LEDs at the same time. In my testing,
this package was already compatible with WS2811 LEDs before this change
when running at 4-5V, but when the voltage dropped to 3V or so the LEDs
started misbehaving. With these improved timings, the LEDs remained of
the correct color even at very low voltages (although blue was starting
to fade due to lack of voltage - that's not a software/protocol issue).
2021-09-17 10:08:46 +02:00
Ayke van Laethem cad03a7d4e ws2812: fix generated build tags 2021-09-17 09:42:28 +02:00
deadprogram 3b16972ed8 all: use build directives for both Go1.17 and earlier versions
Signed-off-by: deadprogram <ron@hybridgroup.com>
2021-09-16 18:31:33 +02:00
Ayke van Laethem b3af3f594e ws2812: generate assembly instead of handwriting it
Previously, a new implementation had to be written for each processor
speed. This is tedious and error-prone, therefore I've rewritten all of
the assembly code using a tool that will calculate exactly how many NOP
instructions are required.

I've also switched from build tags to a switch statement over all
processor speeds.

All in all, this means that:
  - Chips with a supported CPU performance will automatically be
    supported (no build tags necessary).
  - Adding a new chip is as easy as adding the MHz count to the
    generator script and to the switch statement.

Right now this is only for the Cortex-M, but it's certainly feasible to
extend this to other architectures such as the AVR.
2021-09-07 18:00:55 +02:00
sago35 a748451cab Merge pull request #275 from tinygo-org/ws2812-add-nrf52833
ws2812: add tag for nrf52833
2021-06-23 20:33:53 +09:00
deadprogram a811483fd4 ws2812: add tag for nrf52833
Signed-off-by: deadprogram <ron@hybridgroup.com>
2021-06-20 11:11:08 +02:00
Daniel Bridges 7b565e8cb0 Disable interrupts before sending ws2812 data 2021-06-17 09:24:49 +02:00
sago35 5645eb3f91 ws2812: add support for qtpy and atsame5x 2021-06-01 21:09:08 +02:00
Ayke van Laethem df64ce8f50 ws2812: make AVR support more robust
* Merge AVR support for Digispark and non-Digispark
* Fix the error "inline assembly requires more registers than available"
* Use a single file for all AVR targets, in a similar style as the
  Xtensa support.
2020-10-16 18:36:32 +02:00
Ayke van Laethem 65f8299153 ws2812: add support for ESP8266
This patch adds support for the ESP8266 chip by adding support for 80MHz
operation. This should also work when the ESP32 is changed to 80MHz, but
I didn't test it (as there is not currently a way to do that).

Verified on a NodeMCU dev board with an ESP8266.
2020-09-09 22:43:35 +02:00
Ayke van Laethem 7cd7df7bb8 ws2812: add support for the Xtensa architecture
This allows WS2812 LEDs to be controlled by an ESP32. Right now it only
supports 160MHz operation, which is the default with current ESP32
support in TinyGo.
2020-09-05 14:01:22 +02:00
Alan Wang de27fae9a2 Update ws2812_avr_16m.go 2020-07-16 15:50:07 +02:00
Ron Evans 5f4806f0f9 ws2812: work-arounds to allow Digispark to control WS2812 LEDs
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2020-01-30 14:24:39 +01:00
BCG f4bccd1fed Added nrf52840 tag to ws2812 2020-01-06 07:37:21 +01:00
Ayke van Laethem 7b56e61d52 ws2812: add support for simulation
Call a special __tinygo_ws2812_write_byte function to send a single
byte.
2019-12-14 22:16:41 +01:00
Ayke van Laethem 514b436889 ws2812: fix "invalid symbol redefinition" error
Named local labels shouldn't be used in LLVM because they might get
duplicated resulting in multiple symbol definitions and a compiler
error. Instead, use numeric labels.
2019-12-14 22:11:10 +01:00
BCG 7233452819 Added Feather M0 and Trinket M0 to build tags for WS2812 2019-12-12 14:28:21 +01:00
Jonathan Basseri f822da51fe Add support for Cortex-M4 120MHz
This adjusts the timing for 120MHz as seen on atsamd51 boards. The
timing was kept as close as possible to the Cortex-M4 64MHz logic in
ws2812_m4_64m.go.

Tested: This works on ItsyBitsy-M4
2019-12-06 11:33:55 +01:00
Jonathan Basseri c62d7db35d Fix number in comment
assembly comment was counting the # of nops.
2019-12-06 11:33:55 +01:00
Ayke van Laethem d80f619c9f ws2812: fix timings for the nrf51
The timings needed to be changed slightly for ws2811 chips which are
slightly slower.
2019-08-19 10:55:00 +02:00
Brad Erickson c91888a099 ws2812: Add build tag for Arduino Nano33 IoT
Uses `arduino_nano33` to handle only this board. Other boards with
the same chip will need a separate tag.
2019-08-15 17:38:27 +02:00
Ayke van Laethem 00a9b9db77 ws2812: better support the nrf52832
This has cost me _hours_ to find. There are many clones of the ws2812
and they have slightly different timing characteristics. Some don't work
so well when you get close to the minimum T1H time: a 1-bit may be
interpreted as a 0-bit.
2019-06-03 19:25:24 +02:00
Ron Evans c09f0a8075 all: switch to using custom domain for all drivers
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-05-29 13:33:50 +02:00
Ron Evans 3f946868e1 all: refactor all current drivers to use new machine.Pin interface
Signed-off-by: Ron Evans <ron@hybridgroup.com>
2019-05-26 21:46:33 +02:00
Ayke van Laethem 7116778235 ws2812: add support for M0 at 48MHz: most SAMD21 boards 2019-02-24 23:10:10 +01:00
Ayke van Laethem 4ff437e5d4 ws2812: add nrf52 support, update timings for m0 and avr
This commit adds support for the nrf52, which is a Cortex-M4 running at
64MHz.
While implementing this, I discovered that the timings for AVR/16MHz and
Cortex-M0 at 16MHz weren't quite right. They do work, but were slightly
out of spec. So I fixed this as well.
2019-02-22 07:10:22 +01:00
Ayke van Laethem 4c21e79d0e ws2812: switch to different color format
Use image/color.RGBA to represent RGB colors. This is more standard.
2018-12-22 16:37:36 +01:00
Ayke van Laethem 0d692cfd0a ws2812: provide proper file-like interface in Device
* Return len and errors in the Write method, to implement io.Writer.
* Return a nil error in WriteByte, for compatibility with bufio.
2018-12-22 16:35:27 +01:00
Ayke van Laethem aef8d42d42 ws2812: add support for the Arduino 2018-11-20 21:07:04 +01:00
Ayke van Laethem 16a5f82d44 ws2812: rename WS2812 to Device
This is more consistent with the other drivers.
2018-11-16 14:55:00 +01:00
Ayke van Laethem c23954059f ws2812: improve documentation 2018-11-16 12:21:17 +01:00
Ayke van Laethem 1f27817061 Initial commit 2018-10-15 20:47:33 +02:00