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
64
65
66
67
68
69
70
71
72
73
#include "WS2812.h"
 
void w28delay(uint32_t nTimer)  
{  
    uint32_t i=0;  
    for(i=0;i<nTimer;i++){  
        __NOP();
        
    }  
}
void RGB_Set_Up()
{
        gpio_handle[0].base->DATAOUT = gpio_handle[0].base->DATAOUT | (1U << WS2812_PIN);
    w28delay(40);
        gpio_handle[0].base->DATAOUT = gpio_handle[0].base->DATAOUT & (~(1U << WS2812_PIN));
    w28delay(18);//success 15
}
void RGB_Set_Down()
{
//    WS_PIN_1;
     gpio_handle[0].base->DATAOUT = gpio_handle[0].base->DATAOUT | (1U << WS2812_PIN);
    w28delay(8);
//    WS_PIN_0;
     gpio_handle[0].base->DATAOUT = gpio_handle[0].base->DATAOUT & (~(1U << WS2812_PIN));
    w28delay(25);
}
uint32_t temp_G8;
uint8_t byte_temp;
void RGB_Set(uint32_t G8R8B8)
{
    int i;
    temp_G8=G8R8B8;
    uint8_t byte=0;
    for(i=23;i>=0;i--)
    {
        byte = ((G8R8B8>>i)&0x1);
            byte_temp=byte;
        if(byte == 1)
        {
            RGB_Set_Up();
        }else{
            RGB_Set_Down();
        }
        
    }
}
void RGB_Rst(void)
{
        WS_PIN_0;
    w28delay(3600);
   // WS_PIN_1;
}
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();
 
}
 
//void Set4LEDColor_Off(void)
//{
//HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
//}