aboutsummaryrefslogtreecommitdiff
path: root/include/drv/ws2812B/ws2812b.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2020-12-04 23:51:38 -0700
committerJosh Rahm <joshuarahm@gmail.com>2020-12-04 23:51:38 -0700
commit64b827a84ac87bf39e13a570cbd80ef0baa2b913 (patch)
treea21a13ee9e3c4792c96f8325936dd93e17f159f8 /include/drv/ws2812B/ws2812b.h
parent7002cb8380406173407c9e8c8d16ebd670fff55c (diff)
downloadstm32l4-64b827a84ac87bf39e13a570cbd80ef0baa2b913.tar.gz
stm32l4-64b827a84ac87bf39e13a570cbd80ef0baa2b913.tar.bz2
stm32l4-64b827a84ac87bf39e13a570cbd80ef0baa2b913.zip
Added some better implementation around the ws2812b driver.
Diffstat (limited to 'include/drv/ws2812B/ws2812b.h')
-rw-r--r--include/drv/ws2812B/ws2812b.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/drv/ws2812B/ws2812b.h b/include/drv/ws2812B/ws2812b.h
index 5ae41aa..3189907 100644
--- a/include/drv/ws2812B/ws2812b.h
+++ b/include/drv/ws2812B/ws2812b.h
@@ -2,6 +2,7 @@
#define WS2812B_H_
#include "kern/common.h"
+#include "kern/spi/spi_manager.h"
typedef struct {
/* why is it out of order? Don't know! That's the way the hardware was
@@ -11,10 +12,24 @@ typedef struct {
uint8_t b;
} PACKED rgb_t;
+typedef struct {
+ spi_t* spi;
+} ws2812b_t;
+
static_assert(sizeof(rgb_t) == 3, "Sizeof rgb_t should be 3.");
+ws2812b_t* ws2812b_new(spi_select_t spi_select, int* ec);
+
+void ws2812b_latch(ws2812b_t* drv);
+
uint8_t* ws2812b_compile_rgb(rgb_t* out, size_t arr_len);
+void ws2812b_write_rgb_sync(ws2812b_t* drv, uint8_t r, uint8_t g, uint8_t b);
+
+void ws2812b_write_rgb_arr_sync(ws2812b_t* drv, rgb_t* arr, size_t arr_len);
+
+void ws2812b_delete(ws2812b_t* drv);
+
/* Returns round(sin(2πn / 256) * 127.5 + 127.5). */
uint8_t byte_sin(uint8_t n);