/**********************************************************************
|
* Copyright: (C)2023 LingYun IoT System Studio
|
* Author: GuoWenxue<guowenxue@gmail.com> QQ: 281143292
|
* Description: ISKBoard WS2812B strip lights Hardware Abstract Layer driver
|
* Reference: https://blog.csdn.net/Lennon8_8/article/details/108980808
|
*
|
* ChangeLog:
|
* Version Date Author Description
|
* V1.0.0 2023.04.3 GuoWenxue Release initial version
|
***********************************************************************/
|
|
#ifndef INC_WS2812B_H_
|
#define INC_WS2812B_H_
|
|
#include "stm32l4xx_hal.h"
|
|
#define WS2812_NUM 3
|
|
#define PIXEL_OFF 0 /* off */
|
#define PIXEL_B (0xFF<<0) /* blue */
|
#define PIXEL_R (0xFF<<8) /* red */
|
#define PIXEL_G (0xFF<<16) /* green */
|
#define PIXEL_W (0xFFFFFF) /* white */
|
|
/* Composition of 24 bits data: GRB888
|
* +----+----+----+----+----+----+----+----+----+
|
* | G7 | ...| G0 | R7 | ...| R0 | B7 | ...| B0 |
|
* +----+----+----+----+----+----+----+----+----+
|
*/
|
typedef struct pixel_s
|
{
|
uint32_t blue:8;
|
uint32_t red:8;
|
uint32_t green:8;
|
} pixel_t;
|
|
typedef union color_u
|
{
|
pixel_t pixel;
|
uint32_t data;
|
} color_t;
|
|
|
extern void ws2812b_init(void);
|
|
extern void ws2812b_reset(void);
|
|
extern int ws2812b_turn(int which, color_t color);
|
|
extern void ws2812b_blink(void);
|
|
#endif /* INC_WS2812B_H_ */
|