aboutsummaryrefslogtreecommitdiffstats
path: root/src/ws2812.h
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-12-02 16:06:32 +0100
committerLouis Burda <quent.burda@gmail.com>2022-12-02 17:18:16 +0100
commit0392766bc379448c907de2bce45d6b57621d95b5 (patch)
treeb87705bfb60a6569769b3c0125a910144c784436 /src/ws2812.h
parent6defee37f9939991bbf3152e2cd4e18593baa541 (diff)
downloadsxkbd-0392766bc379448c907de2bce45d6b57621d95b5.tar.gz
sxkbd-0392766bc379448c907de2bce45d6b57621d95b5.zip
Added split uart support based on chibios impl
Diffstat (limited to 'src/ws2812.h')
-rw-r--r--src/ws2812.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ws2812.h b/src/ws2812.h
new file mode 100644
index 0000000..3a0cf5c
--- /dev/null
+++ b/src/ws2812.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "hardware/pio.h"
+#include "hardware/gpio.h"
+
+#include <stdbool.h>
+
+#define _WS2812_U8(v, s) (((uint32_t) (v) & 0xFF) << s)
+#define WS2812_U32RGB(r, g, b) \
+ (_WS2812_U8(b, 0) | _WS2812_U8(r, 8) | _WS2812_U8(g, 16))
+
+struct ws2812 {
+ PIO pio;
+ uint sm;
+ uint pin;
+ bool init;
+};
+
+void ws2812_init(struct ws2812 *pix, PIO pio, uint pin);
+void ws2812_put(struct ws2812 *pix, uint32_t rgb);