Tiny-WS2812  1.0.0
A tiny cross-platform WS2812 LED Strip driver
ws2812_stm8s.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Patrick Pedersen
3 
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13 
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  *
17  */
18 
28 #pragma once
29 
30 #ifdef WS2812_TARGET_PLATFORM_STM8S
31 
32 #include <stm8s.h>
33 #include <stdint.h>
34 
35 #include "ws2812_common.h"
36 
37 // General description necessary for Doxygen
38 
52 /*
53  * STM8: Data structure to configure a @ref ws2812 "WS2812 device struct" on STM8S platforms.
54  *
55  * The following struct is used to initialize/configure a @ref ws2812 "WS2812 device struct"
56  * on STM8S based devices. It is passed to the ws2812_config() function along
57  * with a reference to a @ref ws2812 "WS2812 device struct", and contains relevant
58  * information such as pins used to drive WS2812 devices, the device's reset time etc.,
59  * necessary for configuring the @ref ws2812 "WS2812 device struct" to drive one or multiple
60  * WS2812 devices on STM8S based devices.
61  *
62  * NOTE: The library currently makes use of the STM8 Standard Peripheral Library meaning it is
63  * a required dependency to use this library.
64  *
65  * WARNING: All fields of the configuration object must be defined before passing it to #ws2812_config()!
66  * Leaving a field undefined will result in undefined behaivor!
67  */
68 typedef struct ws2812_cfg {
69  uint16_t port_baseaddr;
70  GPIO_Pin_TypeDef *pins;
71  uint8_t rst_time_us;
73  uint8_t n_dev;
75 
76 // General description necessary for Doxygen
77 
90 /*
91  * WS2812 device struct to drive one or more WS2812 devices on STM8S based platforms.
92  *
93  * The following struct is used to drive one or more WS2812 devices on STM8S based devices.
94  * It is initialized by the ws2812_config() function and is taken as an argument by practically
95  * every function of the TinyWS2812 library relevant to driving WS2812 devices (ex. ws2812_tx(),
96  * ws2812_prep_tx(), etc...).
97  *
98  * See ws2812_config()
99  *
100  */
101 typedef struct ws2812 {
102  uint16_t port_baseaddr;
103  uint8_t rst_time_us;
104  uint8_t maskhi;
105  uint8_t masklo;
106  uint8_t rgbmap[3];
108 
109 #endif
ALL PLATFORMS: Data structure to configure a WS2812 device struct.
Definition: ws2812_avr.h:64
uint8_t n_dev
Number of WS2812 device to drive.
Definition: ws2812_avr.h:78
uint8_t rst_time_us
Time required for the WS2812 device(s) to reset in us.
Definition: ws2812_avr.h:76
uint16_t port_baseaddr
Base address of the port used to drive WS2812 devices (ex. GPIOA_BASE, GPIOB_BASE,...
Definition: ws2812_stm8s.h:69
GPIO_Pin_TypeDef * pins
Array of pins used to drive WS2812 devices (ex. GPIO_PIN_1, GPIO_PIN_2, etc...)
Definition: ws2812_stm8s.h:70
ws2812_order order
CoColor order of the WS2812 device(s) (ex. rgb, grb, bgr...)
Definition: ws2812_avr.h:77
ALL PLATFORMS: WS2812 device struct to drive one or more WS2812 devices.
Definition: ws2812_avr.h:107
uint16_t port_baseaddr
Base address of the port used to drive WS2812 devices (ex. GPIOA_BASE, GPIOB_BASE,...
Definition: ws2812_stm8s.h:102
uint8_t rgbmap[3]
RGB map to map/convert RGB values to another color order.
Definition: ws2812_avr.h:112
uint8_t rst_time_us
Time required for WS2812 to reset in us.
Definition: ws2812_avr.h:109
uint8_t masklo
PORT masks to toggle the data pins low.
Definition: ws2812_avr.h:111
uint8_t maskhi
PORT masks to toggle the data pins high.
Definition: ws2812_avr.h:110
Definitions required by all platform specific headers.
ws2812_order
Enum to specify the WS2812 device's color order.
Definition: ws2812_common.h:44
struct ws2812 ws2812
ALL PLATFORMS: WS2812 device struct to drive one or more WS2812 devices.
struct ws2812_cfg ws2812_cfg
ALL PLATFORMS: Data structure to configure a WS2812 device struct.