my9221.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef MY9221_H
22 #define MY9221_H
23 
24 #include <stdint.h>
25 
26 #include "periph/gpio.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
35 #define MY9221_LED_MAX (12U)
36 
40 #define MY9221_LED_ON (0xFF)
41 
45 #define MY9221_LED_OFF (0x00)
46 
51 enum {
54 };
61 enum {
64 };
70 typedef struct {
71  uint8_t leds;
72  uint8_t dir;
73  gpio_t clk;
74  gpio_t dat;
76 
80 typedef struct {
82  uint8_t state[MY9221_LED_MAX];
83 } my9221_t;
84 
93 int my9221_init(my9221_t *dev, const my9221_params_t *params);
94 
105 void my9221_set_state(my9221_t *dev, const uint8_t *state, uint8_t len);
106 
114 void my9221_set_led(my9221_t *dev, const uint8_t led, const uint8_t alpha);
115 
122 void my9221_toggle_led(my9221_t *dev, const uint8_t led);
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* MY9221_H */
129 
MY9221_OK
@ MY9221_OK
success
Definition: my9221.h:62
my9221_params_t::dir
uint8_t dir
led direction
Definition: my9221.h:72
MY9221_ERR
@ MY9221_ERR
failure
Definition: my9221.h:63
my9221_params_t::leds
uint8_t leds
number of LEDs
Definition: my9221.h:71
my9221_params_t::clk
gpio_t clk
clock gpio pin
Definition: my9221.h:73
my9221_set_led
void my9221_set_led(my9221_t *dev, const uint8_t led, const uint8_t alpha)
Set brightness of distinct LED.
MY9221_DIR_FWD
@ MY9221_DIR_FWD
forward
Definition: my9221.h:52
my9221_init
int my9221_init(my9221_t *dev, const my9221_params_t *params)
Initialize the given driver.
my9221_set_state
void my9221_set_state(my9221_t *dev, const uint8_t *state, uint8_t len)
Set device state.
my9221_toggle_led
void my9221_toggle_led(my9221_t *dev, const uint8_t led)
Toggle a distinct LED.
my9221_t
Device descriptor for MY9221 LED controller.
Definition: my9221.h:80
my9221_t::params
my9221_params_t params
config parameters
Definition: my9221.h:81
gpio.h
Low-level GPIO peripheral driver interface definitions.
my9221_params_t::dat
gpio_t dat
data gpio pin
Definition: my9221.h:74
MY9221_DIR_REV
@ MY9221_DIR_REV
backward
Definition: my9221.h:53
my9221_params_t
Parameters needed for device initialization.
Definition: my9221.h:70
MY9221_LED_MAX
#define MY9221_LED_MAX
Maximum number of distinct LEDs the controller can operate.
Definition: my9221.h:35