凌云物联网实验室ISKBoard(IoT Starter Kits Board)开发板项目源码
guowenxue
2023-04-04 5937444d8c50fd85f603fae272f46bf10679fe28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**********************************************************************
*   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_ */