3 * @author Austin Glaser <austin.glaser@gmail.com>
4 * @brief Interface to WS2812 LED driver
6 * Copyright (C) 2016 Austin Glaser
8 * This software may be modified and distributed under the terms
9 * of the MIT license. See the LICENSE file for details.
11 * @todo Put in names and descriptions of variables which need to be defined to use this file
18 * @defgroup WS2812 WS2812 Driver
21 * @brief DMA-based WS2812 LED driver
23 * A driver for WS2812 LEDs
26 /* --- PUBLIC DEPENDENCIES -------------------------------------------------- */
32 /* --- PUBLIC MACROS -------------------------------------------------------- */
35 * @brief Concatenates two symbols s1 and s2 exactly, without expanding either
37 * @param[in] s1: The first symbol to concatenate
38 * @param[in] s2: The second symbol to concatenate
40 * @return A single symbol containing s1 and s2 concatenated without expansion
42 #define CONCAT_SYMBOLS(s1, s2) s1##s2
45 * @brief Concatenate the symbols s1 and s2, expanding both of them
47 * This is important because simply applying s1##s2 doesn't expand them if they're
48 * preprocessor tokens themselves
50 * @param[in] s1: The first symbol to concatenate
51 * @param[in] s2: The second symbol to concatenate
53 * @return A single symbol containing s1 expanded followed by s2 expanded
55 #define CONCAT_EXPANDED_SYMBOLS(s1, s2) CONCAT_SYMBOLS(s1, s2)
57 /* --- PUBLIC CONSTANTS ----------------------------------------------------- */
60 * @brief Return codes from ws2812 interface functions
63 WS2812_SUCCESS
= 0x00, /**< Operation completeed successfully */
64 WS2812_LED_INVALID
, /**< Attempted to index an invalid LED (@ref WS2812_N_LEDS) */
65 MAX_WS2812_ERR
, /**< Total number of possible error codes */
66 WS2812_ERR_INVALID
/**< Invalid error value */
69 /* --- PUBLIC FUNCTIONS ----------------------------------------------------- */
72 * @brief Initialize the driver
74 * After this function is called, all necessary background tasks will be started.
75 * The frame is initially dark.
77 void ws2812_init(void);
80 * @brief Write the value of a single LED in the chain
82 * The color value is written to a frame buffer, and will not
83 * be updated until the next frame is written. Frames are written
84 * at the maximum possible speed -- the longest latency between a
85 * call to this function and the value being displayed is
86 * 1.25uS*(24*@ref WS2812_LED_N + 50)
88 * @param[in] led_number: The index of the LED to be written. Must be strictly less than
90 * @param[in] r: The red level of the LED
91 * @param[in] g: The green level of the LED
92 * @param[in] b: The blue level of the LED
94 * @retval WS2812_SUCCESS: The write was successful
95 * @retval WS2812_LED_INVALID: The write was to an invalid LED index
97 ws2812_err_t
ws2812_write_led(uint32_t led_number
, uint8_t r
, uint8_t g
, uint8_t b
);
99 void ws2812_setleds(LED_TYPE
*ledarray
, uint16_t number_of_leds
);
100 /** @} defgroup WS2812 */
102 #endif // ifndef WS2812_H_