资源简介
STM32F103 例程 包括 基本功能 WS2812真彩LED灯 驱动程序
软件开发工具 KEIL4
软件开发工具 KEIL4
![](http://www.nz998.com/pic/64544.jpg)
代码片段和文件信息
//================================================================================
//STM32F103 多功能通讯控制演示模块
//================================================================================
//WS281X_S.C/H WS281X_RGB_LED彩色灯驱动库函数 BY SAGAHDS 20181127
//================================================================================
#include “stm32f10x.h“
#include “ws281x_S.h“
#include “stdio.h“
#include “tim_S.h“
#include “stm32f10x_tim.h“
#include “misc.h“
#include “usart_S.h“
//================================================================================
//BY SAGAHDS 20181128
unsigned char WS2812_FLAG; //WS2812开关信号
#define WS2812_FLAG_ENABLE 0x01 //置1安装
unsigned int RGB_Timer = 0;
unsigned char RGB_Color = 0;
unsigned char TimeFlag = 0;
unsigned char colorful[8][3] =
{
{0xFF 0x00 0x00 } //红
{0x00 0xFF 0x00 } //绿
{0x00 0x00 0xFF } //蓝
{0x00 0x00 0x00 } //灭
{0xFF 0xFF 0xFF } //白
{0xFF 0x61 0x00 } //橙
{0xFF 0xFF 0x00 } //黄
{0x00 0xFF 0xFF } //青
};
//================================================================================
//BY SAGAHDS 20181128
void WS2812_Configuration(unsigned char Enable)
{
GPIO_InitTypeDef GPIO_InitStructure;
if(!Enable)
{
WS2812_FLAG = 0;
USART_Put_String(“WS2812_LED No Installation.\r\n“);
return;
}
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO ENABLE); // 使能PC端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; //选择对应的引脚
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出 //GPIO_Mode_AF_PP; //复用推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //IO口速度为50MHz
GPIO_Init(GPIOB &GPIO_InitStructure); //初始化PC端口
GPIO_ResetBits(GPIOB GPIO_Pin_10); //关闭所有IO口
WS2812_FLAG |= WS2812_FLAG_ENABLE;
USART_Put_String(“WS2812_LED Installation.\r\n“);
}
//程序名称:WS_Set_Up(GPIO_TypeDef *GPIOxuint16_t GPIO_Pin)
//参数: GPIO_TypeDef *GPIOx : 指定的IO类型
// GPIO_Pin : 指定IO的类型的相应管脚
//说明: 1码 这里直接使用寄存器操作,避免IO口速度不够具体计算如下:
// TIMCLK = 72ZHZ WSTIM=WSH+WSL = 1.25us ± 600ns
// 1码: H1(0.8us) + L1(0.45us) = 1.25us 误差 ±150ns
void WS_Set_Up(GPIO_TypeDef *GPIOxuint16_t GPIO_Pin)
{
unsigned char j=0;
GPIOx->BSRR = GPIO_Pin;
j = 5;
while(j--) __NOP();
GPIOx->BRR = GPIO_Pin;
}
//程序名称:WS_Set_Down(GPIO_TypeDef *GPIOxuint16_t GPIO_Pin)
//参数: GPIO_TypeDef *GPIOx : 指定的IO类型
// GPIO_Pin : 指定IO的类型的相应管脚
//说明: 发送0码 具体计算如下
// TIMCLK = 72ZHZ WSTIM=WSH+WSL = 1.25us ± 600ns
// 0码: H0(0.4us) + L0(0.85us) = 1.25us 误差 ±150ns
void WS_Set_Down(GPIO_TypeDef *GPIOxuint16_t GPIO_Pin)
{
unsigned char j=0;
GPIOx->BSRR = GPIO_Pin;
j= 2;
while(j--) __NOP();
GPIOx->BRR = GPIO_Pin;
j= 2;
while(j--) __NOP();
}
//程序名称:WS_Reset(GPIO_TypeDef *GPIOxuint16_t GPIO_Pin)
//参数: GPIO_TypeDef *GPIOx : 指定的IO类型
//
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 26180 2018-11-30 15:21 Sagahds_20181210_STM32_WS2812_V0.1\cortexm3_macro.lst
文件 5232 2018-12-10 09:00 Sagahds_20181210_STM32_WS2812_V0.1\device\ws281x_S.c
文件 1658 2018-12-10 09:00 Sagahds_20181210_STM32_WS2812_V0.1\device\ws281x_S.h
文件 48807 2018-12-10 15:41 Sagahds_20181210_STM32_WS2812_V0.1\output\Sagahds.hex
文件 3682 2018-12-10 15:46 Sagahds_20181210_STM32_WS2812_V0.1\output\Sagahds.plg
文件 106364 2018-12-10 15:41 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.map
文件 51744 2018-07-31 17:59 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.plg
文件 479 2018-07-31 17:53 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.sct
....... 70830 2018-12-10 15:46 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvgui.Administrator
文件 71194 2018-12-03 13:51 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvguix.Administrator
....... 70832 2018-12-10 15:46 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvgui_Administrator.bak
....... 21342 2018-12-10 15:46 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvopt
文件 21881 2018-12-03 13:51 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvoptx
....... 21328 2018-12-10 15:20 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvproj
文件 22004 2018-12-03 13:48 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds.uvproj.saved_uv4
文件 67960 2018-12-10 15:41 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds_Target 1.dep
....... 21344 2018-12-10 15:40 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds_uvopt.bak
....... 26700 2018-12-05 17:19 Sagahds_20181210_STM32_WS2812_V0.1\Sagahds_uvproj.bak
文件 40529 2018-12-10 15:40 Sagahds_20181210_STM32_WS2812_V0.1\startup_stm32f10x_md.lst
文件 12895 2017-05-12 23:41 Sagahds_20181210_STM32_WS2812_V0.1\startup_stm32f10x_md.s
文件 7181 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\misc.c
文件 9117 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\misc.h
文件 47336 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_adc.c
文件 21825 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_adc.h
文件 8598 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_bkp.c
文件 7690 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_bkp.h
文件 45238 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_can.c
文件 27694 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_can.h
文件 11791 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_cec.c
文件 6708 2012-03-19 17:29 Sagahds_20181210_STM32_WS2812_V0.1\stm32f10x\stm32f10x_cec.h
............此处省略67个文件信息
- 上一篇:20170221212911037.txt
- 下一篇:信息系统管理工程师.txt
相关资源
- stm32f407上的两个can发送和接收例程
- STM32 led 时钟
- STM32 2.4G通信例程
- 直流无刷电机方波驱动 stm32 例程代码
- STM32中文资料
- STM32蓝牙和串口程序
- PCIe速度测试例程
- STM32f103超声波模块例程
- stm32f103c8t6 4 oled.rar
- stm32f030 IAP Demo(原创)
- 嵌入式图形界面MiniGUI的示例程序9例
- STM32基于rt_thread操作系统的SDHC卡文件
- NRF24L01实现51与STM32双向通讯
- CCP标定例程
- STM32F103 串口程序(完整版)
- stm32 ds18b20 温度传感器 测试通过
- stm32官方例程
- STM32F103定时器中断程序
- [免费]基于stm32f103ze 的OLED驱动代码
- STM32F103RBT6驱动UC1698控制芯片的160160黑
- STM32F103 DS18B20 V3.5.0固件库驱动程序工
- STM32定时器使用入门。看了这个程序会
- SIM908 SDIO FSMC STM32 FIFO
- [易语言]游戏多开例程
- STM32F103 CC2500完整驱动(模拟SPI)
- AD7606采集程序
- Siemens PLC编程精品例程11.机械手GRAPH
- VHDL语言编写的100实用的例程
- stm32 用SPI 方式读写 SDHC
- stm32通过DMA方式采集ADC数据
评论
共有 条评论