i2cmux7  2.0.0.0
i2cmux7.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 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 I2CMUX7_H
29 #define I2CMUX7_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 
59 #define I2CMUX7_CHANNEL_DISABLE 0x00
60 #define I2CMUX7_CHANNEL_0 0x08
61 #define I2CMUX7_CHANNEL_1 0x09
62 #define I2CMUX7_CHANNEL_2 0x0A
63 #define I2CMUX7_CHANNEL_3 0x0B
64 #define I2CMUX7_CHANNEL_4 0x0C
65 #define I2CMUX7_CHANNEL_5 0x0D
66 #define I2CMUX7_CHANNEL_6 0x0E
67 #define I2CMUX7_CHANNEL_7 0x0F
68 #define I2CMUX7_CHANNEL_NUM_MASK 0x07
69 
75 #define I2CMUX7_DEV_ADDR_A2A1A0_000 0x70
76 #define I2CMUX7_DEV_ADDR_A2A1A0_001 0x71
77 #define I2CMUX7_DEV_ADDR_A2A1A0_010 0x72
78 #define I2CMUX7_DEV_ADDR_A2A1A0_011 0x73
79 #define I2CMUX7_DEV_ADDR_A2A1A0_100 0x74
80 #define I2CMUX7_DEV_ADDR_A2A1A0_101 0x75
81 #define I2CMUX7_DEV_ADDR_A2A1A0_110 0x76
82 #define I2CMUX7_DEV_ADDR_A2A1A0_111 0x77
83  // i2cmux7_set
85 
100 #define I2CMUX7_MAP_MIKROBUS( cfg, mikrobus ) \
101  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
102  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
103  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST );
104  // i2cmux7_map // i2cmux7
107 
112 typedef struct
113 {
114  // Output pins
115  digital_out_t rst;
117  // Modules
118  i2c_master_t i2c;
120  // I2C slave address
121  uint8_t slave_address;
124 } i2cmux7_t;
125 
130 typedef struct
131 {
132  pin_name_t scl;
133  pin_name_t sda;
135  pin_name_t rst;
137  uint32_t i2c_speed;
138  uint8_t i2c_address;
140 } i2cmux7_cfg_t;
141 
146 typedef enum
147 {
149  I2CMUX7_ERROR = -1
150 
152 
169 
184 err_t i2cmux7_init ( i2cmux7_t *ctx, i2cmux7_cfg_t *cfg );
185 
198 err_t i2cmux7_set_channel ( i2cmux7_t *ctx, uint8_t ch_sel, uint8_t ch_slave_addr );
199 
211 err_t i2cmux7_read_channel ( i2cmux7_t *ctx, uint8_t *ch_sel );
212 
222 
237 err_t i2cmux7_generic_write ( i2cmux7_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
238 
253 err_t i2cmux7_generic_read ( i2cmux7_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 #endif // I2CMUX7_H
259  // i2cmux7
261 
262 // ------------------------------------------------------------------------ END
i2cmux7_cfg_t::sda
pin_name_t sda
Definition: i2cmux7.h:133
i2cmux7_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: i2cmux7.h:137
i2cmux7_t::i2c
i2c_master_t i2c
Definition: i2cmux7.h:118
i2cmux7_t::ch_slave_address
uint8_t ch_slave_address
Definition: i2cmux7.h:122
i2cmux7_t::slave_address
uint8_t slave_address
Definition: i2cmux7.h:121
i2cmux7_cfg_t::i2c_address
uint8_t i2c_address
Definition: i2cmux7.h:138
i2cmux7_cfg_setup
void i2cmux7_cfg_setup(i2cmux7_cfg_t *cfg)
I2C MUX 7 configuration object setup function.
i2cmux7_set_channel
err_t i2cmux7_set_channel(i2cmux7_t *ctx, uint8_t ch_sel, uint8_t ch_slave_addr)
I2C MUX 7 set channel function.
i2cmux7_cfg_t::rst
pin_name_t rst
Definition: i2cmux7.h:135
i2cmux7_init
err_t i2cmux7_init(i2cmux7_t *ctx, i2cmux7_cfg_t *cfg)
I2C MUX 7 initialization function.
i2cmux7_read_channel
err_t i2cmux7_read_channel(i2cmux7_t *ctx, uint8_t *ch_sel)
I2C MUX 7 read channel function.
i2cmux7_generic_write
err_t i2cmux7_generic_write(i2cmux7_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
I2C MUX 7 I2C writing function.
i2cmux7_reset_device
void i2cmux7_reset_device(i2cmux7_t *ctx)
I2C MUX 7 reset device function.
I2CMUX7_OK
@ I2CMUX7_OK
Definition: i2cmux7.h:148
i2cmux7_t
I2C MUX 7 Click context object.
Definition: i2cmux7.h:113
I2CMUX7_ERROR
@ I2CMUX7_ERROR
Definition: i2cmux7.h:149
i2cmux7_cfg_t::scl
pin_name_t scl
Definition: i2cmux7.h:132
i2cmux7_return_value_t
i2cmux7_return_value_t
I2C MUX 7 Click return value data.
Definition: i2cmux7.h:147
i2cmux7_generic_read
err_t i2cmux7_generic_read(i2cmux7_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
I2C MUX 7 I2C reading function.
i2cmux7_cfg_t
I2C MUX 7 Click configuration object.
Definition: i2cmux7.h:131
i2cmux7_t::rst
digital_out_t rst
Definition: i2cmux7.h:115