aboutsummaryrefslogtreecommitdiff
path: root/drivers/avr/ws2812.h
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-07-10 11:18:47 -0400
committerGitHub <noreply@github.com>2017-07-10 11:18:47 -0400
commit42d5a324eb673b2214a87c8911d850105c3bdaab (patch)
treec14aca23eb74164d5cd7e69f50e6d347b3ace51a /drivers/avr/ws2812.h
parent8d190d5e25b3374156264fde0ba5d78696cc74aa (diff)
downloadqmk_firmware-42d5a324eb673b2214a87c8911d850105c3bdaab.tar.gz
qmk_firmware-42d5a324eb673b2214a87c8911d850105c3bdaab.zip
Start mvoing hardware drivers to /drivers/ (#1433)
* start driver isolation * update nyquist and orthodox boards * update atreus62 * move drivers to avr * update avr conditional
Diffstat (limited to 'drivers/avr/ws2812.h')
-rw-r--r--drivers/avr/ws2812.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/drivers/avr/ws2812.h b/drivers/avr/ws2812.h
new file mode 100644
index 000000000..60924a0fb
--- /dev/null
+++ b/drivers/avr/ws2812.h
@@ -0,0 +1,91 @@
1/*
2 * light weight WS2812 lib include
3 *
4 * Version 2.3 - Nev 29th 2015
5 * Author: Tim (cpldcpu@gmail.com)
6 *
7 * Please do not change this file! All configuration is handled in "ws2812_config.h"
8 *
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 */
22
23#ifndef LIGHT_WS2812_H_
24#define LIGHT_WS2812_H_
25
26#include <avr/io.h>
27#include <avr/interrupt.h>
28//#include "ws2812_config.h"
29//#include "i2cmaster.h"
30
31#ifdef RGBW
32 #define LED_TYPE struct cRGBW
33#else
34 #define LED_TYPE struct cRGB
35#endif
36
37
38/*
39 * Structure of the LED array
40 *
41 * cRGB: RGB for WS2812S/B/C/D, SK6812, SK6812Mini, SK6812WWA, APA104, APA106
42 * cRGBW: RGBW for SK6812RGBW
43 */
44
45struct cRGB { uint8_t g; uint8_t r; uint8_t b; };
46struct cRGBW { uint8_t g; uint8_t r; uint8_t b; uint8_t w;};
47
48
49
50/* User Interface
51 *
52 * Input:
53 * ledarray: An array of GRB data describing the LED colors
54 * number_of_leds: The number of LEDs to write
55 * pinmask (optional): Bitmask describing the output bin. e.g. _BV(PB0)
56 *
57 * The functions will perform the following actions:
58 * - Set the data-out pin as output
59 * - Send out the LED data
60 * - Wait 50�s to reset the LEDs
61 */
62
63void ws2812_setleds (LED_TYPE *ledarray, uint16_t number_of_leds);
64void ws2812_setleds_pin (LED_TYPE *ledarray, uint16_t number_of_leds,uint8_t pinmask);
65void ws2812_setleds_rgbw(LED_TYPE *ledarray, uint16_t number_of_leds);
66
67/*
68 * Old interface / Internal functions
69 *
70 * The functions take a byte-array and send to the data output as WS2812 bitstream.
71 * The length is the number of bytes to send - three per LED.
72 */
73
74void ws2812_sendarray (uint8_t *array,uint16_t length);
75void ws2812_sendarray_mask(uint8_t *array,uint16_t length, uint8_t pinmask);
76
77
78/*
79 * Internal defines
80 */
81#ifndef CONCAT
82#define CONCAT(a, b) a ## b
83#endif
84#ifndef CONCAT_EXP
85#define CONCAT_EXP(a, b) CONCAT(a, b)
86#endif
87
88// #define ws2812_PORTREG CONCAT_EXP(PORT,ws2812_port)
89// #define ws2812_DDRREG CONCAT_EXP(DDR,ws2812_port)
90
91#endif /* LIGHT_WS2812_H_ */