serializer 2.0.0.0
serializer.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 SERIALIZER_H
29#define SERIALIZER_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 SERIALIZER_STATUS_OVERTEMPERATURE 0x01
75#define SERIALIZER_STATUS_UNDERVOLTAGE 0x02
76
85#define SERIALIZER_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
86#define SERIALIZER_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
87
88 // serializer_set
89
104#define SERIALIZER_MAP_MIKROBUS( cfg, mikrobus ) \
105 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
106 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
107 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
108 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
109 cfg.flt = MIKROBUS( mikrobus, MIKROBUS_INT )
110
111 // serializer_map
112 // serializer
113
118typedef struct
119{
120 // Input pins
121 digital_in_t flt;
123 // Modules
124 spi_master_t spi;
126 pin_name_t chip_select;
129
134typedef struct
135{
136 // Communication gpio pins
137 pin_name_t miso;
138 pin_name_t mosi;
139 pin_name_t sck;
140 pin_name_t cs;
142 // Additional gpio pins
143 pin_name_t flt;
145 // static variable
146 uint32_t spi_speed;
147 spi_master_mode_t spi_mode;
148 spi_master_chip_select_polarity_t cs_polarity;
151
162
179
195
205
219err_t serializer_read_input ( serializer_t *ctx, uint8_t *data_out );
220
221#ifdef __cplusplus
222}
223#endif
224#endif // SERIALIZER_H
225
226 // serializer
227
228// ------------------------------------------------------------------------ END
err_t serializer_read_input(serializer_t *ctx, uint8_t *data_out)
Serializer read input function.
err_t serializer_init(serializer_t *ctx, serializer_cfg_t *cfg)
Serializer initialization function.
void serializer_cfg_setup(serializer_cfg_t *cfg)
Serializer configuration object setup function.
uint8_t serializer_get_flt_pin(serializer_t *ctx)
Serializer get FLT pin function.
serializer_return_value_t
Serializer Click return value data.
Definition serializer.h:157
@ SERIALIZER_ERROR
Definition serializer.h:159
@ SERIALIZER_OK
Definition serializer.h:158
This file contains SPI specific macros, functions, etc.
Serializer Click configuration object.
Definition serializer.h:135
spi_master_chip_select_polarity_t cs_polarity
Definition serializer.h:148
pin_name_t sck
Definition serializer.h:139
spi_master_mode_t spi_mode
Definition serializer.h:147
pin_name_t mosi
Definition serializer.h:138
uint32_t spi_speed
Definition serializer.h:146
pin_name_t flt
Definition serializer.h:143
pin_name_t miso
Definition serializer.h:137
pin_name_t cs
Definition serializer.h:140
Serializer Click context object.
Definition serializer.h:119
spi_master_t spi
Definition serializer.h:124
digital_in_t flt
Definition serializer.h:121
pin_name_t chip_select
Definition serializer.h:126