1 Star 3 Fork 1

夏天有风/WS2812_LED

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

WS2812_LED

介绍

使用STM32F103的DMA+SPI去驱动WS2812-LED,使用的是HAL库函数。

教程查看

教程地址: https://blog.csdn.net/xia233233/article/details/129810137?spm=1001.2014.3001.5502

安装教程

  1. 克隆下载项目: https://gitee.com/xia-wang-666/ws2812_-led.git
  2. 得到源文件,里面有ws2812.h和ws2812.c文件,把文件放在你的项目的头文件和源文件目录里即可
  3. 完成

使用说明

  1. 首先需要配置你的芯片的SPI和DMA,根据ws2812的协议要求,SPI的速度在5.52——9.41MHz范围都能使用
  2. 配置以STM32CUBEMX为例:
    • ①创建项目,配置好基本设置,找到SPI配置
    • ②SPI模式:发送主机模式(主要使用SPI_MOSI端口)
    • ③SPI时钟参数(CLOCK Parameters):Baud Rate:5.52——9.41MHz范围内,Clock Phase: 2 Edge
    • ④点到DMA配置:添加DMA发送,使用默认配置(从memory取数据以Byte方式发送)
    • 初始化完成
  3. 在主函数中使用
#include "main.h"
#include "dma.h"
#include "spi.h"
#include "gpio.h"
#include "ws2812.h"
/* Initialize all configured peripherals */
MX_GPIO_Init();

/* USER CODE BEGIN 2 */
MX_DMA_Init();
MX_SPI1_Init();

/* USER CODE END 2 */
/* USER CODE BEGIN WHILE */
while (1)
{
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
    RGB_RED(5);
	RGB_RST();
	HAL_Delay(1000);

	RGB_GREEN(4);
	RGB_RST();
	HAL_Delay(1000);

	RGB_BLUE(3);
	RGB_RST();
	HAL_Delay(1000);
}
/* USER CODE END 3 */

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
MIT License Copyright (c) 2023 夏天有风 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

使用STM32F103的DMA+SPI去驱动WS2812-LED,使用的是HAL库函数。 展开 收起
C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/xia-wang-666/ws2812_-led.git
git@gitee.com:xia-wang-666/ws2812_-led.git
xia-wang-666
ws2812_-led
WS2812_LED
master

搜索帮助