i2cextend2 2.0.0.0
i2cextend2.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2021 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef I2CEXTEND2_H
29#define I2CEXTEND2_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
78#define C6DOFIMU11_REG_WHO_AM_I 0x00
79#define C6DOFIMU11_REG_CNTL2 0x3A
80#define C6DOFIMU11_REG_INC3 0x2C
81#define C6DOFIMU11_REG_ACCEL_XOUT_L 0x0A
82#define C6DOFIMU11_REG_ACCEL_YOUT_L 0x0C
83#define C6DOFIMU11_REG_ACCEL_ZOUT_L 0x0E
84#define C6DOFIMU11_REG_MAG_XOUT_L 0x10
85#define C6DOFIMU11_REG_MAG_YOUT_L 0x12
86#define C6DOFIMU11_REG_MAG_ZOUT_L 0x14
87
88 // i2cextend2_reg
89
104#define I2CEXTEND2_EXTEND_DISABLE 0x00
105#define I2CEXTEND2_EXTEND_ENABLE 0x01
106
111#define I2CEXTEND_PIN_STATE_LOW 0x00
112#define I2CEXTEND_PIN_STATE_HIGH 0x01
113
118#define C6DOFIMU11_CNTL2_TEMP_EN_STANDBY_MODE 0x00
119#define C6DOFIMU11_CNTL2_MAG_EN_STANDBY_MODE 0x00
120#define C6DOFIMU11_CNTL2_ACCEL_EN_STANDBY_MODE 0x00
121#define C6DOFIMU11_INC3_IEL2_FIFO_TRIG 0x20
122#define C6DOFIMU11_INC3_IEL1_FIFO_TRIG 0x02
123#define C6DOFIMU11_CNTL2_ACCEL_EN_OPERATING_MODE 0x01
124#define C6DOFIMU11_CNTL2_GSEL_8G 0x00
125#define C6DOFIMU11_CNTL2_RES_MAX2 0x0C
126#define C6DOFIMU11_CNTL2_MAG_EN_OPERATING_MODE 0x02
127#define C6DOFIMU11_WHO_AM_I_WIA_ID 0x2D
128
134#define C6DOFIMU11_I2C_SLAVE_ADDRESS_GND 0x0E
135#define C6DOFIMU11_I2C_SLAVE_ADDRESS_VCC 0x0F
136
137 // i2cextend2_set
138
153#define I2CEXTEND2_MAP_MIKROBUS( cfg, mikrobus ) \
154 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
155 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
156 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS )
157
158 // i2cextend2_map
159 // i2cextend2
160
165typedef struct
166{
167 // Output pins
168 digital_out_t en;
170 // Modules
171 i2c_master_t i2c;
173 // I2C slave address
177
182typedef struct
183{
184 pin_name_t scl;
185 pin_name_t sda;
187 pin_name_t en;
189 uint32_t i2c_speed;
190 uint8_t i2c_address;
193
204
221
236
248void i2cextend2_rmt_write ( i2cextend2_t *ctx, uint8_t reg, uint8_t tx_data );
249
260uint8_t i2cextend2_rmt_read ( i2cextend2_t *ctx, uint8_t reg );
261
274void i2cextend2_rmt_multi_write ( i2cextend2_t *ctx, uint8_t reg, uint8_t *p_tx_data, uint8_t n_bytes );
275
288void i2cextend2_rmt_multi_read ( i2cextend2_t *ctx, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes );
289
302void i2cextend2_enable ( i2cextend2_t *ctx, uint8_t en_extend );
303
304#ifdef __cplusplus
305}
306#endif
307#endif // I2CEXTEND2_H
308
309 // i2cextend2
310
311// ------------------------------------------------------------------------ END
void i2cextend2_rmt_multi_read(i2cextend2_t *ctx, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes)
Generic multi read data in Remote Mode function.
uint8_t i2cextend2_rmt_read(i2cextend2_t *ctx, uint8_t reg)
Generic read data in Remote Mode function.
void i2cextend2_cfg_setup(i2cextend2_cfg_t *cfg)
I2C Extend 2 configuration object setup function.
void i2cextend2_enable(i2cextend2_t *ctx, uint8_t en_extend)
Enable extend function.
void i2cextend2_rmt_multi_write(i2cextend2_t *ctx, uint8_t reg, uint8_t *p_tx_data, uint8_t n_bytes)
Generic multi write data in Remote Mode function.
err_t i2cextend2_init(i2cextend2_t *ctx, i2cextend2_cfg_t *cfg)
I2C Extend 2 initialization function.
void i2cextend2_rmt_write(i2cextend2_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write data in Remote Mode function.
i2cextend2_return_value_t
I2C Extend 2 Click return value data.
Definition i2cextend2.h:199
@ I2CEXTEND2_ERROR
Definition i2cextend2.h:201
@ I2CEXTEND2_OK
Definition i2cextend2.h:200
I2C Extend 2 Click configuration object.
Definition i2cextend2.h:183
uint32_t i2c_speed
Definition i2cextend2.h:189
pin_name_t scl
Definition i2cextend2.h:184
pin_name_t en
Definition i2cextend2.h:187
pin_name_t sda
Definition i2cextend2.h:185
uint8_t i2c_address
Definition i2cextend2.h:190
I2C Extend 2 Click context object.
Definition i2cextend2.h:166
i2c_master_t i2c
Definition i2cextend2.h:171
digital_out_t en
Definition i2cextend2.h:168
uint8_t slave_address
Definition i2cextend2.h:174