i2cisolator 2.0.0.0
i2cisolator.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef I2CISOLATOR_H
36#define I2CISOLATOR_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_i2c_master.h"
54
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define I2CISOLATOR_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
75#define I2CISOLATOR_RETVAL uint8_t
76
77#define I2CISOLATOR_OK 0x00
78#define I2CISOLATOR_INIT_ERROR 0xFF
81 // End group macro
82// --------------------------------------------------------------- PUBLIC TYPES
91typedef struct
92{
93
94 // Modules
95
96 i2c_master_t i2c;
97
98 // ctx variable
99
101
103
107typedef struct
108{
109 // Communication gpio pins
110
111 pin_name_t scl;
112 pin_name_t sda;
113
114
115 // static variable
116
117 uint32_t i2c_speed;
118 uint8_t i2c_address;
119
121
122#ifdef __cplusplus
123extern "C"{
124#endif
125
135
144
153
164void i2cisolator_generic_write ( i2cisolator_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
165
177void i2cisolator_generic_read ( i2cisolator_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
178
179#ifdef __cplusplus
180}
181#endif
182#endif // _I2CISOLATOR_H_
183
184 // End public_function group
186
187// ------------------------------------------------------------------------- END
#define I2CISOLATOR_RETVAL
Definition i2cisolator.h:75
void i2cisolator_cfg_setup(i2cisolator_cfg_t *cfg)
Config Object Initialization function.
void i2cisolator_generic_write(i2cisolator_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
void i2cisolator_generic_read(i2cisolator_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
I2CISOLATOR_RETVAL i2cisolator_init(i2cisolator_t *ctx, i2cisolator_cfg_t *cfg)
Initialization function.
void i2cisolator_default_cfg(i2cisolator_t *ctx)
Click Default Configuration function.
Click configuration structure definition.
Definition i2cisolator.h:108
uint32_t i2c_speed
Definition i2cisolator.h:117
pin_name_t scl
Definition i2cisolator.h:111
pin_name_t sda
Definition i2cisolator.h:112
uint8_t i2c_address
Definition i2cisolator.h:118
Click ctx object definition.
Definition i2cisolator.h:92
i2c_master_t i2c
Definition i2cisolator.h:96
uint8_t slave_address
Definition i2cisolator.h:100