yincheng.zhong
2 天以前 2ebb8217f43b69f491620423ea4d5d5944d1f91d
keil/include/drivers/WS2812.c
@@ -1,27 +1,27 @@
#include "WS2812.h"
void w28delay(uint32_t nTimer)
{
    uint32_t i=0;
    for(i=0;i<nTimer;i++){
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);
    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));
    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);
    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));
    gpio_handle[0].base->DATAOUT = gpio_handle[0].base->DATAOUT & (~(1U << WS2812_PIN));
    w28delay(25);
}
uint32_t temp_G8;
@@ -29,26 +29,26 @@
void RGB_Set(uint32_t G8R8B8)
{
    int i;
   temp_G8=G8R8B8;
    temp_G8=G8R8B8;
    uint8_t byte=0;
    for(i=23;i>=0;i--)
    for(i=23; i>=0; i--)
    {
        byte = ((G8R8B8>>i)&0x1);
         byte_temp=byte;
        byte_temp=byte;
        if(byte == 1)
        {
            RGB_Set_Up();
        }else{
        } else {
            RGB_Set_Down();
        }
    }
}
void RGB_Rst(void)
{
      WS_PIN_0;
    WS_PIN_0;
    w28delay(3600);
   // WS_PIN_1;
    // WS_PIN_1;
}
uint32_t uwbled,rtkled,led4g,powerled;
void Set4LEDColor(uint32_t firstled,uint32_t secondled,uint32_t thirdled,uint32_t fourthled)
@@ -56,11 +56,11 @@
    __disable_irq();
    RGB_Rst();
    RGB_Set(firstled);
    RGB_Set(secondled);
    RGB_Set(thirdled);
    RGB_Set(fourthled);
    __enable_irq();
    //RGB_Rst();