i2cisolator5 2.1.0.0
i2cisolator5.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 I2CISOLATOR5_H
29#define I2CISOLATOR5_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
73#define I2CISOLATOR5_PIN_STATE_HIGH 0x01
74#define I2CISOLATOR5_PIN_STATE_LOW 0x00
75
81#define I2CISOLATOR5_DEVICE_ADDRESS 0x00
82
83 // i2cisolator5_set
84
99#define I2CISOLATOR5_MAP_MIKROBUS( cfg, mikrobus ) \
100 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
101 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
102 cfg.otb = MIKROBUS( mikrobus, MIKROBUS_RST ); \
103 cfg.ota = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
104 cfg.ina = MIKROBUS( mikrobus, MIKROBUS_INT )
105
106 // i2cisolator5_map
107 // i2cisolator5
108
113typedef struct
114{
115 // Output pins
116 digital_out_t otb;
117 digital_out_t ota;
119 // Input pins
120 digital_in_t ina;
122 // Modules
123 i2c_master_t i2c;
125 // I2C slave address
129
134typedef struct
135{
136 pin_name_t scl;
137 pin_name_t sda;
139 pin_name_t otb;
140 pin_name_t ota;
141 pin_name_t ina;
143 uint32_t i2c_speed;
144 uint8_t i2c_address;
147
158
175
190
204
217err_t i2cisolator5_write ( i2cisolator5_t *ctx, uint8_t *data_in, uint8_t len );
218
231err_t i2cisolator5_read ( i2cisolator5_t *ctx, uint8_t *data_out, uint8_t len );
232
252err_t i2cisolator5_write_then_read ( i2cisolator5_t *ctx, uint8_t *data_in, uint8_t data_in_len,
253 uint8_t *data_out, uint8_t data_out_len );
254
267err_t i2cisolator5_set_slave_address ( i2cisolator5_t *ctx, uint8_t address );
268
278void i2cisolator5_set_outa_state ( i2cisolator5_t *ctx, uint8_t outa_state );
279
289void i2cisolator5_set_outb_state ( i2cisolator5_t *ctx, uint8_t outb_state );
290
300
301#ifdef __cplusplus
302}
303#endif
304#endif // I2CISOLATOR5_H
305
306 // i2cisolator5
307
308// ------------------------------------------------------------------------ END
err_t i2cisolator5_init(i2cisolator5_t *ctx, i2cisolator5_cfg_t *cfg)
I2C Isolator 5 initialization function.
uint8_t i2cisolator5_get_ina_state(i2cisolator5_t *ctx)
I2C Isolator 5 get input A state function.
err_t i2cisolator5_write(i2cisolator5_t *ctx, uint8_t *data_in, uint8_t len)
I2C Isolator 5 I2C writing function.
void i2cisolator5_cfg_setup(i2cisolator5_cfg_t *cfg)
I2C Isolator 5 configuration object setup function.
void i2cisolator5_set_outb_state(i2cisolator5_t *ctx, uint8_t outb_state)
I2C Isolator 5 set output B state function.
err_t i2cisolator5_write_then_read(i2cisolator5_t *ctx, uint8_t *data_in, uint8_t data_in_len, uint8_t *data_out, uint8_t data_out_len)
I2C Isolator 5 I2C write then read function.
void i2cisolator5_set_outa_state(i2cisolator5_t *ctx, uint8_t outa_state)
I2C Isolator 5 set output A state function.
err_t i2cisolator5_default_cfg(i2cisolator5_t *ctx)
I2C Isolator 5 default configuration function.
err_t i2cisolator5_read(i2cisolator5_t *ctx, uint8_t *data_out, uint8_t len)
I2C Isolator 5 I2C reading function.
err_t i2cisolator5_set_slave_address(i2cisolator5_t *ctx, uint8_t address)
I2C Isolator 5 set I2C Slave address function.
i2cisolator5_return_value_t
I2C Isolator 5 Click return value data.
Definition i2cisolator5.h:153
@ I2CISOLATOR5_ERROR
Definition i2cisolator5.h:155
@ I2CISOLATOR5_OK
Definition i2cisolator5.h:154
I2C Isolator 5 Click configuration object.
Definition i2cisolator5.h:135
uint32_t i2c_speed
Definition i2cisolator5.h:143
pin_name_t otb
Definition i2cisolator5.h:139
pin_name_t ina
Definition i2cisolator5.h:141
pin_name_t ota
Definition i2cisolator5.h:140
pin_name_t scl
Definition i2cisolator5.h:136
pin_name_t sda
Definition i2cisolator5.h:137
uint8_t i2c_address
Definition i2cisolator5.h:144
I2C Isolator 5 Click context object.
Definition i2cisolator5.h:114
digital_out_t otb
Definition i2cisolator5.h:116
digital_out_t ota
Definition i2cisolator5.h:117
i2c_master_t i2c
Definition i2cisolator5.h:123
uint8_t slave_address
Definition i2cisolator5.h:126
digital_in_t ina
Definition i2cisolator5.h:120