aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-06-03 09:48:16 +1000
committerGitHub <noreply@github.com>2021-06-03 09:48:16 +1000
commit597d2e0e7bdc3f2629965a5b393b725e9ab8442b (patch)
treee7cabc6c252a4c250704e42f9c2b34da076315b9
parent35dbe8ba035c8eefc1051226aa8e3dd7cd63a912 (diff)
downloadqmk_firmware-597d2e0e7bdc3f2629965a5b393b725e9ab8442b.tar.gz
qmk_firmware-597d2e0e7bdc3f2629965a5b393b725e9ab8442b.zip
Fix up WS2812 SPI driver on F072. (#13022)
-rw-r--r--docs/ws2812_driver.md14
-rw-r--r--drivers/chibios/ws2812_spi.c24
-rw-r--r--keyboards/aeboards/ext65/rev2/config.h2
-rw-r--r--keyboards/cannonkeys/an_c/config.h2
-rw-r--r--keyboards/cannonkeys/atlas/config.h2
-rw-r--r--keyboards/cannonkeys/db60/config.h2
-rw-r--r--keyboards/cannonkeys/devastatingtkl/config.h2
-rw-r--r--keyboards/cannonkeys/instant60/config.h2
-rw-r--r--keyboards/cannonkeys/instant65/config.h2
-rw-r--r--keyboards/cannonkeys/obliterated75/config.h2
-rw-r--r--keyboards/cannonkeys/sagittarius/config.h2
-rw-r--r--keyboards/cannonkeys/savage65/config.h2
-rw-r--r--keyboards/cannonkeys/tmov2/config.h2
-rw-r--r--keyboards/cannonkeys/tsukuyomi/config.h2
-rwxr-xr-xkeyboards/nebula12/config.h2
-rw-r--r--keyboards/primekb/meridian/config.h2
-rw-r--r--keyboards/projectkb/alice/rev1/config.h2
-rw-r--r--keyboards/projectkb/alice/rev2/config.h2
-rw-r--r--keyboards/zoo/wampus/config.h2
19 files changed, 61 insertions, 11 deletions
diff --git a/docs/ws2812_driver.md b/docs/ws2812_driver.md
index e69400364..101798f21 100644
--- a/docs/ws2812_driver.md
+++ b/docs/ws2812_driver.md
@@ -72,7 +72,9 @@ WS2812_DRIVER = spi
72Configure the hardware via your config.h: 72Configure the hardware via your config.h:
73```c 73```c
74#define WS2812_SPI SPID1 // default: SPID1 74#define WS2812_SPI SPID1 // default: SPID1
75#define WS2812_SPI_MOSI_PAL_MODE 5 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5 75#define WS2812_SPI_MOSI_PAL_MODE 5 // MOSI pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5
76#define WS2812_SPI_SCK_PIN B3 // Required for F072, may be for others -- SCK pin, see the respective datasheet for the appropriate values for your MCU. default: unspecified
77#define WS2812_SPI_SCK_PAL_MODE 5 // SCK pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5
76``` 78```
77 79
78You must also turn on the SPI feature in your halconf.h and mcuconf.h 80You must also turn on the SPI feature in your halconf.h and mcuconf.h
@@ -100,11 +102,11 @@ Only divisors of 2, 4, 8, 16, 32, 64, 128 and 256 are supported by hardware.
100 102
101While not an exhaustive list, the following table provides the scenarios that have been partially validated: 103While not an exhaustive list, the following table provides the scenarios that have been partially validated:
102 104
103| | SPI1 | SPI2 | SPI3 | 105| | SPI1 | SPI2 | SPI3 |
104|-|-|-|-| 106|------|---------------------------------------------|-----------------------------------------|-----------------------|
105| f072 | ? | B15 :heavy_check_mark: | N/A | 107| f072 | ? | B15 :heavy_check_mark: (needs SCK: B13) | N/A |
106| f103 | A7 :heavy_check_mark: | B15 :heavy_check_mark: | N/A | 108| f103 | A7 :heavy_check_mark: | B15 :heavy_check_mark: | N/A |
107| f303 | A7 :heavy_check_mark: B5 :heavy_check_mark: | B15 :heavy_check_mark: | B5 :heavy_check_mark: | 109| f303 | A7 :heavy_check_mark: B5 :heavy_check_mark: | B15 :heavy_check_mark: | B5 :heavy_check_mark: |
108 110
109*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.* 111*Other supported ChibiOS boards and/or pins may function, it will be highly chip and configuration dependent.*
110 112
diff --git a/drivers/chibios/ws2812_spi.c b/drivers/chibios/ws2812_spi.c
index e02cbabc0..377a929b9 100644
--- a/drivers/chibios/ws2812_spi.c
+++ b/drivers/chibios/ws2812_spi.c
@@ -16,19 +16,23 @@
16# define WS2812_SPI_MOSI_PAL_MODE 5 16# define WS2812_SPI_MOSI_PAL_MODE 5
17#endif 17#endif
18 18
19#ifndef WS2812_SPI_SCK_PAL_MODE
20# define WS2812_SPI_SCK_PAL_MODE 5
21#endif
22
19// Push Pull or Open Drain Configuration 23// Push Pull or Open Drain Configuration
20// Default Push Pull 24// Default Push Pull
21#ifndef WS2812_EXTERNAL_PULLUP 25#ifndef WS2812_EXTERNAL_PULLUP
22# if defined(USE_GPIOV1) 26# if defined(USE_GPIOV1)
23# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL 27# define WS2812_MOSI_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
24# else 28# else
25# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL 29# define WS2812_MOSI_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL
26# endif 30# endif
27#else 31#else
28# if defined(USE_GPIOV1) 32# if defined(USE_GPIOV1)
29# define WS2812_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN 33# define WS2812_MOSI_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_OPENDRAIN
30# else 34# else
31# define WS2812_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN 35# define WS2812_MOSI_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_OPENDRAIN
32# endif 36# endif
33#endif 37#endif
34 38
@@ -63,6 +67,12 @@
63# define WS2812_SPI_BUFFER_MODE 0 // normal buffer 67# define WS2812_SPI_BUFFER_MODE 0 // normal buffer
64#endif 68#endif
65 69
70#if defined(USE_GPIOV1)
71# define WS2812_SCK_OUTPUT_MODE PAL_MODE_STM32_ALTERNATE_PUSHPULL
72#else
73# define WS2812_SCK_OUTPUT_MODE PAL_MODE_ALTERNATE(WS2812_SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL
74#endif
75
66#define BYTES_FOR_LED_BYTE 4 76#define BYTES_FOR_LED_BYTE 4
67#define NB_COLORS 3 77#define NB_COLORS 3
68#define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS) 78#define BYTES_FOR_LED (BYTES_FOR_LED_BYTE * NB_COLORS)
@@ -109,7 +119,11 @@ static void set_led_color_rgb(LED_TYPE color, int pos) {
109} 119}
110 120
111void ws2812_init(void) { 121void ws2812_init(void) {
112 palSetLineMode(RGB_DI_PIN, WS2812_OUTPUT_MODE); 122 palSetLineMode(RGB_DI_PIN, WS2812_MOSI_OUTPUT_MODE);
123
124#ifdef WS2812_SPI_SCK_PIN
125 palSetLineMode(WS2812_SPI_SCK_PIN, WS2812_SCK_OUTPUT_MODE);
126#endif // WS2812_SPI_SCK_PIN
113 127
114 // TODO: more dynamic baudrate 128 // TODO: more dynamic baudrate
115 static const SPIConfig spicfg = {WS2812_SPI_BUFFER_MODE, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN), WS2812_SPI_DIVISOR}; 129 static const SPIConfig spicfg = {WS2812_SPI_BUFFER_MODE, NULL, PAL_PORT(RGB_DI_PIN), PAL_PAD(RGB_DI_PIN), WS2812_SPI_DIVISOR};
diff --git a/keyboards/aeboards/ext65/rev2/config.h b/keyboards/aeboards/ext65/rev2/config.h
index dc1bfb71c..778fc3ea6 100644
--- a/keyboards/aeboards/ext65/rev2/config.h
+++ b/keyboards/aeboards/ext65/rev2/config.h
@@ -51,6 +51,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
51//SPI 51//SPI
52#define WS2812_SPI SPID2 52#define WS2812_SPI SPID2
53#define WS2812_SPI_MOSI_PAL_MODE 0 53#define WS2812_SPI_MOSI_PAL_MODE 0
54#define WS2812_SPI_SCK_PAL_MODE 0
55#define WS2812_SPI_SCK_PIN B13
54#define WS2812_EXTERNAL_PULLUP 56#define WS2812_EXTERNAL_PULLUP
55 57
56// I2C OLED defines 58// I2C OLED defines
diff --git a/keyboards/cannonkeys/an_c/config.h b/keyboards/cannonkeys/an_c/config.h
index 922ea37b2..83e98c2e2 100644
--- a/keyboards/cannonkeys/an_c/config.h
+++ b/keyboards/cannonkeys/an_c/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 14 56#define RGBLED_NUM 14
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60/* 62/*
61 * Feature disable options 63 * Feature disable options
diff --git a/keyboards/cannonkeys/atlas/config.h b/keyboards/cannonkeys/atlas/config.h
index 72ee927e2..1ba5c0fb0 100644
--- a/keyboards/cannonkeys/atlas/config.h
+++ b/keyboards/cannonkeys/atlas/config.h
@@ -50,6 +50,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
50#define RGB_DI_PIN B15 50#define RGB_DI_PIN B15
51#define RGBLED_NUM 22 51#define RGBLED_NUM 22
52#define WS2812_SPI_MOSI_PAL_MODE 0 52#define WS2812_SPI_MOSI_PAL_MODE 0
53#define WS2812_SPI_SCK_PAL_MODE 0
54#define WS2812_SPI_SCK_PIN B13
53 55
54/* 56/*
55 * Feature disable options 57 * Feature disable options
diff --git a/keyboards/cannonkeys/db60/config.h b/keyboards/cannonkeys/db60/config.h
index db7269071..dc2007c17 100644
--- a/keyboards/cannonkeys/db60/config.h
+++ b/keyboards/cannonkeys/db60/config.h
@@ -55,6 +55,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
55#define RGB_DI_PIN B15 55#define RGB_DI_PIN B15
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI_MOSI_PAL_MODE 0 57#define WS2812_SPI_MOSI_PAL_MODE 0
58#define WS2812_SPI_SCK_PAL_MODE 0
59#define WS2812_SPI_SCK_PIN B13
58 60
59/* 61/*
60 * Feature disable options 62 * Feature disable options
diff --git a/keyboards/cannonkeys/devastatingtkl/config.h b/keyboards/cannonkeys/devastatingtkl/config.h
index 15c0d4e35..0a76a3466 100644
--- a/keyboards/cannonkeys/devastatingtkl/config.h
+++ b/keyboards/cannonkeys/devastatingtkl/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60/* 62/*
61 * Feature disable options 63 * Feature disable options
diff --git a/keyboards/cannonkeys/instant60/config.h b/keyboards/cannonkeys/instant60/config.h
index bd0ae3160..d34bc0003 100644
--- a/keyboards/cannonkeys/instant60/config.h
+++ b/keyboards/cannonkeys/instant60/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 14 56#define RGBLED_NUM 14
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60/* 62/*
61 * Feature disable options 63 * Feature disable options
diff --git a/keyboards/cannonkeys/instant65/config.h b/keyboards/cannonkeys/instant65/config.h
index ecfb55fe0..dc097494b 100644
--- a/keyboards/cannonkeys/instant65/config.h
+++ b/keyboards/cannonkeys/instant65/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60 62
61/* 63/*
diff --git a/keyboards/cannonkeys/obliterated75/config.h b/keyboards/cannonkeys/obliterated75/config.h
index b2edfecd3..7a8a7ff28 100644
--- a/keyboards/cannonkeys/obliterated75/config.h
+++ b/keyboards/cannonkeys/obliterated75/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60 62
61/* 63/*
diff --git a/keyboards/cannonkeys/sagittarius/config.h b/keyboards/cannonkeys/sagittarius/config.h
index 6c1648713..a263ebc71 100644
--- a/keyboards/cannonkeys/sagittarius/config.h
+++ b/keyboards/cannonkeys/sagittarius/config.h
@@ -60,6 +60,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
60#define RGBLED_NUM 8 60#define RGBLED_NUM 8
61#define WS2812_SPI SPID2 61#define WS2812_SPI SPID2
62#define WS2812_SPI_MOSI_PAL_MODE 0 62#define WS2812_SPI_MOSI_PAL_MODE 0
63#define WS2812_SPI_SCK_PAL_MODE 0
64#define WS2812_SPI_SCK_PIN B13
63 65
64#define DYNAMIC_KEYMAP_LAYER_COUNT 2 66#define DYNAMIC_KEYMAP_LAYER_COUNT 2
65 67
diff --git a/keyboards/cannonkeys/savage65/config.h b/keyboards/cannonkeys/savage65/config.h
index 07672643e..3c3166c91 100644
--- a/keyboards/cannonkeys/savage65/config.h
+++ b/keyboards/cannonkeys/savage65/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60 62
61/* 63/*
diff --git a/keyboards/cannonkeys/tmov2/config.h b/keyboards/cannonkeys/tmov2/config.h
index 5f44584e0..cddff4ce7 100644
--- a/keyboards/cannonkeys/tmov2/config.h
+++ b/keyboards/cannonkeys/tmov2/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 22 56#define RGBLED_NUM 22
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60/* 62/*
61 * Feature disable options 63 * Feature disable options
diff --git a/keyboards/cannonkeys/tsukuyomi/config.h b/keyboards/cannonkeys/tsukuyomi/config.h
index 00cd0eee9..d3e955450 100644
--- a/keyboards/cannonkeys/tsukuyomi/config.h
+++ b/keyboards/cannonkeys/tsukuyomi/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 20 56#define RGBLED_NUM 20
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60 62
61/* 63/*
diff --git a/keyboards/nebula12/config.h b/keyboards/nebula12/config.h
index 6f596beb3..da9fd1057 100755
--- a/keyboards/nebula12/config.h
+++ b/keyboards/nebula12/config.h
@@ -100,6 +100,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
100 100
101#define WS2812_SPI SPID2 // default: SPID1 101#define WS2812_SPI SPID2 // default: SPID1
102#define WS2812_SPI_MOSI_PAL_MODE 0 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5 102#define WS2812_SPI_MOSI_PAL_MODE 0 // Pin "alternate function", see the respective datasheet for the appropriate values for your MCU. default: 5
103#define WS2812_SPI_SCK_PAL_MODE 0
104#define WS2812_SPI_SCK_PIN B13
103 105
104#define RGB_DI_PIN B15 106#define RGB_DI_PIN B15
105#ifdef RGB_DI_PIN 107#ifdef RGB_DI_PIN
diff --git a/keyboards/primekb/meridian/config.h b/keyboards/primekb/meridian/config.h
index 9194023ab..082392c6b 100644
--- a/keyboards/primekb/meridian/config.h
+++ b/keyboards/primekb/meridian/config.h
@@ -36,6 +36,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
36#define RGBLED_NUM 3 36#define RGBLED_NUM 3
37#define WS2812_SPI SPID2 37#define WS2812_SPI SPID2
38#define WS2812_SPI_MOSI_PAL_MODE 0 38#define WS2812_SPI_MOSI_PAL_MODE 0
39#define WS2812_SPI_SCK_PAL_MODE 0
40#define WS2812_SPI_SCK_PIN B13
39 41
40/* Set 0 if debouncing isn't needed */ 42/* Set 0 if debouncing isn't needed */
41#define DEBOUNCE 5 43#define DEBOUNCE 5
diff --git a/keyboards/projectkb/alice/rev1/config.h b/keyboards/projectkb/alice/rev1/config.h
index fcf9817fa..05180c756 100644
--- a/keyboards/projectkb/alice/rev1/config.h
+++ b/keyboards/projectkb/alice/rev1/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 14 56#define RGBLED_NUM 14
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60#define INDICATOR_PIN_0 A0 62#define INDICATOR_PIN_0 A0
61#define INDICATOR_PIN_1 A1 63#define INDICATOR_PIN_1 A1
diff --git a/keyboards/projectkb/alice/rev2/config.h b/keyboards/projectkb/alice/rev2/config.h
index 174889d62..0b017936c 100644
--- a/keyboards/projectkb/alice/rev2/config.h
+++ b/keyboards/projectkb/alice/rev2/config.h
@@ -56,6 +56,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
56#define RGBLED_NUM 14 56#define RGBLED_NUM 14
57#define WS2812_SPI SPID2 57#define WS2812_SPI SPID2
58#define WS2812_SPI_MOSI_PAL_MODE 0 58#define WS2812_SPI_MOSI_PAL_MODE 0
59#define WS2812_SPI_SCK_PAL_MODE 0
60#define WS2812_SPI_SCK_PIN B13
59 61
60#define INDICATOR_PIN_0 A9 62#define INDICATOR_PIN_0 A9
61#define INDICATOR_PIN_1 A8 63#define INDICATOR_PIN_1 A8
diff --git a/keyboards/zoo/wampus/config.h b/keyboards/zoo/wampus/config.h
index c3a13ec35..f572c91fc 100644
--- a/keyboards/zoo/wampus/config.h
+++ b/keyboards/zoo/wampus/config.h
@@ -67,6 +67,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
67// SPI RGB Driver 67// SPI RGB Driver
68#define WS2812_SPI SPID2 68#define WS2812_SPI SPID2
69#define WS2812_SPI_MOSI_PAL_MODE 0 69#define WS2812_SPI_MOSI_PAL_MODE 0
70#define WS2812_SPI_SCK_PAL_MODE 0
71#define WS2812_SPI_SCK_PIN B13
70 72
71// OLED defines 73// OLED defines
72#define OLED_TIMEOUT 60000 74#define OLED_TIMEOUT 60000