39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define C2X2RGB_REG_ID 0x00
74#define C2X2RGB_REG_MONITOR 0x01
75#define C2X2RGB_REG_CONTROL 0x02
76#define C2X2RGB_REG_IRED1 0x03
77#define C2X2RGB_REG_IGRN1 0x04
78#define C2X2RGB_REG_IBLU1 0x05
79#define C2X2RGB_REG_IRED2 0x06
80#define C2X2RGB_REG_IGRN2 0x07
81#define C2X2RGB_REG_IBLU2 0x08
82#define C2X2RGB_REG_IRED3 0x09
83#define C2X2RGB_REG_IGRN3 0x0A
84#define C2X2RGB_REG_IBLU3 0x0B
85#define C2X2RGB_REG_IRED4 0x0C
86#define C2X2RGB_REG_IGRN4 0x0D
87#define C2X2RGB_REG_IBLU4 0x0E
88#define C2X2RGB_REG_PG_CNTL 0x0F
89#define C2X2RGB_REG_PG_FADE 0x10
90#define C2X2RGB_REG_PG_RGB1 0x11
91#define C2X2RGB_REG_PG_RGB2 0x12
92#define C2X2RGB_REG_PG_RGB3 0x13
93#define C2X2RGB_REG_PG_RGB4 0x14
94#define C2X2RGB_REG_PG_WD 0x15
112#define C2X2RGB_SET_LD1 1
113#define C2X2RGB_SET_LD2 2
114#define C2X2RGB_SET_LD3 3
115#define C2X2RGB_SET_LD4 4
121#define C2X2RGB_DEV_ID 0x06
122#define C2X2RGB_DEV_ID_BIT_MASK 0x0F
123#define C2X2RGB_VEN_ID 0x05
124#define C2X2RGB_VEN_ID_BIT_MASK 0x07
130#define C2X2RGB_MONITOR_UV_OT_STAT 0x01
131#define C2X2RGB_MONITOR_COOL_STAT 0x02
132#define C2X2RGB_MONITOR_BE_STAT 0x04
133#define C2X2RGB_MONITOR_SC_STAT 0x08
139#define C2X2RGB_LED_CURRENT_OFF 0
140#define C2X2RGB_LED_CURRENT_3MA 3000
141#define C2X2RGB_LED_CURRENT_MAX 24000
142#define C2X2RGB_LED_CURRENT_STEP 125
149#define C2X2RGB_EN_MODE_SHUTDOWN 0x00
150#define C2X2RGB_EN_MODE_NIGHT 0x01
151#define C2X2RGB_EN_MODE_NORMAL 0x02
152#define C2X2RGB_EN_MODE_SW_RESET 0x03
153#define C2X2RGB_EN_MODE_BIT_MASK 0xC0
154#define C2X2RGB_BE_DISABLE 0x00
155#define C2X2RGB_BE_ENABLE 0x01
156#define C2X2RGB_BE_BIT_MASK 0x20
157#define C2X2RGB_CE_TEMP_135C 0x00
158#define C2X2RGB_CE_TEMP_120C 0x01
159#define C2X2RGB_CE_TEMP_105C 0x02
160#define C2X2RGB_CE_TEMP_90C 0x03
161#define C2X2RGB_CE_TEMP_BIT_MASK 0x18
162#define C2X2RGB_FADE_RATE0_32_MS 0x00
163#define C2X2RGB_FADE_RATE0_63_MS 0x01
164#define C2X2RGB_FADE_RATE0_125_MS 0x02
165#define C2X2RGB_FADE_RATE0_250_MS 0x03
166#define C2X2RGB_FADE_RATE0_500_MS 0x04
167#define C2X2RGB_FADE_RATE0_1_S 0x05
168#define C2X2RGB_FADE_RATE0_2_S 0x06
169#define C2X2RGB_FADE_RATE0_4_S 0x07
170#define C2X2RGB_FADE_RATE0_BIT_MASK 0x07
176#define C2X2RGB_PG_MODE_OFF 0x00
177#define C2X2RGB_PG_MODE_4P_EN 0x01
178#define C2X2RGB_PG_MODE_6P_EN 0x02
179#define C2X2RGB_PG_MODE_8P_EN 0x03
180#define C2X2RGB_PG_MODE_BIT_MASK 0xC0
181#define C2X2RGB_PG_TIME_188_MS 0x00
182#define C2X2RGB_PG_TIME_2_S 0x0F
183#define C2X2RGB_PG_TIME_BIT_MASK 0x3C
185#define C2X2RGB_FADE_RATE1_32_MS 0x00
186#define C2X2RGB_FADE_RATE1_4_S 0x07
187#define C2X2RGB_FADE_RATE1_BIT_MASK 0x07
195#define C2X2RGB_DEVICE_ADDRESS 0x74
213#define C2X2RGB_MAP_MIKROBUS( cfg, mikrobus ) \
214 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
215 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
388 uint8_t *cool_stat, uint8_t *uv_ot_stat );
405 uint8_t ce_temp, uint8_t fade_rate );
c2x2rgb_return_value_t
2x2 RGB Click return value data.
Definition c2x2rgb.h:276
@ C2X2RGB_ERROR
Definition c2x2rgb.h:278
@ C2X2RGB_OK
Definition c2x2rgb.h:277
err_t c2x2rgb_generic_write(c2x2rgb_t *ctx, uint8_t reg, uint8_t data_in)
2x2 RGB I2C writing function.
void c2x2rgb_cfg_setup(c2x2rgb_cfg_t *cfg)
2x2 RGB configuration object setup function.
err_t c2x2rgb_set_rgb_led(c2x2rgb_t *ctx, uint8_t led_num, uint16_t ired, uint16_t igrn, uint16_t iblu)
2x2 RGB set RGB LED function.
err_t c2x2rgb_set_pg_wd(c2x2rgb_t *ctx, uint8_t wd_pcr)
2x2 RGB set pattern watchdog counter function.
err_t c2x2rgb_set_all_rgb_led(c2x2rgb_t *ctx, c2x2rgb_rgb_led_t cfg_rgb_led)
2x2 RGB set all RGB LED function.
err_t c2x2rgb_set_control(c2x2rgb_t *ctx, uint8_t en_mode, uint8_t be_en, uint8_t ce_temp, uint8_t fade_rate)
2x2 RGB set control function.
err_t c2x2rgb_set_normal_mode(c2x2rgb_t *ctx)
2x2 RGB set normal mode function.
err_t c2x2rgb_get_device_id(c2x2rgb_t *ctx, uint8_t *vendor_id, uint8_t *device_id)
2x2 RGB get device ID function.
err_t c2x2rgb_set_pg_ctrl(c2x2rgb_t *ctx, uint8_t pg_mode, uint8_t pg_time, uint8_t fade_rate)
2x2 RGB set PG control function.
err_t c2x2rgb_set_pg_rgb(c2x2rgb_t *ctx, uint8_t led_num, uint8_t pg_rgb)
2x2 RGB set PG fade function.
err_t c2x2rgb_set_pg_fade(c2x2rgb_t *ctx, uint8_t pg_fade)
2x2 RGB set PG fade function.
err_t c2x2rgb_init(c2x2rgb_t *ctx, c2x2rgb_cfg_t *cfg)
2x2 RGB initialization function.
err_t c2x2rgb_default_cfg(c2x2rgb_t *ctx)
2x2 RGB default configuration function.
err_t c2x2rgb_sw_reset(c2x2rgb_t *ctx)
2x2 RGB set soft reset function.
err_t c2x2rgb_get_monitor_status(c2x2rgb_t *ctx, uint8_t *sc_stat, uint8_t *be_stat, uint8_t *cool_stat, uint8_t *uv_ot_stat)
2x2 RGB get monitor status function.
err_t c2x2rgb_generic_read(c2x2rgb_t *ctx, uint8_t reg, uint8_t *data_out)
2x2 RGB I2C reading function.
2x2 RGB Click configuration object.
Definition c2x2rgb.h:240
uint32_t i2c_speed
Definition c2x2rgb.h:244
pin_name_t scl
Definition c2x2rgb.h:241
pin_name_t sda
Definition c2x2rgb.h:242
uint8_t i2c_address
Definition c2x2rgb.h:245
2x2 RGB Click LED current setting object.
Definition c2x2rgb.h:254
uint16_t led3_iblu
Definition c2x2rgb.h:264
uint16_t led2_igrn
Definition c2x2rgb.h:260
uint16_t led1_ired
Definition c2x2rgb.h:256
uint16_t led3_ired
Definition c2x2rgb.h:262
uint16_t led4_iblu
Definition c2x2rgb.h:267
uint8_t en_mode
Definition c2x2rgb.h:255
uint16_t led3_igrn
Definition c2x2rgb.h:263
uint16_t led4_ired
Definition c2x2rgb.h:265
uint16_t led1_igrn
Definition c2x2rgb.h:257
uint16_t led1_iblu
Definition c2x2rgb.h:258
uint16_t led2_ired
Definition c2x2rgb.h:259
uint16_t led4_igrn
Definition c2x2rgb.h:266
uint16_t led2_iblu
Definition c2x2rgb.h:261
2x2 RGB Click context object.
Definition c2x2rgb.h:225
i2c_master_t i2c
Definition c2x2rgb.h:228
uint8_t slave_address
Definition c2x2rgb.h:231