Use PWM driver for ws2812

This commit is contained in:
mawaeg 2025-03-02 20:18:51 +01:00
parent 9af623764c
commit aa754da13d
5 changed files with 35 additions and 1 deletions

View File

@ -0,0 +1,22 @@
/* Copyright 2025 @mawaeg
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#define CH_CFG_ST_RESOLUTION 16
#define CH_CFG_ST_FREQUENCY 10000
#include_next <chconf.h>

View File

@ -19,4 +19,8 @@
#define I2C1_SCL_PIN A9
#define I2C1_SDA_PIN A10
#define WS2812_BITBANG_NOP_FUDGE 0.4
#define WS2812_PWM_DRIVER PWMD2
#define WS2812_PWM_CHANNEL 2
#define WS2812_PWM_PAL_MODE 1
#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM2
#define WS2812_PWM_DMA_CHANNEL 4

View File

@ -17,5 +17,6 @@
#pragma once
#define HAL_USE_I2C TRUE
#define HAL_USE_PWM TRUE
#include_next <halconf.h>

View File

@ -112,6 +112,7 @@
"vid": "0x6D73"
},
"ws2812": {
"driver": "pwm",
"pin": "B3"
},
"layouts": {

View File

@ -20,3 +20,9 @@
#undef STM32_I2C_USE_I2C1
#define STM32_I2C_USE_I2C1 TRUE
#undef STM32_PWM_USE_TIM2
#define STM32_PWM_USE_TIM2 TRUE
#undef STM32_ST_USE_TIMER
#define STM32_ST_USE_TIMER 15