summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/bastardkb/charybdis/3x5/blackpill/config.h1
-rw-r--r--keyboards/bastardkb/charybdis/3x6/blackpill/config.h1
-rw-r--r--keyboards/bastardkb/charybdis/4x6/blackpill/config.h1
-rw-r--r--keyboards/bastardkb/scylla/blackpill/config.h1
-rw-r--r--keyboards/bastardkb/skeletyl/blackpill/config.h1
-rw-r--r--keyboards/bastardkb/tbkmini/blackpill/config.h1
-rw-r--r--keyboards/handwired/macroboard/config.h1
-rw-r--r--keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h1
-rw-r--r--keyboards/mode/m60h/config.h3
-rw-r--r--keyboards/mode/m60h_f/config.h3
-rw-r--r--keyboards/mode/m60s/config.h3
-rw-r--r--platforms/chibios/drivers/ws2812_pwm.c37
12 files changed, 11 insertions, 43 deletions
diff --git a/keyboards/bastardkb/charybdis/3x5/blackpill/config.h b/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
index 0467a1261f..bd1e0fe31e 100644
--- a/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/3x5/blackpill/config.h
@@ -29,7 +29,6 @@
29#define WS2812_EXTERNAL_PULLUP 29#define WS2812_EXTERNAL_PULLUP
30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
31#define WS2812_PWM_DMA_CHANNEL 3 31#define WS2812_PWM_DMA_CHANNEL 3
32#define WS2812_PWM_TARGET_PERIOD 800000
33 32
34/* Serial configuration for split keyboard. */ 33/* Serial configuration for split keyboard. */
35#define SERIAL_USART_TX_PIN A9 34#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/charybdis/3x6/blackpill/config.h b/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
index b41a1d3f57..e1365a109d 100644
--- a/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/3x6/blackpill/config.h
@@ -27,7 +27,6 @@
27#define WS2812_EXTERNAL_PULLUP 27#define WS2812_EXTERNAL_PULLUP
28#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 28#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
29#define WS2812_PWM_DMA_CHANNEL 3 29#define WS2812_PWM_DMA_CHANNEL 3
30#define WS2812_PWM_TARGET_PERIOD 800000
31 30
32/* Serial configuration for split keyboard. */ 31/* Serial configuration for split keyboard. */
33#define SERIAL_USART_TX_PIN A9 32#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/charybdis/4x6/blackpill/config.h b/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
index 0467a1261f..bd1e0fe31e 100644
--- a/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
+++ b/keyboards/bastardkb/charybdis/4x6/blackpill/config.h
@@ -29,7 +29,6 @@
29#define WS2812_EXTERNAL_PULLUP 29#define WS2812_EXTERNAL_PULLUP
30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
31#define WS2812_PWM_DMA_CHANNEL 3 31#define WS2812_PWM_DMA_CHANNEL 3
32#define WS2812_PWM_TARGET_PERIOD 800000
33 32
34/* Serial configuration for split keyboard. */ 33/* Serial configuration for split keyboard. */
35#define SERIAL_USART_TX_PIN A9 34#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/scylla/blackpill/config.h b/keyboards/bastardkb/scylla/blackpill/config.h
index 1d86b474ee..bf7879edbe 100644
--- a/keyboards/bastardkb/scylla/blackpill/config.h
+++ b/keyboards/bastardkb/scylla/blackpill/config.h
@@ -29,7 +29,6 @@
29#define WS2812_EXTERNAL_PULLUP 29#define WS2812_EXTERNAL_PULLUP
30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
31#define WS2812_PWM_DMA_CHANNEL 3 31#define WS2812_PWM_DMA_CHANNEL 3
32#define WS2812_PWM_TARGET_PERIOD 800000
33 32
34/* Serial configuration for split keyboard. */ 33/* Serial configuration for split keyboard. */
35#define SERIAL_USART_TX_PIN A9 34#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/skeletyl/blackpill/config.h b/keyboards/bastardkb/skeletyl/blackpill/config.h
index 1d86b474ee..bf7879edbe 100644
--- a/keyboards/bastardkb/skeletyl/blackpill/config.h
+++ b/keyboards/bastardkb/skeletyl/blackpill/config.h
@@ -29,7 +29,6 @@
29#define WS2812_EXTERNAL_PULLUP 29#define WS2812_EXTERNAL_PULLUP
30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
31#define WS2812_PWM_DMA_CHANNEL 3 31#define WS2812_PWM_DMA_CHANNEL 3
32#define WS2812_PWM_TARGET_PERIOD 800000
33 32
34/* Serial configuration for split keyboard. */ 33/* Serial configuration for split keyboard. */
35#define SERIAL_USART_TX_PIN A9 34#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/bastardkb/tbkmini/blackpill/config.h b/keyboards/bastardkb/tbkmini/blackpill/config.h
index 1d86b474ee..bf7879edbe 100644
--- a/keyboards/bastardkb/tbkmini/blackpill/config.h
+++ b/keyboards/bastardkb/tbkmini/blackpill/config.h
@@ -29,7 +29,6 @@
29#define WS2812_EXTERNAL_PULLUP 29#define WS2812_EXTERNAL_PULLUP
30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1 30#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM1
31#define WS2812_PWM_DMA_CHANNEL 3 31#define WS2812_PWM_DMA_CHANNEL 3
32#define WS2812_PWM_TARGET_PERIOD 800000
33 32
34/* Serial configuration for split keyboard. */ 33/* Serial configuration for split keyboard. */
35#define SERIAL_USART_TX_PIN A9 34#define SERIAL_USART_TX_PIN A9
diff --git a/keyboards/handwired/macroboard/config.h b/keyboards/handwired/macroboard/config.h
index ca12d2c753..21171b9374 100644
--- a/keyboards/handwired/macroboard/config.h
+++ b/keyboards/handwired/macroboard/config.h
@@ -22,4 +22,3 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
22#define WS2812_PWM_PAL_MODE 2 22#define WS2812_PWM_PAL_MODE 2
23#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. 23#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
24#define WS2812_PWM_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. 24#define WS2812_PWM_DMA_CHANNEL 2 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
25#define WS2812_PWM_TARGET_PERIOD 800000
diff --git a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
index 64169da7e5..28acc1e69b 100644
--- a/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
+++ b/keyboards/handwired/tractyl_manuform/5x6_right/f411/config.h
@@ -28,7 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
28//#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy). 28//#define WS2812_PWM_COMPLEMENTARY_OUTPUT // Define for a complementary timer output (TIMx_CHyN); omit for a normal timer output (TIMx_CHy).
29#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM7 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. 29#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM7 // DMA Stream for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
30#define WS2812_PWM_DMA_CHANNEL 3 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU. 30#define WS2812_PWM_DMA_CHANNEL 3 // DMA Channel for TIMx_UP, see the respective reference manual for the appropriate values for your MCU.
31#define WS2812_PWM_TARGET_PERIOD 800000
32 31
33#define DEBUG_LED_PIN C13 32#define DEBUG_LED_PIN C13
34 33
diff --git a/keyboards/mode/m60h/config.h b/keyboards/mode/m60h/config.h
index cde4ffdbc6..e51bff8ca5 100644
--- a/keyboards/mode/m60h/config.h
+++ b/keyboards/mode/m60h/config.h
@@ -6,5 +6,4 @@
6#define WS2812_PWM_DRIVER PWMD4 6#define WS2812_PWM_DRIVER PWMD4
7#define WS2812_PWM_CHANNEL 4 7#define WS2812_PWM_CHANNEL 4
8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
9#define WS2812_PWM_DMA_CHANNEL 2 9#define WS2812_PWM_DMA_CHANNEL 2 \ No newline at end of file
10#define WS2812_PWM_TARGET_PERIOD 800000 \ No newline at end of file
diff --git a/keyboards/mode/m60h_f/config.h b/keyboards/mode/m60h_f/config.h
index cde4ffdbc6..e51bff8ca5 100644
--- a/keyboards/mode/m60h_f/config.h
+++ b/keyboards/mode/m60h_f/config.h
@@ -6,5 +6,4 @@
6#define WS2812_PWM_DRIVER PWMD4 6#define WS2812_PWM_DRIVER PWMD4
7#define WS2812_PWM_CHANNEL 4 7#define WS2812_PWM_CHANNEL 4
8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
9#define WS2812_PWM_DMA_CHANNEL 2 9#define WS2812_PWM_DMA_CHANNEL 2 \ No newline at end of file
10#define WS2812_PWM_TARGET_PERIOD 800000 \ No newline at end of file
diff --git a/keyboards/mode/m60s/config.h b/keyboards/mode/m60s/config.h
index cde4ffdbc6..e51bff8ca5 100644
--- a/keyboards/mode/m60s/config.h
+++ b/keyboards/mode/m60s/config.h
@@ -6,5 +6,4 @@
6#define WS2812_PWM_DRIVER PWMD4 6#define WS2812_PWM_DRIVER PWMD4
7#define WS2812_PWM_CHANNEL 4 7#define WS2812_PWM_CHANNEL 4
8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6 8#define WS2812_PWM_DMA_STREAM STM32_DMA1_STREAM6
9#define WS2812_PWM_DMA_CHANNEL 2 9#define WS2812_PWM_DMA_CHANNEL 2 \ No newline at end of file
10#define WS2812_PWM_TARGET_PERIOD 800000 \ No newline at end of file
diff --git a/platforms/chibios/drivers/ws2812_pwm.c b/platforms/chibios/drivers/ws2812_pwm.c
index dc0e309163..c46e9171ab 100644
--- a/platforms/chibios/drivers/ws2812_pwm.c
+++ b/platforms/chibios/drivers/ws2812_pwm.c
@@ -79,15 +79,15 @@
79# endif 79# endif
80#endif 80#endif
81 81
82#ifndef WS2812_PWM_TARGET_PERIOD 82// Default is 800000Hz, which has a period of 1.25us
83//# define WS2812_PWM_TARGET_PERIOD 800000 // Original code is 800k...? 83#ifndef WS2812_PWM_FREQUENCY
84# define WS2812_PWM_TARGET_PERIOD 80000 // TODO: work out why 10x less on f303/f4x1 84# define WS2812_PWM_FREQUENCY (1000000000 / WS2812_TIMING)
85#endif 85#endif
86 86
87/* --- PRIVATE CONSTANTS ---------------------------------------------------- */ 87/* --- PRIVATE CONSTANTS ---------------------------------------------------- */
88 88
89#define WS2812_PWM_FREQUENCY (CPU_CLOCK / 2) /**< Clock frequency of PWM, must be valid with respect to system clock! */ 89#define WS2812_PWM_TICK_FREQUENCY (CPU_CLOCK / 2) /**< Clock frequency of PWM ticks, must be valid with respect to system clock! */
90#define WS2812_PWM_PERIOD (WS2812_PWM_FREQUENCY / WS2812_PWM_TARGET_PERIOD) /**< Clock period in ticks. 1 / 800kHz = 1.25 uS (as per datasheet) */ 90#define WS2812_PWM_PERIOD (WS2812_PWM_TICK_FREQUENCY / WS2812_PWM_FREQUENCY) /**< Clock period in PWM ticks. */
91 91
92/** 92/**
93 * @brief Number of bit-periods to hold the data line low at the end of a frame 93 * @brief Number of bit-periods to hold the data line low at the end of a frame
@@ -102,37 +102,16 @@
102 102
103/** 103/**
104 * @brief High period for a zero, in ticks 104 * @brief High period for a zero, in ticks
105 *
106 * Per the datasheet:
107 * WS2812:
108 * - T0H: 200 nS to 500 nS, inclusive
109 * - T0L: 650 nS to 950 nS, inclusive
110 * WS2812B:
111 * - T0H: 200 nS to 500 nS, inclusive
112 * - T0L: 750 nS to 1050 nS, inclusive
113 *
114 * The duty cycle is calculated for a high period of 350 nS.
115 */ 105 */
116#define WS2812_DUTYCYCLE_0 (WS2812_PWM_FREQUENCY / (1000000000 / 350)) 106#define WS2812_DUTYCYCLE_0 (WS2812_PWM_TICK_FREQUENCY / (1000000000 / WS2812_T0H))
117#if (WS2812_DUTYCYCLE_0 > 255) 107#if (WS2812_DUTYCYCLE_0 > 255)
118# error WS2812 PWM driver: High period for a 0 is more than a byte 108# error WS2812 PWM driver: High period for a 0 is more than a byte
119#endif 109#endif
120 110
121/** 111/**
122 * @brief High period for a one, in ticks 112 * @brief High period for a one, in ticks
123 *
124 * Per the datasheet:
125 * WS2812:
126 * - T1H: 550 nS to 850 nS, inclusive
127 * - T1L: 450 nS to 750 nS, inclusive
128 * WS2812B:
129 * - T1H: 750 nS to 1050 nS, inclusive
130 * - T1L: 200 nS to 500 nS, inclusive
131 *
132 * The duty cycle is calculated for a high period of 800 nS.
133 * This is in the middle of the specifications of the WS2812 and WS2812B.
134 */ 113 */
135#define WS2812_DUTYCYCLE_1 (WS2812_PWM_FREQUENCY / (1000000000 / 800)) 114#define WS2812_DUTYCYCLE_1 (WS2812_PWM_TICK_FREQUENCY / (1000000000 / WS2812_T1H))
136#if (WS2812_DUTYCYCLE_1 > 255) 115#if (WS2812_DUTYCYCLE_1 > 255)
137# error WS2812 PWM driver: High period for a 1 is more than a byte 116# error WS2812 PWM driver: High period for a 1 is more than a byte
138#endif 117#endif
@@ -322,7 +301,7 @@ void ws2812_init(void) {
322 // PWM Configuration 301 // PWM Configuration
323 //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config 302 //#pragma GCC diagnostic ignored "-Woverride-init" // Turn off override-init warning for this struct. We use the overriding ability to set a "default" channel config
324 static const PWMConfig ws2812_pwm_config = { 303 static const PWMConfig ws2812_pwm_config = {
325 .frequency = WS2812_PWM_FREQUENCY, 304 .frequency = WS2812_PWM_TICK_FREQUENCY,
326 .period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben 305 .period = WS2812_PWM_PERIOD, // Mit dieser Periode wird UDE-Event erzeugt und ein neuer Wert (Länge WS2812_BIT_N) vom DMA ins CCR geschrieben
327 .callback = NULL, 306 .callback = NULL,
328 .channels = 307 .channels =