spiisolator6 2.0.0.0
spiisolator6.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 SPIISOLATOR6_H
29#define SPIISOLATOR6_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
74#define SPIISOLATOR6_SPI_CLOCK_SPEED 100000
75#define SPIISOLATOR6_SPI_MODE SPI_MASTER_MODE_0
76#define SPIISOLATOR6_SPI_CS_POLARITY SPI_MASTER_CHIP_SELECT_POLARITY_ACTIVE_LOW
77#define SPIISOLATOR6_SPI_DUMMY_BYTE 0x00
78
87#define SPIISOLATOR6_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
88#define SPIISOLATOR6_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
89
90 // spiisolator6_set
91
106#define SPIISOLATOR6_MAP_MIKROBUS( cfg, mikrobus ) \
107 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
108 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
109 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
110 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
111
112 // spiisolator6_map
113 // spiisolator6
114
119typedef struct
120{
121 // Modules
122 spi_master_t spi;
124 pin_name_t chip_select;
127
132typedef struct
133{
134 // Communication gpio pins
135 pin_name_t miso;
136 pin_name_t mosi;
137 pin_name_t sck;
138 pin_name_t cs;
140 // static variable
141 uint32_t spi_speed;
142 spi_master_mode_t spi_mode;
143 spi_master_chip_select_polarity_t cs_polarity;
146
157
174
189
202err_t spiisolator6_generic_write ( spiisolator6_t *ctx, uint8_t *data_in, uint8_t in_len );
203
218err_t spiisolator6_generic_read ( spiisolator6_t *ctx, uint8_t *data_in, uint8_t in_len, uint8_t *data_out, uint8_t out_len );
219
220#ifdef __cplusplus
221}
222#endif
223#endif // SPIISOLATOR6_H
224
225 // spiisolator6
226
227// ------------------------------------------------------------------------ END
void spiisolator6_cfg_setup(spiisolator6_cfg_t *cfg)
SPI Isolator 6 configuration object setup function.
err_t spiisolator6_generic_read(spiisolator6_t *ctx, uint8_t *data_in, uint8_t in_len, uint8_t *data_out, uint8_t out_len)
SPI Isolator 6 data reading function.
err_t spiisolator6_generic_write(spiisolator6_t *ctx, uint8_t *data_in, uint8_t in_len)
SPI Isolator 6 data writing function.
err_t spiisolator6_init(spiisolator6_t *ctx, spiisolator6_cfg_t *cfg)
SPI Isolator 6 initialization function.
This file contains SPI specific macros, functions, etc.
spiisolator6_return_value_t
SPI Isolator 6 Click return value data.
Definition spiisolator6.h:152
@ SPIISOLATOR6_OK
Definition spiisolator6.h:153
@ SPIISOLATOR6_ERROR
Definition spiisolator6.h:154
SPI Isolator 6 Click configuration object.
Definition spiisolator6.h:133
spi_master_chip_select_polarity_t cs_polarity
Definition spiisolator6.h:143
pin_name_t sck
Definition spiisolator6.h:137
spi_master_mode_t spi_mode
Definition spiisolator6.h:142
pin_name_t mosi
Definition spiisolator6.h:136
uint32_t spi_speed
Definition spiisolator6.h:141
pin_name_t miso
Definition spiisolator6.h:135
pin_name_t cs
Definition spiisolator6.h:138
SPI Isolator 6 Click context object.
Definition spiisolator6.h:120
spi_master_t spi
Definition spiisolator6.h:122
pin_name_t chip_select
Definition spiisolator6.h:124