ozone2 2.0.0.0
ozone2.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef OZONE2_H
36#define OZONE2_H
37
38#include "drv_analog_in.h"
39#include "drv_digital_in.h"
40#include "drv_spi_master.h"
41
42// -------------------------------------------------------------- PUBLIC MACROS
52#define OZONE2_MAP_MIKROBUS( cfg, mikrobus ) \
53 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
54 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
55 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
56 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
57 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN )
64#define OZONE2_OK 0
65#define OZONE2_INIT_ERROR (-1) // End group macro
69// --------------------------------------------------------------- PUBLIC TYPES
78typedef enum
79{
82
84
88typedef struct
89{
90 // Input pins objects
91
92 analog_in_t an;
93 digital_in_t miso;
94
95 // Module object
96
97 spi_master_t spi;
98 pin_name_t chip_select;
99
100 // ADC selection
101
103
104} ozone2_t;
105
109typedef struct
110{
111 // Communication gpio pins
112
113 pin_name_t miso;
114 pin_name_t mosi;
115 pin_name_t sck;
116 pin_name_t cs;
117
118 // Additional gpio pins
119
120 pin_name_t an;
121
122 // SPI settings
123
124 uint32_t spi_speed;
125 spi_master_mode_t spi_mode;
126 spi_master_chip_select_polarity_t cs_polarity;
127
128 // ADC settings
129
130 analog_in_resolution_t resolution;
131 float vref;
132
133 // ADC selection
134
136
138
139// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
145#ifdef __cplusplus
146extern "C"{
147#endif
148
159
171err_t ozone2_init ( ozone2_t *ctx, ozone2_cfg_t *cfg );
172
183err_t ozone2_read_signal_voltage ( ozone2_t *ctx, float *data_out );
184
196err_t ozone2_read_measurement ( ozone2_t *ctx, uint16_t *data_out );
197
198#ifdef __cplusplus
199}
200#endif
201#endif // OZONE2_H
202 // End public_function group // End click Driver group
205
206// ------------------------------------------------------------------------ END
spi_master_t spi
Definition: ozone2.h:97
analog_in_resolution_t resolution
Definition: ozone2.h:130
float vref
Definition: ozone2.h:131
ozone2_adc_sel_t adc_sel
Definition: ozone2.h:102
digital_in_t miso
Definition: ozone2.h:93
spi_master_chip_select_polarity_t cs_polarity
Definition: ozone2.h:126
pin_name_t sck
Definition: ozone2.h:115
spi_master_mode_t spi_mode
Definition: ozone2.h:125
pin_name_t mosi
Definition: ozone2.h:114
uint32_t spi_speed
Definition: ozone2.h:124
pin_name_t miso
Definition: ozone2.h:113
analog_in_t an
Definition: ozone2.h:92
pin_name_t chip_select
Definition: ozone2.h:98
pin_name_t an
Definition: ozone2.h:120
pin_name_t cs
Definition: ozone2.h:116
err_t ozone2_read_signal_voltage(ozone2_t *ctx, float *data_out)
Measurement Voltage Read function.
void ozone2_cfg_setup(ozone2_cfg_t *cfg)
Config Object Initialization function.
err_t ozone2_read_measurement(ozone2_t *ctx, uint16_t *data_out)
Measurement Read function.
err_t ozone2_init(ozone2_t *ctx, ozone2_cfg_t *cfg)
Initialization function.
ozone2_adc_sel_t
Click AD conversion type selectors.
Definition: ozone2.h:79
@ OZONE2_ADC_SEL_SPI
Definition: ozone2.h:81
@ OZONE2_ADC_SEL_AN
Definition: ozone2.h:80
Click configuration structure definition.
Definition: ozone2.h:110
Click ctx object definition.
Definition: ozone2.h:89