pca9633.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 Freie Universität Berlin
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 
20 #ifndef PCA9633_H
21 #define PCA9633_H
22 
23 #ifdef __cplusplus
24 extern "C"
25 {
26 #endif
27 
28 #include "stdbool.h"
29 #include "periph/i2c.h"
30 
31 #include "pca9633_regs.h"
32 
36 #define PCA9633_BLINKING_PERIOD_MAX_MS (10625)
37 
43 #define PCA9633_BLINKING_RATIO_BALANCED 128
44 
48 typedef struct {
50  uint16_t i2c_addr;
52  uint8_t reg_pwm_red;
53  uint8_t reg_pwm_green;
54  uint8_t reg_pwm_blue;
55  uint8_t reg_pwm_amber;
59 
63 typedef struct {
66 } pca9633_t;
67 
71 enum {
72  PCA9633_OK = 0,
74 };
75 
79 typedef enum {
85 
89 typedef enum {
94 
100 
106 
115 
119 typedef enum {
124 
130 
137 
143 
151 
155 typedef enum {
160 
166 
182 int pca9633_init(pca9633_t *dev, const pca9633_params_t *params);
183 
193 void pca9633_turn_on(pca9633_t* dev);
194 
205 void pca9633_turn_off(pca9633_t* dev);
206 
212 void pca9633_wakeup(pca9633_t* dev);
213 
219 void pca9633_sleep(pca9633_t* dev);
220 
228 void pca9633_set_pwm(pca9633_t* dev,
229  pca9633_pwm_channel_t pwm_channel, uint8_t pwm);
230 
237 void pca9633_set_grp_pwm(pca9633_t* dev, uint8_t pwm);
238 
253 void pca9633_set_blinking(pca9633_t* dev, uint16_t blink_period_ms,
254  uint8_t on_off_ratio);
255 
264 void pca9633_set_rgb(pca9633_t* dev, uint8_t r, uint8_t g, uint8_t b);
265 
275 void pca9633_set_rgba(pca9633_t* dev, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
276 
290  pca9633_ldr_state_t state,
291  pca9633_pwm_channel_t pwm_channel);
292 
305 
319 
331 
332 #ifdef __cplusplus
333 }
334 #endif
335 
336 #endif /* PCA9633_H */
337 
PCA9633_LDR_STATE_IND
@ PCA9633_LDR_STATE_IND
LED driver x individual brightness can be controlled through its PWMx register.
Definition: pca9633.h:105
pca9633_params_t::has_amber_channel
bool has_amber_channel
Whether PCA9633 has fourth channel.
Definition: pca9633.h:57
PCA9633_ERROR_I2C
@ PCA9633_ERROR_I2C
I2C communication error.
Definition: pca9633.h:73
pca9633_params_t::reg_pwm_amber
uint8_t reg_pwm_amber
Register for amber color.
Definition: pca9633.h:55
PCA9633_LDR_STATE_IND_GRP
@ PCA9633_LDR_STATE_IND_GRP
LED driver x individual brightness and group dimming/ blinking can be controlled through its PWMx reg...
Definition: pca9633.h:113
PCA9633_REG_PWM3
#define PCA9633_REG_PWM3
Brightness control LED3.
Definition: pca9633_regs.h:57
pca9633_regs.h
Register definitions for the PCA9633 I2C PWM controller.
pca9633_set_rgb
void pca9633_set_rgb(pca9633_t *dev, uint8_t r, uint8_t g, uint8_t b)
Set PWM values for RGB.
PCA9633_PWM_CHANNEL_1
@ PCA9633_PWM_CHANNEL_1
PWM channel 1.
Definition: pca9633.h:81
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
pca9633_params_t::i2c_addr
uint16_t i2c_addr
I2C address of device.
Definition: pca9633.h:50
pca9633_set_auto_increment
void pca9633_set_auto_increment(pca9633_t *dev, pca9633_auto_inc_option_t option)
Set an option for auto increment.
pca9633_params_t::i2c_dev
i2c_t i2c_dev
I2C device.
Definition: pca9633.h:49
pca9633_t
PCA9633 PWM device data structure type.
Definition: pca9633.h:63
pca9633_sleep
void pca9633_sleep(pca9633_t *dev)
Switch to low power mode.
pca9633_set_ldr_state_all
void pca9633_set_ldr_state_all(pca9633_t *dev, pca9633_ldr_state_t state)
Set the LED driver output state for all channels.
pca9633_group_control_mode_t
pca9633_group_control_mode_t
PCA9633 group control modes.
Definition: pca9633.h:155
pca9633_turn_on
void pca9633_turn_on(pca9633_t *dev)
Turn on all LEDs.
pca9633_t::stored_reg_ledout
uint8_t stored_reg_ledout
Stored register content of LEDOUT.
Definition: pca9633.h:65
pca9633_params_t::reg_pwm_red
uint8_t reg_pwm_red
Register for red color.
Definition: pca9633.h:52
PCA9633_REG_PWM1
#define PCA9633_REG_PWM1
Brightness control LED1.
Definition: pca9633_regs.h:47
pca9633_set_rgba
void pca9633_set_rgba(pca9633_t *dev, uint8_t r, uint8_t g, uint8_t b, uint8_t w)
Set PWM values for RGBA.
pca9633_t::params
pca9633_params_t params
Device initialization parameters.
Definition: pca9633.h:64
PCA9633_AI_ALL
@ PCA9633_AI_ALL
Auto-Increment for all registers.
Definition: pca9633.h:129
pca9633_set_grp_pwm
void pca9633_set_grp_pwm(pca9633_t *dev, uint8_t pwm)
Set global PWM signal.
pca9633_params_t
PCA9633 device initialization parameters.
Definition: pca9633.h:48
PCA9633_AI_IND_GBL
@ PCA9633_AI_IND_GBL
Auto-Increment for individual and global control registers only.
Definition: pca9633.h:149
pca9633_auto_inc_option_t
pca9633_auto_inc_option_t
Auto-Increment options (page 10, table 6)
Definition: pca9633.h:119
PCA9633_REG_PWM2
#define PCA9633_REG_PWM2
Brightness control LED2.
Definition: pca9633_regs.h:52
PCA9633_PWM_CHANNEL_2
@ PCA9633_PWM_CHANNEL_2
PWM channel 2.
Definition: pca9633.h:82
pca9633_set_pwm
void pca9633_set_pwm(pca9633_t *dev, pca9633_pwm_channel_t pwm_channel, uint8_t pwm)
Set individual PWM signal for a given channel.
PCA9633_AI_IND
@ PCA9633_AI_IND
Auto-Increment for individual brightness registers only.
Definition: pca9633.h:136
pca9633_params_t::reg_pwm_green
uint8_t reg_pwm_green
Register for green color.
Definition: pca9633.h:53
PCA9633_LDR_STATE_OFF
@ PCA9633_LDR_STATE_OFF
LED driver x is off.
Definition: pca9633.h:93
PCA9633_PWM_CHANNEL_0
@ PCA9633_PWM_CHANNEL_0
PWM channel 0.
Definition: pca9633.h:80
pca9633_init
int pca9633_init(pca9633_t *dev, const pca9633_params_t *params)
Initialization.
pca9633_ldr_state_t
pca9633_ldr_state_t
LED driver output state, LEDOUT (page 14, below table 13)
Definition: pca9633.h:89
pca9633_set_blinking
void pca9633_set_blinking(pca9633_t *dev, uint16_t blink_period_ms, uint8_t on_off_ratio)
Set up values for blinking mode.
PCA9633_AI_DISABLED
@ PCA9633_AI_DISABLED
No Auto-Increment.
Definition: pca9633.h:123
PCA9633_GROUP_CONTROL_MODE_BLINKING
@ PCA9633_GROUP_CONTROL_MODE_BLINKING
Control mode for blinking.
Definition: pca9633.h:159
pca9633_wakeup
void pca9633_wakeup(pca9633_t *dev)
Switch to normal mode.
PCA9633_REG_PWM0
#define PCA9633_REG_PWM0
Brightness control LED0.
Definition: pca9633_regs.h:42
pca9633_params_t::reg_pwm_blue
uint8_t reg_pwm_blue
Register for blue color.
Definition: pca9633.h:54
PCA9633_PWM_CHANNEL_3
@ PCA9633_PWM_CHANNEL_3
PWM channel 3.
Definition: pca9633.h:83
pca9633_set_ldr_state
void pca9633_set_ldr_state(pca9633_t *dev, pca9633_ldr_state_t state, pca9633_pwm_channel_t pwm_channel)
Set the LED driver output state for a given channel.
pca9633_set_group_control_mode
void pca9633_set_group_control_mode(pca9633_t *dev, pca9633_group_control_mode_t mode)
Set the group control mode.
PCA9633_GROUP_CONTROL_MODE_DIMMING
@ PCA9633_GROUP_CONTROL_MODE_DIMMING
Control mode for dimming.
Definition: pca9633.h:164
PCA9633_AI_GBL
@ PCA9633_AI_GBL
Auto-Increment for global control registers only.
Definition: pca9633.h:142
i2c.h
Low-level I2C peripheral driver interface definition.
pca9633_pwm_channel_t
pca9633_pwm_channel_t
PCA9633 PWM channel definitions.
Definition: pca9633.h:79
PCA9633_OK
@ PCA9633_OK
Success.
Definition: pca9633.h:72
pca9633_turn_off
void pca9633_turn_off(pca9633_t *dev)
Turn off all LEDs.
PCA9633_LDR_STATE_ON
@ PCA9633_LDR_STATE_ON
LED driver x is fully on (individual brightness and group dimming/ blinking not controlled)
Definition: pca9633.h:99