spiisolator3 2.0.0.0
spiisolator3.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 SPIISOLATOR3_H
29#define SPIISOLATOR3_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_spi_master.h"
52
53
54
76#define SPIISOLATOR3_PIN_STATE_LOW 0
77#define SPIISOLATOR3_PIN_STATE_HIGH 1
78
79 // spiisolator3_set
80
95#define SPIISOLATOR3_MAP_MIKROBUS( cfg, mikrobus ) \
96 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
97 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
98 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
99 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
100 cfg.saa = MIKROBUS( mikrobus, MIKROBUS_AN ); \
101 cfg.oen = MIKROBUS( mikrobus, MIKROBUS_RST ); \
102 cfg.aux = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
103 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
104
105 // spiisolator3_map
106 // spiisolator3
107
112typedef struct
113{
114 // Output pins
115
116 digital_out_t saa;
117 digital_out_t oen;
118 digital_out_t aux;
120 // Input pins
121
122 digital_in_t flt;
124 // Modules
125
126 spi_master_t spi;
128 pin_name_t chip_select;
131
136typedef struct
137{
138 // Communication gpio pins
139
140 pin_name_t miso;
141 pin_name_t mosi;
142 pin_name_t sck;
143 pin_name_t cs;
145 // Additional gpio pins
146
147 pin_name_t saa;
148 pin_name_t oen;
149 pin_name_t aux;
150 pin_name_t flt;
152 // static variable
153
154 uint32_t spi_speed;
155 spi_master_mode_t spi_mode;
156 spi_master_chip_select_polarity_t cs_polarity;
159
170
187
203
218
234err_t spiisolator3_generic_write ( spiisolator3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
235
251err_t spiisolator3_generic_read ( spiisolator3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
252
264void spiisolator3_set_side_a_active ( spiisolator3_t *ctx, uint8_t saa_state );
265
277void spiisolator3_set_sdo_enable ( spiisolator3_t *ctx, uint8_t sdo_state );
278
290void spiisolator3_set_aux ( spiisolator3_t *ctx, uint8_t aux_state );
291
304
305#ifdef __cplusplus
306}
307#endif
308#endif // SPIISOLATOR3_H
309
310 // spiisolator3
311
312// ------------------------------------------------------------------------ END
err_t spiisolator3_generic_write(spiisolator3_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
SPI Isolator 3 data writing function.
err_t spiisolator3_init(spiisolator3_t *ctx, spiisolator3_cfg_t *cfg)
SPI Isolator 3 initialization function.
err_t spiisolator3_default_cfg(spiisolator3_t *ctx)
SPI Isolator 3 default configuration function.
void spiisolator3_set_aux(spiisolator3_t *ctx, uint8_t aux_state)
SPI Isolator 3 set AUX function.
uint8_t spiisolator3_get_fault(spiisolator3_t *ctx)
SPI Isolator 3 get fault state function.
void spiisolator3_set_side_a_active(spiisolator3_t *ctx, uint8_t saa_state)
SPI Isolator 3 set side A active function.
void spiisolator3_cfg_setup(spiisolator3_cfg_t *cfg)
SPI Isolator 3 configuration object setup function.
void spiisolator3_set_sdo_enable(spiisolator3_t *ctx, uint8_t sdo_state)
SPI Isolator 3 set SDO enable function.
err_t spiisolator3_generic_read(spiisolator3_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
SPI Isolator 3 data reading function.
spiisolator3_return_value_t
SPI Isolator 3 Click return value data.
Definition spiisolator3.h:165
@ SPIISOLATOR3_ERROR
Definition spiisolator3.h:167
@ SPIISOLATOR3_OK
Definition spiisolator3.h:166
SPI Isolator 3 Click configuration object.
Definition spiisolator3.h:137
spi_master_chip_select_polarity_t cs_polarity
Definition spiisolator3.h:156
pin_name_t aux
Definition spiisolator3.h:149
pin_name_t sck
Definition spiisolator3.h:142
spi_master_mode_t spi_mode
Definition spiisolator3.h:155
pin_name_t mosi
Definition spiisolator3.h:141
uint32_t spi_speed
Definition spiisolator3.h:154
pin_name_t flt
Definition spiisolator3.h:150
pin_name_t miso
Definition spiisolator3.h:140
pin_name_t oen
Definition spiisolator3.h:148
pin_name_t saa
Definition spiisolator3.h:147
pin_name_t cs
Definition spiisolator3.h:143
SPI Isolator 3 Click context object.
Definition spiisolator3.h:113
spi_master_t spi
Definition spiisolator3.h:126
digital_in_t flt
Definition spiisolator3.h:122
digital_out_t aux
Definition spiisolator3.h:118
digital_out_t oen
Definition spiisolator3.h:117
digital_out_t saa
Definition spiisolator3.h:116
pin_name_t chip_select
Definition spiisolator3.h:128