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.
This commit is contained in:
Ayke van Laethem
2021-08-08 00:51:14 +02:00
committed by Ron Evans
parent 9a3bfd4826
commit b3af3f594e
8 changed files with 575 additions and 428 deletions
+2
View File
@@ -1,6 +1,8 @@
// Package ws2812 implements a driver for WS2812 and SK6812 RGB LED strips.
package ws2812 // import "tinygo.org/x/drivers/ws2812"
//go:generate go run gen-ws2812-arm.go
import (
"errors"
"image/color"