Tiny-WS2812
1.0.0
A tiny cross-platform WS2812 LED Strip driver
|
Driver code for STM8S chips. More...
#include <stm8s.h>
#include <stddef.h>
#include <stdbool.h>
#include <ws2812_common.h>
#include <ws2812_stm8s.h>
Go to the source code of this file.
Macros | |
#define | TICKS_PER_LOOP 2 |
Number of CPU ticks per loop in delay_us function. | |
#define | LOOPS_PER_US (F_CPU / TICKS_PER_LOOP / 1000000UL) |
Number for loops required for 1 us to pass. | |
#define | LDW_OVERHEAD 2 |
Number of CPU ticks for the LDW instruction. | |
Functions | |
uint8_t | ws2812_config (ws2812 *dev, ws2812_cfg *cfg) |
Configures a WS2812 device struct. More... | |
void | ws2812_prep_tx (ws2812 *dev) |
Prepares the host device for data transmission. More... | |
void | ws2812_wait_rst (ws2812 *dev) |
Waits for the WS2812 device to reset. More... | |
void | ws2812_tx (ws2812 *dev, ws2812_rgb *leds, size_t n_leds) |
Transmits RGB values to the provided WS2812 device. More... | |
void | ws2812_close_tx (ws2812 *dev) |
Closes a WS2812 transmission. More... | |
Driver code for STM8S chips.
The following file holds the Tiny-WS2812 library code to drive WS2812 devices on STM8S chips.
Definition in file ws2812_stm8s.c.
void ws2812_close_tx | ( | ws2812 * | dev | ) |
Closes a WS2812 transmission.
The following function should be called after ending data transmission with a WS2812 device. The exact closing procedure is platform specific but will typically involve restoring stashed registers to their previous states, re-enable interrupts, wait for the WS2812 to reset by calling ws2812_wait_rst(), and potentially alter fields of the provided WS2812 device struct.
Definition at line 263 of file ws2812_stm8s.c.
uint8_t ws2812_config | ( | ws2812 * | dev, |
ws2812_cfg * | cfg | ||
) |
Configures a WS2812 device struct.
The following function initializes/configures a WS2812 device struct using a ws2812_cfg configuration struct.
Definition at line 83 of file ws2812_stm8s.c.
void ws2812_prep_tx | ( | ws2812 * | dev | ) |
Prepares the host device for data transmission.
The following function prepares the host device for data transmission. The exact preperation procedure is platform specific, but typically will involve disabling interrupts, stashing registers that may be modified when communicating to the WS2812 device and potentially preparing the passed WS2812 device struct for data transmission. For a more detailed understanding, please refer to the platform specific code of this function.
Definition at line 106 of file ws2812_stm8s.c.
void ws2812_tx | ( | ws2812 * | dev, |
ws2812_rgb * | pxls, | ||
size_t | n_pxls | ||
) |
Transmits RGB values to the provided WS2812 device.
The following function transmits RGB values to the provided WS2812 device. Calling this function consecutively for the same device will continue programming LEDs after the position where the last transmission has ended. In other words, calling the function consecutively for the same device will NOT program the device from the first LED, but rather take off from where it last ended. If this is not desired, call ws2812_wait_rst() after each transmission.
Definition at line 252 of file ws2812_stm8s.c.
void ws2812_wait_rst | ( | ws2812 * | dev | ) |
Waits for the WS2812 device to reset.
The following function waits for the WS2812 device to reset, thus allowing it to be overwritten from the first LED again. The reset time is configuredin the ws2812_cfg object used to initialize/configure the passed WS2812 device struct, and is recommended to be 50us according to the WS2812 datasheet, but may be set significantly lower for some WS2812 devices. Call this function if you wish to overwritte the WS2812 device after a previous ws2812_tx() call.
Definition at line 119 of file ws2812_stm8s.c.