diff options
author | xengineering <mail2xengineering@protonmail.com> | 2020-10-25 13:07:54 +0100 |
---|---|---|
committer | xengineering <mail2xengineering@protonmail.com> | 2020-10-25 13:07:54 +0100 |
commit | 58d3787ca563b7d6a2cb4e0a1ab7fdde67fd5557 (patch) | |
tree | 42115a58b60bdd7fa027b8b37cac7e76e7b74fab /libraries/ws2812.h | |
parent | 9435a85605d7efc75642491c85b0942bd558fcec (diff) | |
download | stm32f103c8-examples-58d3787ca563b7d6a2cb4e0a1ab7fdde67fd5557.tar stm32f103c8-examples-58d3787ca563b7d6a2cb4e0a1ab7fdde67fd5557.tar.zst stm32f103c8-examples-58d3787ca563b7d6a2cb4e0a1ab7fdde67fd5557.zip |
Add ws2812 Code
Diffstat (limited to 'libraries/ws2812.h')
-rw-r--r-- | libraries/ws2812.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libraries/ws2812.h b/libraries/ws2812.h new file mode 100644 index 0000000..e4f0754 --- /dev/null +++ b/libraries/ws2812.h @@ -0,0 +1,38 @@ + + +#ifndef WS2812_H +#define WS2812_H + + +#include <stdlib.h> +#include <libopencm3/stm32/gpio.h> + + +typedef struct ws2812_init_typedef{ + + uint32_t gpio_port; + uint16_t gpio_pin; + uint32_t array_length; + uint32_t matrix_width; + uint8_t (*led_array)[3]; + +}ws2812_init_typedef; + + +void ws2812_init(ws2812_init_typedef *control_struct, uint32_t port, uint16_t pin, uint32_t array_length, uint32_t matrix_width); + +void ws2812_send_reset(ws2812_init_typedef *control_struct); +void ws2812_send_zero(ws2812_init_typedef *control_struct); +void ws2812_send_one(ws2812_init_typedef *control_struct); + +void ws2812_send_byte(ws2812_init_typedef *control_struct, uint8_t data); +void ws2812_send_led(ws2812_init_typedef *control_struct, uint8_t red, uint8_t green, uint8_t blue); +void ws2812_write_leds(ws2812_init_typedef *control_struct); + +void ws2812_set_array_led(ws2812_init_typedef *control_struct, uint32_t index, uint8_t red, uint8_t green, uint8_t blue); +void ws2812_set_matrix_led(ws2812_init_typedef *control_struct, uint32_t x, uint32_t y, uint8_t red, uint8_t green, uint8_t blue); + +void ws2812_clear_buffer(ws2812_init_typedef *control_struct); + + +#endif /* WS2812_H */ |