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
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
38 
64 #define C6DOFIMU11_REG_WHO_AM_I 0x00
65 #define C6DOFIMU11_REG_CNTL2 0x3A
66 #define C6DOFIMU11_REG_INC3 0x2C
67 #define C6DOFIMU11_REG_ACCEL_XOUT_L 0x0A
68 #define C6DOFIMU11_REG_ACCEL_YOUT_L 0x0C
69 #define C6DOFIMU11_REG_ACCEL_ZOUT_L 0x0E
70 #define C6DOFIMU11_REG_MAG_XOUT_L 0x10
71 #define C6DOFIMU11_REG_MAG_YOUT_L 0x12
72 #define C6DOFIMU11_REG_MAG_ZOUT_L 0x14
73  // i2cextend2_reg
75 
90 #define I2CEXTEND2_EXTEND_DISABLE 0x00
91 #define I2CEXTEND2_EXTEND_ENABLE 0x01
92 
97 #define I2CEXTEND_PIN_STATE_LOW 0x00
98 #define I2CEXTEND_PIN_STATE_HIGH 0x01
99 
104 #define C6DOFIMU11_CNTL2_TEMP_EN_STANDBY_MODE 0x00
105 #define C6DOFIMU11_CNTL2_MAG_EN_STANDBY_MODE 0x00
106 #define C6DOFIMU11_CNTL2_ACCEL_EN_STANDBY_MODE 0x00
107 #define C6DOFIMU11_INC3_IEL2_FIFO_TRIG 0x20
108 #define C6DOFIMU11_INC3_IEL1_FIFO_TRIG 0x02
109 #define C6DOFIMU11_CNTL2_ACCEL_EN_OPERATING_MODE 0x01
110 #define C6DOFIMU11_CNTL2_GSEL_8G 0x00
111 #define C6DOFIMU11_CNTL2_RES_MAX2 0x0C
112 #define C6DOFIMU11_CNTL2_MAG_EN_OPERATING_MODE 0x02
113 #define C6DOFIMU11_WHO_AM_I_WIA_ID 0x2D
114 
120 #define C6DOFIMU11_I2C_SLAVE_ADDRESS_GND 0x0E
121 #define C6DOFIMU11_I2C_SLAVE_ADDRESS_VCC 0x0F
122  // i2cextend2_set
124 
139 #define I2CEXTEND2_MAP_MIKROBUS( cfg, mikrobus ) \
140  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
141  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
142  cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS )
143  // i2cextend2_map // i2cextend2
146 
151 typedef struct
152 {
153  // Output pins
154  digital_out_t en;
156  // Modules
157  i2c_master_t i2c;
159  // I2C slave address
160  uint8_t slave_address;
162 } i2cextend2_t;
163 
168 typedef struct
169 {
170  pin_name_t scl;
171  pin_name_t sda;
173  pin_name_t en;
175  uint32_t i2c_speed;
176  uint8_t i2c_address;
179 
184 typedef enum
185 {
187  I2CEXTEND2_ERROR = -1
188 
190 
207 
222 err_t i2cextend2_init ( i2cextend2_t *ctx, i2cextend2_cfg_t *cfg );
223 
235 void i2cextend2_rmt_write ( i2cextend2_t *ctx, uint8_t reg, uint8_t tx_data );
236 
247 uint8_t i2cextend2_rmt_read ( i2cextend2_t *ctx, uint8_t reg );
248 
261 void i2cextend2_rmt_multi_write ( i2cextend2_t *ctx, uint8_t reg, uint8_t *p_tx_data, uint8_t n_bytes );
262 
275 void i2cextend2_rmt_multi_read ( i2cextend2_t *ctx, uint8_t reg, uint8_t *p_rx_data, uint8_t n_bytes );
276 
289 void i2cextend2_enable ( i2cextend2_t *ctx, uint8_t en_extend );
290 
291 #ifdef __cplusplus
292 }
293 #endif
294 #endif // I2CEXTEND2_H
295  // i2cextend2
297 
298 // ------------------------------------------------------------------------ END
i2cextend2_return_value_t
i2cextend2_return_value_t
I2C Extend 2 Click return value data.
Definition: i2cextend2.h:183
i2cextend2_rmt_multi_read
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.
i2cextend2_rmt_write
void i2cextend2_rmt_write(i2cextend2_t *ctx, uint8_t reg, uint8_t tx_data)
Generic write data in Remote Mode function.
i2cextend2_enable
void i2cextend2_enable(i2cextend2_t *ctx, uint8_t en_extend)
Enable extend function.
i2cextend2_rmt_multi_write
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.
i2cextend2_init
err_t i2cextend2_init(i2cextend2_t *ctx, i2cextend2_cfg_t *cfg)
I2C Extend 2 initialization function.
i2cextend2_cfg_setup
void i2cextend2_cfg_setup(i2cextend2_cfg_t *cfg)
I2C Extend 2 configuration object setup function.
I2CEXTEND2_ERROR
Definition: i2cextend2.h:186
i2cextend2_cfg_t
I2C Extend 2 Click configuration object.
Definition: i2cextend2.h:167
i2cextend2_t
I2C Extend 2 Click context object.
Definition: i2cextend2.h:150
I2CEXTEND2_OK
Definition: i2cextend2.h:185
i2cextend2_rmt_read
uint8_t i2cextend2_rmt_read(i2cextend2_t *ctx, uint8_t reg)
Generic read data in Remote Mode function.