aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/cannonkeys/bluepill/keyboard.c20
-rw-r--r--keyboards/cannonkeys/bluepill/ws2812.c133
-rw-r--r--keyboards/cannonkeys/ortho48/rules.mk4
-rw-r--r--keyboards/cannonkeys/ortho60/rules.mk4
-rw-r--r--keyboards/cannonkeys/ortho75/rules.mk4
-rw-r--r--keyboards/cannonkeys/practice60/rules.mk4
-rw-r--r--keyboards/cannonkeys/practice65/rules.mk4
7 files changed, 0 insertions, 173 deletions
diff --git a/keyboards/cannonkeys/bluepill/keyboard.c b/keyboards/cannonkeys/bluepill/keyboard.c
deleted file mode 100644
index 6a8edd4a9..000000000
--- a/keyboards/cannonkeys/bluepill/keyboard.c
+++ /dev/null
@@ -1,20 +0,0 @@
1#include <ch.h>
2#include <hal.h>
3#include "util.h"
4#include "quantum.h"
5
6#ifdef BOARD_STM32_F103_STM32DUINO
7#define LED_ON() do { palClearPad(GPIOC, 13) ;} while (0)
8#define LED_OFF() do { palSetPad(GPIOC, 13); } while (0)
9#define LED_TGL() do { palTogglePad(GPIOC, 13); } while (0)
10#else
11#define LED_ON()
12#define LED_OFF()
13#define LED_TGL()
14#endif
15
16void matrix_init_kb(void){
17 LED_ON();
18 wait_ms(500);
19 LED_OFF();
20}
diff --git a/keyboards/cannonkeys/bluepill/ws2812.c b/keyboards/cannonkeys/bluepill/ws2812.c
deleted file mode 100644
index 779e90519..000000000
--- a/keyboards/cannonkeys/bluepill/ws2812.c
+++ /dev/null
@@ -1,133 +0,0 @@
1/*
2 * LEDDriver.c
3 *
4 * Created on: Aug 26, 2013
5 * Author: Omri Iluz
6 */
7
8#include "ws2812.h"
9#include <stdlib.h>
10
11#define BYTES_FOR_LED_BYTE 4
12#define NB_COLORS 3
13#define BYTES_FOR_LED BYTES_FOR_LED_BYTE*NB_COLORS
14#define DATA_SIZE BYTES_FOR_LED*NB_LEDS
15#define RESET_SIZE 200
16#define PREAMBLE_SIZE 4
17// Define the spi your LEDs are plugged to here
18#define WS2812_SPI SPID2
19// Define the number of LEDs you wish to control in your LED strip
20#define NB_LEDS RGBLED_NUM
21
22 #define LED_SPIRAL 1
23
24 static uint8_t txbuf[PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE];
25static uint8_t get_protocol_eq(uint8_t data, int pos);
26
27 /*
28 * This lib is meant to be used asynchronously, thus the colors contained in
29 * the txbuf will be sent in loop, so that the colors are always the ones you
30 * put in the table (the user thus have less to worry about)
31 *
32 * Since the data are sent via DMA, and the call to spiSend is a blocking one,
33 * the processor ressources are not used to much, if you see your program being
34 * too slow, simply add a:
35 * chThdSleepMilliseconds(x);
36 * after the spiSend, where you increment x untill you are satisfied with your
37 * program speed, another trick may be to lower this thread priority : your call
38 */
39static THD_WORKING_AREA(LEDS_THREAD_WA, 128);
40static THD_FUNCTION(ledsThread, arg) {
41 (void) arg;
42 while(1){
43 spiSend(&WS2812_SPI, PREAMBLE_SIZE + DATA_SIZE + RESET_SIZE, txbuf);
44 }
45}
46
47 static const SPIConfig spicfg = {
48 false,
49 NULL,
50 PORT_WS2812,
51 PIN_WS2812,
52 SPI_CR1_BR_1|SPI_CR1_BR_0 // baudrate : fpclk / 8 => 1tick is 0.32us (2.25 MHz)
53};
54
55 /*
56 * Function used to initialize the driver.
57 *
58 * Starts by shutting off all the LEDs.
59 * Then gets access on the LED_SPI driver.
60 * May eventually launch an animation on the LEDs (e.g. a thread setting the
61 * txbuff values)
62 */
63void leds_init(void){
64 /* MOSI pin*/
65 palSetPadMode(PORT_WS2812, PIN_WS2812, PAL_MODE_STM32_ALTERNATE_PUSHPULL);
66 for(int i = 0; i < RESET_SIZE; i++)
67 txbuf[DATA_SIZE+i] = 0x00;
68 for (int i=0; i<PREAMBLE_SIZE; i++)
69 txbuf[i] = 0x00;
70 spiAcquireBus(&WS2812_SPI); /* Acquire ownership of the bus. */
71 spiStart(&WS2812_SPI, &spicfg); /* Setup transfer parameters. */
72 spiSelect(&WS2812_SPI); /* Slave Select assertion. */
73 chThdCreateStatic(LEDS_THREAD_WA, sizeof(LEDS_THREAD_WA),NORMALPRIO, ledsThread, NULL);
74}
75
76 /*
77 * As the trick here is to use the SPI to send a huge pattern of 0 and 1 to
78 * the ws2812b protocol, we use this helper function to translate bytes into
79 * 0s and 1s for the LED (with the appropriate timing).
80 */
81static uint8_t get_protocol_eq(uint8_t data, int pos){
82 uint8_t eq = 0;
83 if (data & (1 << (2*(3-pos))))
84 eq = 0b1110;
85 else
86 eq = 0b1000;
87 if (data & (2 << (2*(3-pos))))
88 eq += 0b11100000;
89 else
90 eq += 0b10000000;
91 return eq;
92}
93
94
95 void WS2812_init(void) {
96 leds_init();
97}
98
99 void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds) {
100 uint8_t i = 0;
101 while (i < number_of_leds) {
102 set_led_color_rgb(ledarray[i], i);
103 i++;
104 }
105}
106
107 /*
108 * If you want to set a LED's color in the RGB color space, simply call this
109 * function with a hsv_color containing the desired color and the index of the
110 * led on the LED strip (starting from 0, the first one being the closest the
111 * first plugged to the board)
112 *
113 * Only set the color of the LEDs through the functions given by this API
114 * (unless you really know what you are doing)
115 */
116void set_led_color_rgb(LED_TYPE color, int pos){
117 for(int j = 0; j < 4; j++)
118 txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + j] = get_protocol_eq(color.g, j);
119 for(int j = 0; j < 4; j++)
120 txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + BYTES_FOR_LED_BYTE+j] = get_protocol_eq(color.r, j);
121 for(int j = 0; j < 4; j++)
122 txbuf[PREAMBLE_SIZE + BYTES_FOR_LED*pos + BYTES_FOR_LED_BYTE*2+j] = get_protocol_eq(color.b, j);
123}
124
125 void set_leds_color_rgb(LED_TYPE color){
126 for(int i = 0; i < NB_LEDS; i++)
127 set_led_color_rgb(color, i);
128}
129
130
131 void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds) {
132
133 }
diff --git a/keyboards/cannonkeys/ortho48/rules.mk b/keyboards/cannonkeys/ortho48/rules.mk
index ac927481f..7deab7581 100644
--- a/keyboards/cannonkeys/ortho48/rules.mk
+++ b/keyboards/cannonkeys/ortho48/rules.mk
@@ -4,10 +4,6 @@ MCU = STM32F103
4# Bootloader selection 4# Bootloader selection
5BOOTLOADER = stm32duino 5BOOTLOADER = stm32duino
6 6
7# project specific files
8VPATH += keyboards/cannonkeys/bluepill
9SRC = keyboard.c
10
11#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration 7#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = yes # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
13EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control
diff --git a/keyboards/cannonkeys/ortho60/rules.mk b/keyboards/cannonkeys/ortho60/rules.mk
index ec91d3b81..7a642a2f5 100644
--- a/keyboards/cannonkeys/ortho60/rules.mk
+++ b/keyboards/cannonkeys/ortho60/rules.mk
@@ -4,10 +4,6 @@ MCU = STM32F103
4# Bootloader selection 4# Bootloader selection
5BOOTLOADER = stm32duino 5BOOTLOADER = stm32duino
6 6
7# project specific files
8VPATH += keyboards/cannonkeys/bluepill
9SRC = keyboard.c
10
11#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration 7#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = yes # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
13EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control
diff --git a/keyboards/cannonkeys/ortho75/rules.mk b/keyboards/cannonkeys/ortho75/rules.mk
index 9d6004656..a476836ae 100644
--- a/keyboards/cannonkeys/ortho75/rules.mk
+++ b/keyboards/cannonkeys/ortho75/rules.mk
@@ -4,10 +4,6 @@ MCU = STM32F103
4# Bootloader selection 4# Bootloader selection
5BOOTLOADER = stm32duino 5BOOTLOADER = stm32duino
6 6
7# project specific files
8VPATH += keyboards/cannonkeys/bluepill
9SRC = keyboard.c
10
11#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration 7#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = yes # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
13EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control
diff --git a/keyboards/cannonkeys/practice60/rules.mk b/keyboards/cannonkeys/practice60/rules.mk
index 80bde01cf..e1a981c37 100644
--- a/keyboards/cannonkeys/practice60/rules.mk
+++ b/keyboards/cannonkeys/practice60/rules.mk
@@ -4,10 +4,6 @@ MCU = STM32F103
4# Bootloader selection 4# Bootloader selection
5BOOTLOADER = stm32duino 5BOOTLOADER = stm32duino
6 6
7# project specific files
8VPATH += keyboards/cannonkeys/bluepill
9SRC = keyboard.c
10
11#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration 7#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = yes # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
13EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control
diff --git a/keyboards/cannonkeys/practice65/rules.mk b/keyboards/cannonkeys/practice65/rules.mk
index 130f9b98e..0d43570c5 100644
--- a/keyboards/cannonkeys/practice65/rules.mk
+++ b/keyboards/cannonkeys/practice65/rules.mk
@@ -4,10 +4,6 @@ MCU = STM32F103
4# Bootloader selection 4# Bootloader selection
5BOOTLOADER = stm32duino 5BOOTLOADER = stm32duino
6 6
7# project specific files
8VPATH += keyboards/cannonkeys/bluepill
9SRC = keyboard.c
10
11#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration 7#BOOTMAGIC_ENABLE = full # Virtual DIP switch configuration
12MOUSEKEY_ENABLE = yes # Mouse keys 8MOUSEKEY_ENABLE = yes # Mouse keys
13EXTRAKEY_ENABLE = yes # Audio control and System control 9EXTRAKEY_ENABLE = yes # Audio control and System control