基于STM32F030的WS2812B的程序设计
#include "ws2812b.h"
#include "timer.h"
#define numLEDs 255
#define ws28 GPIO_Pin_0
unsigned char buf_R[numLEDs] = {
0};
unsigned char buf_G[numLEDs] = {
0};
unsigned char buf_B[numLEDs] = {
0};
unsigned char len;
void WS2812B_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;
GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;
GPIO_Init(GPIOB,&GPIO_InitStructure);
}
void WS28_Reset(void)
{
uint16_t y=0;
GPIOB->ODR=0;
for(y=0;y<1000;y++);
}