spiisolator8 2.1.0.0
spiisolator8.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 SPIISOLATOR8_H
29#define SPIISOLATOR8_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#include "spi_specifics.h"
53
73#define SPIISOLATOR8_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
74#define SPIISOLATOR8_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
75
76 // spiisolator8_set
77
92#define SPIISOLATOR8_MAP_MIKROBUS( cfg, mikrobus ) \
93 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
94 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
95 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
96 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
97 cfg.enc = MIKROBUS( mikrobus, MIKROBUS_AN ); \
98 cfg.enp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
99 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
100
101 // spiisolator8_map
102 // spiisolator8
103
108typedef struct
109{
110 // Output pins
111 digital_out_t enc;
112 digital_out_t enp;
114 // Input pins
115 digital_in_t flt;
117 // Modules
118 spi_master_t spi;
120 pin_name_t chip_select;
123
128typedef struct
129{
130 // Communication gpio pins
131 pin_name_t miso;
132 pin_name_t mosi;
133 pin_name_t sck;
134 pin_name_t cs;
136 // Additional gpio pins
137 pin_name_t enc;
138 pin_name_t enp;
139 pin_name_t flt;
141 // static variable
142 uint32_t spi_speed;
143 spi_master_mode_t spi_mode;
144 spi_master_chip_select_polarity_t cs_polarity;
147
158
175
190
202
215
228
241
254
269
283err_t spiisolator8_write ( spiisolator8_t *ctx, uint8_t *data_in, uint8_t len );
284
298err_t spiisolator8_read ( spiisolator8_t *ctx, uint8_t *data_out, uint8_t len_out );
299
315err_t spiisolator8_write_then_read ( spiisolator8_t *ctx, uint8_t *data_in, uint8_t len_in,
316 uint8_t *data_out, uint8_t len_out );
317
332err_t spiisolator8_transfer ( spiisolator8_t *ctx, uint8_t *data_in, uint8_t *data_out, uint8_t len );
333
334#ifdef __cplusplus
335}
336#endif
337#endif // SPIISOLATOR8_H
338
339 // spiisolator8
340
341// ------------------------------------------------------------------------ END
void spiisolator8_enp_disable(spiisolator8_t *ctx)
SPI Isolator 8 disable side 2 function.
uint8_t spiisolator8_get_fault(spiisolator8_t *ctx)
SPI Isolator 8 get fault function.
err_t spiisolator8_transfer(spiisolator8_t *ctx, uint8_t *data_in, uint8_t *data_out, uint8_t len)
SPI Isolator 8 data transfer function.
void spiisolator8_enp_enable(spiisolator8_t *ctx)
SPI Isolator 8 enable side 2 function.
err_t spiisolator8_read(spiisolator8_t *ctx, uint8_t *data_out, uint8_t len_out)
SPI Isolator 8 data reading function.
void spiisolator8_enc_enable(spiisolator8_t *ctx)
SPI Isolator 8 enable side 1 function.
err_t spiisolator8_write_then_read(spiisolator8_t *ctx, uint8_t *data_in, uint8_t len_in, uint8_t *data_out, uint8_t len_out)
SPI Isolator 8 write then read function.
void spiisolator8_default_cfg(spiisolator8_t *ctx)
SPI Isolator 8 default configuration function.
err_t spiisolator8_init(spiisolator8_t *ctx, spiisolator8_cfg_t *cfg)
SPI Isolator 8 initialization function.
void spiisolator8_cfg_setup(spiisolator8_cfg_t *cfg)
SPI Isolator 8 configuration object setup function.
err_t spiisolator8_write(spiisolator8_t *ctx, uint8_t *data_in, uint8_t len)
SPI Isolator 8 data writing function.
void spiisolator8_enc_disable(spiisolator8_t *ctx)
SPI Isolator 8 disable side 1 function.
This file contains SPI specific macros, functions, etc.
spiisolator8_return_value_t
SPI Isolator 8 Click return value data.
Definition spiisolator8.h:153
@ SPIISOLATOR8_OK
Definition spiisolator8.h:154
@ SPIISOLATOR8_ERROR
Definition spiisolator8.h:155
SPI Isolator 8 Click configuration object.
Definition spiisolator8.h:129
pin_name_t enc
Definition spiisolator8.h:137
spi_master_chip_select_polarity_t cs_polarity
Definition spiisolator8.h:144
pin_name_t sck
Definition spiisolator8.h:133
spi_master_mode_t spi_mode
Definition spiisolator8.h:143
pin_name_t mosi
Definition spiisolator8.h:132
uint32_t spi_speed
Definition spiisolator8.h:142
pin_name_t enp
Definition spiisolator8.h:138
pin_name_t flt
Definition spiisolator8.h:139
pin_name_t miso
Definition spiisolator8.h:131
pin_name_t cs
Definition spiisolator8.h:134
SPI Isolator 8 Click context object.
Definition spiisolator8.h:109
spi_master_t spi
Definition spiisolator8.h:118
digital_out_t enp
Definition spiisolator8.h:112
digital_in_t flt
Definition spiisolator8.h:115
digital_out_t enc
Definition spiisolator8.h:111
pin_name_t chip_select
Definition spiisolator8.h:120