#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);
|
//}
|