aboutsummaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/arm/ws2812.c11
-rw-r--r--drivers/arm/ws2812.h3
-rw-r--r--drivers/avr/ws2812.c22
-rw-r--r--drivers/avr/ws2812.h3
-rw-r--r--drivers/avr/ws2812_i2c.c12
5 files changed, 16 insertions, 35 deletions
diff --git a/drivers/arm/ws2812.c b/drivers/arm/ws2812.c
index b076eff33..fa702fca9 100644
--- a/drivers/arm/ws2812.c
+++ b/drivers/arm/ws2812.c
@@ -84,17 +84,12 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
84 sendByte(ledarray[i].g); 84 sendByte(ledarray[i].g);
85 sendByte(ledarray[i].r); 85 sendByte(ledarray[i].r);
86 sendByte(ledarray[i].b); 86 sendByte(ledarray[i].b);
87#ifdef RGBW
88 sendByte(ledarray[i].w);
89#endif
87 } 90 }
88 91
89 wait_ns(RES); 92 wait_ns(RES);
90 93
91 chSysUnlock(); 94 chSysUnlock();
92} 95}
93
94// Setleds for SK6812RGBW
95void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
96// not supported - for now error out if its enabled
97#ifdef RGBW
98# error "RGBW not supported"
99#endif
100}
diff --git a/drivers/arm/ws2812.h b/drivers/arm/ws2812.h
index bf5c9fd0f..41c22a00b 100644
--- a/drivers/arm/ws2812.h
+++ b/drivers/arm/ws2812.h
@@ -11,7 +11,6 @@
11 * The functions will perform the following actions: 11 * The functions will perform the following actions:
12 * - Set the data-out pin as output 12 * - Set the data-out pin as output
13 * - Send out the LED data 13 * - Send out the LED data
14 * - Wait 50s to reset the LEDs 14 * - Wait 50us to reset the LEDs
15 */ 15 */
16void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); 16void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
17void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
diff --git a/drivers/avr/ws2812.c b/drivers/avr/ws2812.c
index 5c733c4ab..dc7e8d48a 100644
--- a/drivers/avr/ws2812.c
+++ b/drivers/avr/ws2812.c
@@ -36,7 +36,6 @@
36void ws2812_sendarray(uint8_t *array, uint16_t length); 36void ws2812_sendarray(uint8_t *array, uint16_t length);
37void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask); 37void ws2812_sendarray_mask(uint8_t *array, uint16_t length, uint8_t pinmask);
38 38
39
40#ifdef RGBW_BB_TWI 39#ifdef RGBW_BB_TWI
41 40
42// Port for the I2C 41// Port for the I2C
@@ -146,16 +145,6 @@ void inline ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
146} 145}
147 146
148void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) { 147void inline ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t leds, uint8_t pinmask) {
149 // ws2812_DDRREG |= pinmask; // Enable DDR
150 // new universal format (DDR)
151 _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
152
153 ws2812_sendarray_mask((uint8_t *)ledarray, leds + leds + leds, pinmask);
154 _delay_us(50);
155}
156
157// Setleds for SK6812RGBW
158void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
159#ifdef RGBW_BB_TWI 148#ifdef RGBW_BB_TWI
160 uint8_t sreg_prev, twcr_prev; 149 uint8_t sreg_prev, twcr_prev;
161 sreg_prev = SREG; 150 sreg_prev = SREG;
@@ -176,15 +165,18 @@ void inline ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
176 SREG = sreg_prev; 165 SREG = sreg_prev;
177 TWCR = twcr_prev; 166 TWCR = twcr_prev;
178#endif 167#endif
179 168 // ws2812_DDRREG |= pinmask; // Enable DDR
180 // ws2812_DDRREG |= _BV(ws2812_pin); // Enable DDR
181 // new universal format (DDR) 169 // new universal format (DDR)
182 _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= _BV(RGB_DI_PIN & 0xF); 170 _SFR_IO8((RGB_DI_PIN >> 4) + 1) |= pinmask;
183 171
184 ws2812_sendarray_mask((uint8_t *)ledarray, leds << 2, _BV(RGB_DI_PIN & 0xF)); 172 ws2812_sendarray_mask((uint8_t *)ledarray, leds * sizeof(LED_TYPE), pinmask);
185 173
186#ifndef RGBW_BB_TWI 174#ifndef RGBW_BB_TWI
175# ifdef RGBW
187 _delay_us(80); 176 _delay_us(80);
177# else
178 _delay_us(50);
179# endif
188#endif 180#endif
189} 181}
190 182
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h
index 9652b94bb..b869fb28c 100644
--- a/drivers/avr/ws2812.h
+++ b/drivers/avr/ws2812.h
@@ -34,8 +34,7 @@
34 * The functions will perform the following actions: 34 * The functions will perform the following actions:
35 * - Set the data-out pin as output 35 * - Set the data-out pin as output
36 * - Send out the LED data 36 * - Send out the LED data
37 * - Wait 50s to reset the LEDs 37 * - Wait 50us to reset the LEDs
38 */ 38 */
39void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds); 39void ws2812_setleds(LED_TYPE *ledarray, uint16_t number_of_leds);
40void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask); 40void ws2812_setleds_pin(LED_TYPE *ledarray, uint16_t number_of_leds, uint8_t pinmask);
41void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
diff --git a/drivers/avr/ws2812_i2c.c b/drivers/avr/ws2812_i2c.c
index 8525a026c..1c332e24b 100644
--- a/drivers/avr/ws2812_i2c.c
+++ b/drivers/avr/ws2812_i2c.c
@@ -1,6 +1,10 @@
1#include "ws2812.h" 1#include "ws2812.h"
2#include "i2c_master.h" 2#include "i2c_master.h"
3 3
4#ifdef RGBW
5# error "RGBW not supported"
6#endif
7
4#ifndef WS2812_ADDRESS 8#ifndef WS2812_ADDRESS
5# define WS2812_ADDRESS 0xb0 9# define WS2812_ADDRESS 0xb0
6#endif 10#endif
@@ -21,11 +25,3 @@ void ws2812_setleds(LED_TYPE *ledarray, uint16_t leds) {
21 25
22 i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT); 26 i2c_transmit(WS2812_ADDRESS, (uint8_t *)ledarray, sizeof(LED_TYPE) * leds, WS2812_TIMEOUT);
23} 27}
24
25// Setleds for SK6812RGBW
26void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t leds) {
27// not supported - for now error out if its enabled
28#ifdef RGBW
29# error "RGBW not supported"
30#endif
31}