adc11 2.0.0.0
adc11.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 ADC11_H
29#define ADC11_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_spi_master.h"
51
73#define ADC11_MAP_MIKROBUS( cfg, mikrobus ) \
74 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
75 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
76 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
77 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
78
79 // adc11_map
80 // adc11
81
86typedef struct
87{
88 // Modules
89
90 spi_master_t spi;
92 pin_name_t chip_select;
94} adc11_t;
95
100typedef struct
101{
102 // Communication gpio pins
103
104 pin_name_t miso;
105 pin_name_t mosi;
106 pin_name_t sck;
107 pin_name_t cs;
109 // static variable
110
111 uint32_t spi_speed;
112 spi_master_mode_t spi_mode;
113 spi_master_chip_select_polarity_t cs_polarity;
116
121typedef struct
122{
123 uint16_t zero_adc_val;
124
126
131typedef enum
132{
134 ADC11_ERROR = -1
135
137
154
169err_t adc11_init ( adc11_t *ctx, adc11_cfg_t *cfg );
170
185err_t adc11_generic_read ( adc11_t *ctx, uint16_t *adc_data );
186
203
220
221
222#ifdef __cplusplus
223}
224#endif
225#endif // ADC11_H
226
227 // adc11
228
229// ------------------------------------------------------------------------ END
adc11_return_value_t
ADC 11 Click return value data.
Definition adc11.h:132
@ ADC11_OK
Definition adc11.h:133
@ ADC11_ERROR
Definition adc11.h:134
void adc11_cfg_setup(adc11_cfg_t *cfg)
ADC 11 configuration object setup function.
err_t adc11_generic_read(adc11_t *ctx, uint16_t *adc_data)
ADC 11 data reading function.
err_t adc11_get_voltage(adc11_t *ctx, adc11_calibration_data_t *adc_val, float *voltage)
ADC 11 get voltage function.
err_t adc11_init(adc11_t *ctx, adc11_cfg_t *cfg)
ADC 11 initialization function.
err_t adc11_set_calibration(adc11_t *ctx, adc11_calibration_data_t *adc_val)
ADC 11 set calibration function.
float voltage
Definition main.c:33
uint16_t adc_data
Definition main.c:35
ADC 11 Click calibration object.
Definition adc11.h:122
uint16_t zero_adc_val
Definition adc11.h:123
ADC 11 Click configuration object.
Definition adc11.h:101
spi_master_chip_select_polarity_t cs_polarity
Definition adc11.h:113
pin_name_t sck
Definition adc11.h:106
spi_master_mode_t spi_mode
Definition adc11.h:112
pin_name_t mosi
Definition adc11.h:105
uint32_t spi_speed
Definition adc11.h:111
pin_name_t miso
Definition adc11.h:104
pin_name_t cs
Definition adc11.h:107
ADC 11 Click context object.
Definition adc11.h:87
spi_master_t spi
Definition adc11.h:90
pin_name_t chip_select
Definition adc11.h:92