/ components / drivers / ws2812 / include / ws2812.h
ws2812.h
 1  #ifndef _WS2812_H
 2  #define _WS2812_H
 3  
 4  #include <stddef.h>
 5  #include <stdbool.h>
 6  
 7  #include "i2s.h"
 8  
 9  typedef struct _WS2812_DATA {
10  	uint32_t blue : 8;
11  	uint32_t red : 8;
12  	uint32_t green : 8;
13  	uint32_t reserved : 8;
14  } __attribute__((packed, aligned(4))) ws2812_data;
15  
16  typedef struct _WS2812_INFO {
17  	size_t ws_num;
18  	ws2812_data *ws_buf;
19  } ws2812_info;
20  
21  ws2812_info *ws2812_init_buf(uint32_t num);
22  bool ws2812_release_buf(ws2812_info *ws);
23  bool ws2812_clear(ws2812_info *ws);
24  
25  void ws2812_i2s_enable_channel(i2s_device_number_t i2s_num, i2s_channel_num_t channel);
26  
27  bool ws2812_set_data(ws2812_info *ws, uint32_t num, uint8_t r, uint8_t g, uint8_t b);
28  
29  void ws2812_init_i2s(uint8_t pin, i2s_device_number_t i2s_num, i2s_channel_num_t channel);
30  bool ws2812_send_data_i2s(i2s_device_number_t i2s_num, dmac_channel_number_t dmac_num, ws2812_info *ws);
31  
32  #endif