microwave5  2.1.0.0
microwave5.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 MICROWAVE5_H
29 #define MICROWAVE5_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_analog_in.h"
48 #include "drv_i2c_master.h"
49 
75 #define MICROWAVE5_ADC_RESOLUTION 0x0FFF
76 #define MICROWAVE5_VREF_3V3 3.3
77 #define MICROWAVE5_VREF_5V 5.0
78 
84 #define MICROWAVE5_SET_DEV_ADDR 0x4D
85  // microwave5_set
87 
102 #define MICROWAVE5_MAP_MIKROBUS( cfg, mikrobus ) \
103  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
104  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
105  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
106  // microwave5_map // microwave5
109 
114 typedef enum
115 {
120 
125 typedef struct
126 {
127  analog_in_t adc;
128  i2c_master_t i2c;
130  uint8_t slave_address;
131  float vref;
134 } microwave5_t;
135 
140 typedef struct
141 {
142  pin_name_t an;
143  pin_name_t scl;
144  pin_name_t sda;
146  analog_in_resolution_t resolution;
147  float vref;
149  uint32_t i2c_speed;
150  uint8_t i2c_address;
155 
160 typedef enum
161 {
163  MICROWAVE5_ERROR = -1
164 
166 
183 
199 
214 
226 err_t microwave5_read_raw_adc ( microwave5_t *ctx, uint16_t *raw_adc );
227 
239 err_t microwave5_read_voltage ( microwave5_t *ctx, float *voltage );
240 
252 err_t microwave5_set_vref ( microwave5_t *ctx, float vref );
253 
254 #ifdef __cplusplus
255 }
256 #endif
257 #endif // MICROWAVE5_H
258  // microwave5
260 
261 // ------------------------------------------------------------------------ END
microwave5_cfg_t
Microwave 5 Click configuration object.
Definition: microwave5.h:141
microwave5_cfg_t::sda
pin_name_t sda
Definition: microwave5.h:144
microwave5_t::i2c
i2c_master_t i2c
Definition: microwave5.h:128
microwave5_read_voltage
err_t microwave5_read_voltage(microwave5_t *ctx, float *voltage)
Microwave 5 read voltage level function.
microwave5_cfg_t::scl
pin_name_t scl
Definition: microwave5.h:143
microwave5_drv_t
microwave5_drv_t
Microwave 5 Click driver selector.
Definition: microwave5.h:115
microwave5_return_value_t
microwave5_return_value_t
Microwave 5 Click return value data.
Definition: microwave5.h:161
microwave5_init
err_t microwave5_init(microwave5_t *ctx, microwave5_cfg_t *cfg)
Microwave 5 initialization function.
microwave5_t::drv_sel
microwave5_drv_t drv_sel
Definition: microwave5.h:132
microwave5_cfg_t::resolution
analog_in_resolution_t resolution
Definition: microwave5.h:146
microwave5_t
Microwave 5 Click context object.
Definition: microwave5.h:126
microwave5_cfg_t::vref
float vref
Definition: microwave5.h:147
microwave5_set_vref
err_t microwave5_set_vref(microwave5_t *ctx, float vref)
Microwave 5 set vref function.
microwave5_t::slave_address
uint8_t slave_address
Definition: microwave5.h:130
microwave5_read_raw_adc
err_t microwave5_read_raw_adc(microwave5_t *ctx, uint16_t *raw_adc)
Microwave 5 read raw ADC value function.
MICROWAVE5_DRV_SEL_ADC
@ MICROWAVE5_DRV_SEL_ADC
Definition: microwave5.h:116
microwave5_t::vref
float vref
Definition: microwave5.h:131
MICROWAVE5_DRV_SEL_I2C
@ MICROWAVE5_DRV_SEL_I2C
Definition: microwave5.h:117
microwave5_drv_interface_selection
void microwave5_drv_interface_selection(microwave5_cfg_t *cfg, microwave5_drv_t drv_sel)
Microwave 5 driver interface setup function.
microwave5_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: microwave5.h:149
MICROWAVE5_OK
@ MICROWAVE5_OK
Definition: microwave5.h:162
microwave5_cfg_setup
void microwave5_cfg_setup(microwave5_cfg_t *cfg)
Microwave 5 configuration object setup function.
microwave5_cfg_t::an
pin_name_t an
Definition: microwave5.h:142
microwave5_t::adc
analog_in_t adc
Definition: microwave5.h:127
MICROWAVE5_ERROR
@ MICROWAVE5_ERROR
Definition: microwave5.h:163
microwave5_cfg_t::drv_sel
microwave5_drv_t drv_sel
Definition: microwave5.h:152
microwave5_cfg_t::i2c_address
uint8_t i2c_address
Definition: microwave5.h:150