Loading...
Searching...
No Matches
pca9633.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#ifdef __cplusplus
20extern "C"
21{
22#endif
23
24#include "stdbool.h"
25#include "periph/i2c.h"
26
27#include "pca9633_regs.h"
28
32#define PCA9633_BLINKING_PERIOD_MAX_MS (10625)
33
39#define PCA9633_BLINKING_RATIO_BALANCED 128
40
44typedef struct {
46 uint16_t i2c_addr;
47
48 uint8_t reg_pwm_red;
49 uint8_t reg_pwm_green;
50 uint8_t reg_pwm_blue;
51 uint8_t reg_pwm_amber;
52
55
63
67enum {
70};
71
81
111
147
162
178int pca9633_init(pca9633_t *dev, const pca9633_params_t *params);
179
190
202
209
216
225 pca9633_pwm_channel_t pwm_channel, uint8_t pwm);
226
233void pca9633_set_grp_pwm(pca9633_t* dev, uint8_t pwm);
234
249void pca9633_set_blinking(pca9633_t* dev, uint16_t blink_period_ms,
250 uint8_t on_off_ratio);
251
260void pca9633_set_rgb(pca9633_t* dev, uint8_t r, uint8_t g, uint8_t b);
261
271void pca9633_set_rgba(pca9633_t* dev, uint8_t r, uint8_t g, uint8_t b, uint8_t w);
272
287 pca9633_pwm_channel_t pwm_channel);
288
301
315
327
328#ifdef __cplusplus
329}
330#endif
331
void pca9633_set_ldr_state_all(pca9633_t *dev, pca9633_ldr_state_t state)
Set the LED driver output state for all channels.
void pca9633_turn_off(pca9633_t *dev)
Turn off all LEDs.
void pca9633_set_auto_increment(pca9633_t *dev, pca9633_auto_inc_option_t option)
Set an option for auto increment.
void pca9633_sleep(pca9633_t *dev)
Switch to low power mode.
pca9633_ldr_state_t
LED driver output state, LEDOUT (page 14, below table 13)
Definition pca9633.h:85
void pca9633_set_pwm(pca9633_t *dev, pca9633_pwm_channel_t pwm_channel, uint8_t pwm)
Set individual PWM signal for a given channel.
void pca9633_set_blinking(pca9633_t *dev, uint16_t blink_period_ms, uint8_t on_off_ratio)
Set up values for blinking mode.
void pca9633_set_group_control_mode(pca9633_t *dev, pca9633_group_control_mode_t mode)
Set the group control mode.
void pca9633_set_grp_pwm(pca9633_t *dev, uint8_t pwm)
Set global PWM signal.
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_auto_inc_option_t
Auto-Increment options (page 10, table 6)
Definition pca9633.h:115
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_pwm_channel_t
PCA9633 PWM channel definitions.
Definition pca9633.h:75
void pca9633_set_rgb(pca9633_t *dev, uint8_t r, uint8_t g, uint8_t b)
Set PWM values for RGB.
pca9633_group_control_mode_t
PCA9633 group control modes.
Definition pca9633.h:151
int pca9633_init(pca9633_t *dev, const pca9633_params_t *params)
Initialization.
void pca9633_wakeup(pca9633_t *dev)
Switch to normal mode.
void pca9633_turn_on(pca9633_t *dev)
Turn on all LEDs.
@ PCA9633_LDR_STATE_IND_GRP
LED driver x individual brightness and group dimming/ blinking can be controlled through its PWMx reg...
Definition pca9633.h:109
@ PCA9633_LDR_STATE_ON
LED driver x is fully on (individual brightness and group dimming/ blinking not controlled)
Definition pca9633.h:95
@ PCA9633_LDR_STATE_IND
LED driver x individual brightness can be controlled through its PWMx register.
Definition pca9633.h:101
@ PCA9633_LDR_STATE_OFF
LED driver x is off.
Definition pca9633.h:89
@ PCA9633_OK
Success.
Definition pca9633.h:68
@ PCA9633_ERROR_I2C
I2C communication error.
Definition pca9633.h:69
@ PCA9633_AI_IND
Auto-Increment for individual brightness registers only.
Definition pca9633.h:132
@ PCA9633_AI_ALL
Auto-Increment for all registers.
Definition pca9633.h:125
@ PCA9633_AI_GBL
Auto-Increment for global control registers only.
Definition pca9633.h:138
@ PCA9633_AI_DISABLED
No Auto-Increment.
Definition pca9633.h:119
@ PCA9633_AI_IND_GBL
Auto-Increment for individual and global control registers only.
Definition pca9633.h:145
@ PCA9633_PWM_CHANNEL_1
PWM channel 1.
Definition pca9633.h:77
@ PCA9633_PWM_CHANNEL_3
PWM channel 3.
Definition pca9633.h:79
@ PCA9633_PWM_CHANNEL_2
PWM channel 2.
Definition pca9633.h:78
@ PCA9633_PWM_CHANNEL_0
PWM channel 0.
Definition pca9633.h:76
@ PCA9633_GROUP_CONTROL_MODE_DIMMING
Control mode for dimming.
Definition pca9633.h:160
@ PCA9633_GROUP_CONTROL_MODE_BLINKING
Control mode for blinking.
Definition pca9633.h:155
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Low-level I2C peripheral driver interface definition.
Register definitions for the PCA9633 I2C PWM controller.
#define PCA9633_REG_PWM0
Brightness control LED0.
#define PCA9633_REG_PWM2
Brightness control LED2.
#define PCA9633_REG_PWM1
Brightness control LED1.
#define PCA9633_REG_PWM3
Brightness control LED3.
PCA9633 device initialization parameters.
Definition pca9633.h:44
uint8_t reg_pwm_blue
Register for blue color.
Definition pca9633.h:50
uint8_t reg_pwm_green
Register for green color.
Definition pca9633.h:49
uint8_t reg_pwm_amber
Register for amber color.
Definition pca9633.h:51
i2c_t i2c_dev
I2C device.
Definition pca9633.h:45
uint8_t reg_pwm_red
Register for red color.
Definition pca9633.h:48
uint16_t i2c_addr
I2C address of device.
Definition pca9633.h:46
bool has_amber_channel
Whether PCA9633 has fourth channel.
Definition pca9633.h:53
PCA9633 PWM device data structure type.
Definition pca9633.h:59
uint8_t stored_reg_ledout
Stored register content of LEDOUT.
Definition pca9633.h:61
pca9633_params_t params
Device initialization parameters.
Definition pca9633.h:60