a752c7ab
elopes
add first test an...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
/*
* Copyright (C) 2017 HAW Hamburg
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup drivers_my9221 MY9221 LED controller
* @ingroup drivers_actuators
* @brief Driver for the MY-Semi MY9221 LED controller
*
* @{
* @file
* @brief Interface for the MY9221 LED controller driver
*
* @author Sebastian Meiling <s@mlng.net>
*/
#ifndef MY9221_H
#define MY9221_H
#include <stdint.h>
#include "periph/gpio.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Maximum number of distinct LEDs the controller can operate
*/
#define MY9221_LED_MAX (12U)
/**
* @brief Max brightness value to turn LED full on
*/
#define MY9221_LED_ON (0xFF)
/**
* @brief Min brightness value to turn LED off
*/
#define MY9221_LED_OFF (0x00)
/**
* @name Direction the controller accesses LEDs
* @{
*/
enum {
MY9221_DIR_FWD, /**< forward */
MY9221_DIR_REV, /**< backward */
};
/** @} */
/**
* @name Driver specific return codes
* @{
*/
enum {
MY9221_OK, /**< success */
MY9221_ERR, /**< failure */
};
/** @} */
/**
* @brief Parameters needed for device initialization
*/
typedef struct {
uint8_t leds; /**< number of LEDs */
uint8_t dir; /**< led direction */
gpio_t clk; /**< clock gpio pin */
gpio_t dat; /**< data gpio pin */
} my9221_params_t;
/**
* @brief Device descriptor for MY9221 LED controller
*/
typedef struct {
my9221_params_t params; /**< config parameters */
uint8_t state[MY9221_LED_MAX]; /**< state of individual leds */
} my9221_t;
/**
* @brief Initialize the given driver
*
* @param[out] dev device descriptor of MY9221 LED controller
* @param[in] params configuration parameters
*
* @return 0 on success, otherwise error
*/
int my9221_init(my9221_t *dev, const my9221_params_t *params);
/**
* @brief Set device state
*
* @note If @p state is NULL or @p len is 0, current device state is set
* otherwise, current state is overwritten by @p state.
*
* @param[in] dev device descriptor of MY9221 LED controller
* @param[in] state new device state array
* @param[in] len length of state array
*/
void my9221_set_state(my9221_t *dev, const uint8_t *state, uint8_t len);
/**
* @brief Set brightness of distinct LED
*
* @param[in] dev device descriptor of MY9221 LED controller
* @param[in] led led number, start with 0
* @param[in] alpha brightness level for led
*/
void my9221_set_led(my9221_t *dev, const uint8_t led, const uint8_t alpha);
/**
* @brief Toggle a distinct LED
*
* @param[in] dev device descriptor of MY9221 LED controller
* @param[in] led led number, start with 0
*/
void my9221_toggle_led(my9221_t *dev, const uint8_t led);
#ifdef __cplusplus
}
#endif
#endif /* MY9221_H */
/** @} */
|