spiisolator5 2.1.0.0
spiisolator5.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 SPIISOLATOR5_H
29#define SPIISOLATOR5_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
78#define SPIISOLATOR5_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
79#define SPIISOLATOR5_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
80
81 // spiisolator5_set
82
97#define SPIISOLATOR5_MAP_MIKROBUS( cfg, mikrobus ) \
98 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
99 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
100 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
101 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
102 cfg.en = MIKROBUS( mikrobus, MIKROBUS_RST )
103
104 // spiisolator5_map
105 // spiisolator5
106
111typedef struct
112{
113 // Output pins
114 digital_out_t en;
116 // Modules
117 spi_master_t spi;
119 pin_name_t chip_select;
122
127typedef struct
128{
129 // Communication gpio pins
130 pin_name_t miso;
131 pin_name_t mosi;
132 pin_name_t sck;
133 pin_name_t cs;
135 // Additional gpio pins
136 pin_name_t en;
138 // static variable
139 uint32_t spi_speed;
140 spi_master_mode_t spi_mode;
141 spi_master_chip_select_polarity_t cs_polarity;
144
155
172
187
199
211
225err_t spiisolator5_write ( spiisolator5_t *ctx, uint8_t *data_in, uint8_t len );
226
240err_t spiisolator5_read ( spiisolator5_t *ctx, uint8_t *data_out, uint8_t len_out );
241
257err_t spiisolator5_write_then_read ( spiisolator5_t *ctx, uint8_t *data_in, uint8_t len_in, uint8_t *data_out, uint8_t len_out );
258
273err_t spiisolator5_transfer ( spiisolator5_t *ctx, uint8_t *data_in, uint8_t *data_out, uint8_t len );
274
275#ifdef __cplusplus
276}
277#endif
278#endif // SPIISOLATOR5_H
279
280 // spiisolator5
281
282// ------------------------------------------------------------------------ END
void spiisolator5_enable(spiisolator5_t *ctx)
SPI Isolator 5 enable function.
err_t spiisolator5_read(spiisolator5_t *ctx, uint8_t *data_out, uint8_t len_out)
SPI Isolator 5 data reading function.
err_t spiisolator5_transfer(spiisolator5_t *ctx, uint8_t *data_in, uint8_t *data_out, uint8_t len)
SPI Isolator 5 transfer function.
void spiisolator5_disable(spiisolator5_t *ctx)
SPI Isolator 5 disable function.
void spiisolator5_cfg_setup(spiisolator5_cfg_t *cfg)
SPI Isolator 5 configuration object setup function.
err_t spiisolator5_write(spiisolator5_t *ctx, uint8_t *data_in, uint8_t len)
SPI Isolator 5 data writing function.
err_t spiisolator5_write_then_read(spiisolator5_t *ctx, uint8_t *data_in, uint8_t len_in, uint8_t *data_out, uint8_t len_out)
SPI Isolator 5 write then read function.
err_t spiisolator5_init(spiisolator5_t *ctx, spiisolator5_cfg_t *cfg)
SPI Isolator 5 initialization function.
This file contains SPI specific macros, functions, etc.
spiisolator5_return_value_t
SPI Isolator 5 Click return value data.
Definition spiisolator5.h:150
@ SPIISOLATOR5_ERROR
Definition spiisolator5.h:152
@ SPIISOLATOR5_OK
Definition spiisolator5.h:151
SPI Isolator 5 Click configuration object.
Definition spiisolator5.h:128
spi_master_chip_select_polarity_t cs_polarity
Definition spiisolator5.h:141
pin_name_t sck
Definition spiisolator5.h:132
spi_master_mode_t spi_mode
Definition spiisolator5.h:140
pin_name_t mosi
Definition spiisolator5.h:131
uint32_t spi_speed
Definition spiisolator5.h:139
pin_name_t en
Definition spiisolator5.h:136
pin_name_t miso
Definition spiisolator5.h:130
pin_name_t cs
Definition spiisolator5.h:133
SPI Isolator 5 Click context object.
Definition spiisolator5.h:112
spi_master_t spi
Definition spiisolator5.h:117
digital_out_t en
Definition spiisolator5.h:114
pin_name_t chip_select
Definition spiisolator5.h:119