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 I2CEXTEND_REG_CONFIG 0x00
74#define I2CEXTEND_REG_STATUS 0x01
75#define I2CEXTEND_REG_EVENT 0x02
76#define I2CEXTEND_REG_ALERT_EN 0x03
77#define I2CEXTEND_REG_FAULT 0x04
78#define I2CEXTEND_REG_SCRATCH 0x05
79#define I2CEXTEND_REG_ADDR_TRANS 0x06
80#define I2CEXTEND_REG_CTRL 0x07
86#define C6DOFIMU11_REG_WHO_AM_I 0x00
87#define C6DOFIMU11_REG_CNTL2 0x3A
88#define C6DOFIMU11_REG_INC3 0x2C
89#define C6DOFIMU11_REG_ACCEL_XOUT_L 0x0A
90#define C6DOFIMU11_REG_ACCEL_YOUT_L 0x0C
91#define C6DOFIMU11_REG_ACCEL_ZOUT_L 0x0E
92#define C6DOFIMU11_REG_MAG_XOUT_L 0x10
93#define C6DOFIMU11_REG_MAG_YOUT_L 0x12
94#define C6DOFIMU11_REG_MAG_ZOUT_L 0x14
112#define I2CEXTEND_CONFIG_INTR_MODE_BIT_MASK 0x01
113#define I2CEXTEND_CONFIG_INTR_MODE_SET_ALERT_PIN 0x00
114#define I2CEXTEND_CONFIG_INTR_MODE_IGNORE_ARA 0x01
115#define I2CEXTEND_CONFIG_CTRL_SEL_BIT_MASK 0x02
116#define I2CEXTEND_CONFIG_CTRL_SEL_MIRRORED_RMT_OUT 0x00
117#define I2CEXTEND_CONFIG_CTRL_SEL_USE_REG_CTRL_VAL 0x02
123#define I2CEXTEND_ALERT_EN_LINK_GOOD_DISABLE 0x00
124#define I2CEXTEND_ALERT_EN_LINK_GOOD 0x01
125#define I2CEXTEND_ALERT_EN_LINK_LOST_DISABLE 0x00
126#define I2CEXTEND_ALERT_EN_LINK_LOST 0x02
127#define I2CEXTEND_ALERT_EN_FAULT_DISABLE 0x00
128#define I2CEXTEND_ALERT_EN_FAULT 0x04
134#define I2CEXTEND_CTRL_SEL_L 0x00
135#define I2CEXTEND_CTRL_SEL_H 0x01
141#define I2CEXTEND_PIN_STATE_LOW 0x00
142#define I2CEXTEND_PIN_STATE_HIGH 0x01
148#define C6DOFIMU11_CNTL2_TEMP_EN_STANDBY_MODE 0x00
149#define C6DOFIMU11_CNTL2_MAG_EN_STANDBY_MODE 0x00
150#define C6DOFIMU11_CNTL2_ACCEL_EN_STANDBY_MODE 0x00
151#define C6DOFIMU11_INC3_IEL2_FIFO_TRIG 0x20
152#define C6DOFIMU11_INC3_IEL1_FIFO_TRIG 0x02
153#define C6DOFIMU11_CNTL2_ACCEL_EN_OPERATING_MODE 0x01
154#define C6DOFIMU11_CNTL2_GSEL_8G 0x00
155#define C6DOFIMU11_CNTL2_RES_MAX2 0x0C
156#define C6DOFIMU11_CNTL2_MAG_EN_OPERATING_MODE 0x02
157#define C6DOFIMU11_WHO_AM_I_WIA_ID 0x2D
164#define I2CEXTEND_I2C_SLAVE_ADDR_0 0x3E
165#define I2CEXTEND_I2C_SLAVE_ADDR_1 0x3F
166#define I2CEXTEND_I2C_SLAVE_ADDR_2 0x76
167#define I2CEXTEND_I2C_SLAVE_ADDR_3 0x77
174#define C6DOFIMU11_I2C_SLAVE_ADDRESS_GND 0x0E
175#define C6DOFIMU11_I2C_SLAVE_ADDRESS_VCC 0x0F
193#define I2CEXTEND_MAP_MIKROBUS( cfg, mikrobus ) \
194 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
195 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
196 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
197 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
198 cfg.on = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
199 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
uint8_t i2cextend_generic_read(i2cextend_t *ctx, uint8_t reg)
Generic read data function.
void i2cextend_generic_write(i2cextend_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write data function.
void i2cextend_fault(i2cextend_t *ctx, i2cextend_fault_data_t *fault_data)
Check the fault state function.
err_t i2cextend_init(i2cextend_t *ctx, i2cextend_cfg_t *cfg)
I2C Extend initialization function.
void i2cextend_status(i2cextend_t *ctx, i2cextend_status_data_t *status_data)
Check the status function.
uint8_t i2cextend_rmt_read(i2cextend_t *ctx, uint8_t rmt_slave_addr, uint8_t reg)
Generic read data in Remote Mode function.
void i2cextend_rmt_write(i2cextend_t *ctx, uint8_t rmt_slave_addr, uint8_t reg, uint8_t tx_data)
Generic write data in Remote Mode function.
uint8_t i2cextend_check_int(i2cextend_t *ctx)
Check interrupt ststus function.
void i2cextend_set_cs(i2cextend_t *ctx, uint8_t en_cs)
Set CS pin state function.
void i2cextend_rmt_multi_read(i2cextend_t *ctx, uint8_t rmt_slave_addr, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes)
Generic multi read data in Remote Mode function.
void i2cextend_rmt_multi_write(i2cextend_t *ctx, uint8_t rmt_slave_addr, uint8_t reg, uint8_t *p_tx_data, uint8_t n_bytes)
Generic multi write data in Remote Mode function.
void i2cextend_set_on(i2cextend_t *ctx, uint8_t on_state)
Set ON pin state function.
void i2cextend_cfg_setup(i2cextend_cfg_t *cfg)
I2C Extend configuration object setup function.
void i2cextend_set_out_slave_address(i2cextend_t *ctx, uint8_t out_slave_address)
Set out slave address function.
void i2cextend_set_out_ctrl(i2cextend_t *ctx, uint8_t out_ctrl)
Set out CTRL function.
void i2cextend_enable_alerts(i2cextend_t *ctx, uint8_t link_good, uint8_t link_lost, uint8_t fault)
Set enable alerts function.
uint8_t i2cextend_get_scratch(i2cextend_t *ctx)
Get scratch function.
void i2cextend_set_config(i2cextend_t *ctx, uint8_t intr_mode, uint8_t ctrl_sel)
Set the configuration function.
void i2cextend_set_rst(i2cextend_t *ctx, uint8_t en_rst)
Set RTS pin state function.
i2cextend_return_value_t
I2C Extend Click return value data.
Definition i2cextend.h:274
@ I2CEXTEND_OK
Definition i2cextend.h:275
@ I2CEXTEND_ERROR
Definition i2cextend.h:276
I2C Extend Click configuration object.
Definition i2cextend.h:231
uint32_t i2c_speed
Definition i2cextend.h:240
pin_name_t on
Definition i2cextend.h:237
pin_name_t scl
Definition i2cextend.h:232
pin_name_t int_pin
Definition i2cextend.h:238
pin_name_t sda
Definition i2cextend.h:233
pin_name_t rst
Definition i2cextend.h:236
pin_name_t cs
Definition i2cextend.h:235
uint8_t i2c_address
Definition i2cextend.h:241
I2C Extend Click fault data.
Definition i2cextend.h:262
uint8_t link_fault
Definition i2cextend.h:264
uint8_t tx_buf_overflow
Definition i2cextend.h:266
uint8_t ext_i2c_fault
Definition i2cextend.h:265
uint8_t i2c_write_fault
Definition i2cextend.h:263
I2C Extend Click status data.
Definition i2cextend.h:250
uint8_t speed_idx
Definition i2cextend.h:254
uint8_t ext_nalert
Definition i2cextend.h:253
uint8_t nalert
Definition i2cextend.h:252
uint8_t nlink
Definition i2cextend.h:251
I2C Extend Click context object.
Definition i2cextend.h:209
digital_out_t cs
Definition i2cextend.h:211
digital_out_t on
Definition i2cextend.h:213
digital_in_t int_pin
Definition i2cextend.h:216
i2c_master_t i2c
Definition i2cextend.h:219
digital_out_t rst
Definition i2cextend.h:212
uint8_t slave_address
Definition i2cextend.h:222