LibDriver WS2812B
Loading...
Searching...
No Matches
driver_ws2812b.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_WS2812B_H
38#define DRIVER_WS2812B_H
39
40#include <stdint.h>
41#include <stdio.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
53
58
62#ifndef WS2812B_EACH_RESET_BIT_FRAME_LEN
63 #define WS2812B_EACH_RESET_BIT_FRAME_LEN 512
64#endif
65
69typedef struct ws2812b_handle_s
70{
71 uint8_t (*spi_10mhz_init)(void);
72 uint8_t (*spi_deinit)(void);
73 uint8_t (*spi_write_cmd)(uint8_t *buf, uint16_t len);
74 void (*delay_ms)(uint32_t ms);
75 void (*debug_print)(const char *const fmt, ...);
76 uint8_t inited;
78
94
98
105
112#define DRIVER_WS2812B_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
113
120#define DRIVER_WS2812B_LINK_SPI_10MHZ_INIT(HANDLE, FUC) (HANDLE)->spi_10mhz_init = FUC
121
128#define DRIVER_WS2812B_LINK_SPI_DEINIT(HANDLE, FUC) (HANDLE)->spi_deinit = FUC
129
136#define DRIVER_WS2812B_LINK_SPI_WRITE_COMMAND(HANDLE, FUC) (HANDLE)->spi_write_cmd = FUC
137
144#define DRIVER_WS2812B_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
145
152#define DRIVER_WS2812B_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
153
157
164
173uint8_t ws2812b_info(ws2812b_info_t *info);
174
185uint8_t ws2812b_init(ws2812b_handle_t *handle);
186
197uint8_t ws2812b_deinit(ws2812b_handle_t *handle);
198
216uint8_t ws2812b_write(ws2812b_handle_t *handle, uint32_t *rgb, uint32_t len, uint8_t *temp, uint32_t temp_len);
217
233uint8_t ws2812b_write_only_reset(ws2812b_handle_t *handle, uint32_t len, uint8_t *temp, uint32_t temp_len);
234
252uint8_t ws2812b_write_only_color(ws2812b_handle_t *handle, uint32_t *rgb, uint32_t len, uint8_t *temp, uint32_t temp_len);
253
266uint8_t ws2812b_set_reg(ws2812b_handle_t *handle, uint8_t *buf, uint16_t len);
267
271
275
276#ifdef __cplusplus
277}
278#endif
279
280#endif
uint8_t ws2812b_info(ws2812b_info_t *info)
get chip's information
struct ws2812b_info_s ws2812b_info_t
ws2812b information structure definition
uint8_t ws2812b_write(ws2812b_handle_t *handle, uint32_t *rgb, uint32_t len, uint8_t *temp, uint32_t temp_len)
write reset and color frame
uint8_t ws2812b_deinit(ws2812b_handle_t *handle)
close the chip
struct ws2812b_handle_s ws2812b_handle_t
ws2812b handle structure definition
uint8_t ws2812b_write_only_reset(ws2812b_handle_t *handle, uint32_t len, uint8_t *temp, uint32_t temp_len)
write the reset frame
uint8_t ws2812b_write_only_color(ws2812b_handle_t *handle, uint32_t *rgb, uint32_t len, uint8_t *temp, uint32_t temp_len)
write the color frame
uint8_t ws2812b_init(ws2812b_handle_t *handle)
initialize the chip
uint8_t ws2812b_set_reg(ws2812b_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
ws2812b handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* spi_deinit)(void)
uint8_t(* spi_10mhz_init)(void)
uint8_t(* spi_write_cmd)(uint8_t *buf, uint16_t len)
ws2812b information structure definition
float supply_voltage_max_v
uint32_t driver_version
char manufacturer_name[32]
float supply_voltage_min_v