48 #ifndef __DRV_EXT_LIGHT_H__ 49 #define __DRV_EXT_LIGHT_H__ 52 #include "app_error.h" 53 #include "drv_sx1509.h" 54 #include "sx150x_led_drv_regs.h" 55 #include "sx150x_led_drv_calc.h" 56 #include "app_timer.h" 58 #define DRV_EXT_LIGHT_INTENSITY_MAX ((uint8_t)(0xFF)) 59 #define DRV_EXT_LIGHT_INTENSITY_OFF (0) 61 #define DRV_EXT_LIGHT_MAX_PIN_ID_ALLOWED 16 62 #define DRV_EXT_LIGHT_NUM_LIGHTS_MAX (((DRV_SX1509_HIGHINPMODE_PIN15_Pos + 1) < (16)) ? \ 63 (DRV_SX1509_HIGHINPMODE_PIN15_Pos + 1) : (16)) 64 #define DRV_EXT_LIGHT_IOEXT_CLKX_DIV_MAX (DRV_SX1509_MISC_CLKX_Msk >> DRV_SX1509_MISC_CLKX_Pos) 65 #define DRV_EXT_LIGHT_INVALID_RESYNC_PIN 255 82 DRV_EXT_LIGHT_CLKX_DIV_1 = 1,
83 DRV_EXT_LIGHT_CLKX_DIV_2 ,
84 DRV_EXT_LIGHT_CLKX_DIV_4 ,
85 DRV_EXT_LIGHT_CLKX_DIV_8 ,
86 DRV_EXT_LIGHT_CLKX_DIV_16,
87 DRV_EXT_LIGHT_CLKX_DIV_32,
88 DRV_EXT_LIGHT_CLKX_DIV_64,
95 DRV_EXT_LIGHT_COLOR_NONE,
96 DRV_EXT_LIGHT_COLOR_RED,
97 DRV_EXT_LIGHT_COLOR_GREEN,
98 DRV_EXT_LIGHT_COLOR_YELLOW,
99 DRV_EXT_LIGHT_COLOR_BLUE,
100 DRV_EXT_LIGHT_COLOR_PURPLE,
101 DRV_EXT_LIGHT_COLOR_CYAN,
102 DRV_EXT_LIGHT_COLOR_WHITE
128 #define DRV_EXT_LIGHT_STATUS_INIT \ 130 .active_time_ms = 0, \ 131 .inactive_time_ms = 0, \ 132 .colors = DRV_EXT_LIGHT_COLOR_NONE, \ 133 .ioext_osc_status = EXTENDER_OSC_UNUSED \ 146 #define DRV_EXT_LIGHT_DEF(light_id) \ 147 static drv_ext_light_status_t light_id##_timings = DRV_EXT_LIGHT_STATUS_INIT; \ 148 static app_timer_t light_id##_timer_data = { {0} }; \ 149 static drv_ext_light_data_t light_id = {.p_status = &light_id##_timings, .timer = &light_id##_timer_data} \ 207 #define SEQUENCE_REAL_VAL_INIT(PARAM) drv_ext_light_sequence_t PARAM = SEQUENCE_DEFAULT_VAL uint8_t mono
Monochrome pin.
Definition: drv_ext_light.h:166
drv_ext_light_data_t * p_data
Associated data for this light (app timer and timings).
Definition: drv_ext_light.h:174
The color mix and sequence variables if a sequence (e.g. breathe) is used.
Definition: drv_ext_light.h:199
drv_ext_light_conf_t const * p_light_conf
Array of lights, each with their specific configuraion.
Definition: drv_ext_light.h:181
drv_sx1509_cfg_t const * p_twi_conf
pointer to TWI (I2C) configuration for communication between master and IO extender.
Definition: drv_ext_light.h:184
SX1509 configuration.
Definition: drv_sx1509.h:70
The type of light is not supported.
Definition: drv_ext_light.h:73
Ext osc not used for this light.
Definition: drv_ext_light.h:109
drv_ext_light_clkx_div_t
Defines the frequency of the LED driver clock (ClkX) of the SX1509 according to ClkX = fOSC/2^(DRV_EX...
Definition: drv_ext_light.h:80
uint8_t r
Red intensity.
Definition: drv_ext_light.h:192
Not supported.
Definition: drv_ext_light.h:72
ret_code_t drv_ext_light_rgb_sequence(uint32_t id, drv_ext_light_rgb_sequence_t *const p_sequence)
Function for setting color for a given light through the GPIO extender.
Simplified struct for setting RGB intensity directly.
Definition: drv_ext_light.h:190
drv_ext_light_color_mix_t color
Color mix used for the sequence.
Definition: drv_ext_light.h:201
ret_code_t drv_ext_light_init(drv_ext_light_init_t const *p_init, bool on_init_reset)
Function for initializing the drv_ext_light driver.
uint8_t g
RGB G pin.
Definition: drv_ext_light.h:170
drv_ext_light_ioext_osc_status_t
The state of the IO extender oscillator for each light.
Definition: drv_ext_light.h:107
uint8_t r
RGB R pin.
Definition: drv_ext_light.h:169
Ext osc used on a permanent basis (light dimmed).
Definition: drv_ext_light.h:112
Number of different possible IO extender oscillator statuses.
Definition: drv_ext_light.h:113
drv_ext_light_sequence_t sequence_vals
Defines sequence values: on/off/fade_in/fade_out times, and on/off intensities.
Definition: drv_ext_light.h:202
ret_code_t drv_ext_light_on(uint32_t id)
Function for turning a given light on.
uint8_t resync_pin
Pin used to resync IO extender counters. Use DRV_EXT_LIGHT_INVALID_RESYNC_PIN if unused.
Definition: drv_ext_light.h:185
ret_code_t drv_ext_light_sequence(uint32_t id, drv_ext_light_sequence_t *const p_sequence)
Function for setting color for a given light through the GPIO extender.
Struct for initializing the light driver.
Definition: drv_ext_light.h:179
ret_code_t drv_ext_light_rgb_intensity_set(uint32_t id, drv_ext_light_rgb_intensity_t const *const p_intensity)
Function for setting color for RGB LEDs.
uint8_t b
RGB B pin.
Definition: drv_ext_light.h:171
Ext osc running (Light currently on).
Definition: drv_ext_light.h:110
ret_code_t drv_ext_light_intensity_set(uint32_t id, uint8_t intensity)
Function for setting intensity of monochrome light.
App timer and internal light timing struct.
Definition: drv_ext_light.h:138
app_timer_id_t timer
App timer information.
Definition: drv_ext_light.h:141
drv_ext_light_status_t * p_status
Light status information.
Definition: drv_ext_light.h:140
Monochrome (single) LED.
Definition: drv_ext_light.h:155
ret_code_t drv_ext_light_reset(void)
Function for resetting all the registers of the IO extender to their default values.
drv_ext_light_reg_type_t type
Monochrome or RGB.
Definition: drv_ext_light.h:163
Struct used by the app_timer handler, mainly for power saving.
Definition: drv_ext_light.h:118
uint32_t inactive_time_ms
Total time for a light to be off.
Definition: drv_ext_light.h:121
Ext osc paused (Light currently off).
Definition: drv_ext_light.h:111
drv_ext_light_reg_type_t
Monochrome (single) or RGB light.
Definition: drv_ext_light.h:153
ret_code_t drv_ext_light_off(uint32_t id)
Function for turning a given light off.
Invalid parameters.
Definition: drv_ext_light.h:71
drv_ext_light_color_mix_t
The following color combinations are possible when using drv_ext_light_rgb_sequence_t.
Definition: drv_ext_light.h:93
uint8_t g
Green intensity.
Definition: drv_ext_light.h:193
RGB LED (three IOs used).
Definition: drv_ext_light.h:156
Struct that defines the type of light (monochrome or RGB) and the corresponding connected pins...
Definition: drv_ext_light.h:161
drv_ext_light_ioext_osc_status_t ioext_osc_status
Status, holds information on the current use of the IO extender oscillator.
Definition: drv_ext_light.h:123
uint32_t active_time_ms
Total time for a light to be on or dimmed.
Definition: drv_ext_light.h:120
drv_ext_light_color_mix_t colors
Color mix used for breathe, single-shot, or blink.
Definition: drv_ext_light.h:122
uint8_t num_lights
Number of connected lights.
Definition: drv_ext_light.h:182
drv_ext_light_clkx_div_t clkx_div
IO extender clock divider.
Definition: drv_ext_light.h:183
The desired time is too long. Increase the ClkX divider.
Definition: drv_ext_light.h:74
Successful.
Definition: drv_ext_light.h:70
uint8_t b
Blue intensity.
Definition: drv_ext_light.h:194