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
53
54
55
56
57
58
59
60
61
62
63
| #include "WS2812.h"
|
| void w28delay(uint32_t nTimer)
| {
| uint32_t i=0;
| for(i=0;i<nTimer;i++){
| __NOP();
|
| }
| }
| void RGB_Set_Up()
| {
| GPIOB->BSRR = 0X0080;
| w28delay(11);
| GPIOB->BSRR = 0X0080 << 16;
| w28delay(2);
| }
| void RGB_Set_Down()
| {
| GPIOB->BSRR = 0X0080;
| w28delay(2);
| GPIOB->BSRR = 0X0080 << 16;
| w28delay(10);
| }
|
| void RGB_Set(uint32_t G8R8B8)
| {
| int i;
| uint8_t byte=0;
| for(i=23;i>=0;i--)
| {
| byte = ((G8R8B8>>i)&0x1);
| if(byte == 1)
| {
| RGB_Set_Up();
| }else{
| RGB_Set_Down();
| }
|
| }
| }
| void RGB_Rst(void)
| {
| GPIOB->BSRR=0X0080 << 16;
| w28delay(500);
| // GPIOB->BSRR = 0X0080;
| }
| uint32_t uwbled,rtkled,led4g,powerled;
| void Set4LEDColor(uint32_t firstled,uint32_t secondled,uint32_t thirdled,uint32_t fourthled)
| {
| __disable_irq();
| RGB_Rst();
| RGB_Set(firstled);
|
| RGB_Set(secondled);
|
| RGB_Set(thirdled);
|
| RGB_Set(fourthled);
| __enable_irq();
| //RGB_Rst();
|
| }
|
|