microwave6  2.1.0.0
microwave6.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 MICROWAVE6_H
29 #define MICROWAVE6_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_analog_in.h"
38 #include "drv_i2c_master.h"
39 
60 #define MICROWAVE6_ADC_RESOLUTION 0x0FFF
61 #define MICROWAVE6_VREF_3V3 3.3
62 #define MICROWAVE6_VREF_5V 5.0
63 
69 #define MICROWAVE6_SET_DEV_ADDR 0x4D
70  // microwave6_set
72 
87 #define MICROWAVE6_MAP_MIKROBUS( cfg, mikrobus ) \
88  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
89  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
90  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
91  // microwave6_map // microwave6
94 
99 typedef enum
100 {
105 
110 typedef struct
111 {
112  analog_in_t adc;
113  i2c_master_t i2c;
115  uint8_t slave_address;
116  float vref;
119 } microwave6_t;
120 
125 typedef struct
126 {
127  pin_name_t an;
128  pin_name_t scl;
129  pin_name_t sda;
131  analog_in_resolution_t resolution;
132  float vref;
134  uint32_t i2c_speed;
135  uint8_t i2c_address;
140 
145 typedef enum
146 {
148  MICROWAVE6_ERROR = -1
149 
151 
168 
184 
199 
211 err_t microwave6_read_raw_adc ( microwave6_t *ctx, uint16_t *raw_adc );
212 
224 err_t microwave6_read_voltage ( microwave6_t *ctx, float *voltage );
225 
237 err_t microwave6_set_vref ( microwave6_t *ctx, float vref );
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 #endif // MICROWAVE6_H
243  // microwave6
245 
246 // ------------------------------------------------------------------------ END
microwave6_cfg_t::vref
float vref
Definition: microwave6.h:132
microwave6_t
Microwave 6 Click context object.
Definition: microwave6.h:111
microwave6_cfg_t::i2c_address
uint8_t i2c_address
Definition: microwave6.h:135
MICROWAVE6_OK
@ MICROWAVE6_OK
Definition: microwave6.h:147
microwave6_t::adc
analog_in_t adc
Definition: microwave6.h:112
microwave6_cfg_t
Microwave 6 Click configuration object.
Definition: microwave6.h:126
microwave6_read_voltage
err_t microwave6_read_voltage(microwave6_t *ctx, float *voltage)
Microwave 6 read voltage level function.
microwave6_cfg_t::scl
pin_name_t scl
Definition: microwave6.h:128
microwave6_t::vref
float vref
Definition: microwave6.h:116
MICROWAVE6_DRV_SEL_ADC
@ MICROWAVE6_DRV_SEL_ADC
Definition: microwave6.h:101
microwave6_cfg_setup
void microwave6_cfg_setup(microwave6_cfg_t *cfg)
Microwave 6 configuration object setup function.
MICROWAVE6_DRV_SEL_I2C
@ MICROWAVE6_DRV_SEL_I2C
Definition: microwave6.h:102
microwave6_cfg_t::an
pin_name_t an
Definition: microwave6.h:127
microwave6_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: microwave6.h:134
MICROWAVE6_ERROR
@ MICROWAVE6_ERROR
Definition: microwave6.h:148
microwave6_init
err_t microwave6_init(microwave6_t *ctx, microwave6_cfg_t *cfg)
Microwave 6 initialization function.
microwave6_t::slave_address
uint8_t slave_address
Definition: microwave6.h:115
microwave6_return_value_t
microwave6_return_value_t
Microwave 6 Click return value data.
Definition: microwave6.h:146
microwave6_t::i2c
i2c_master_t i2c
Definition: microwave6.h:113
microwave6_t::drv_sel
microwave6_drv_t drv_sel
Definition: microwave6.h:117
microwave6_cfg_t::resolution
analog_in_resolution_t resolution
Definition: microwave6.h:131
microwave6_cfg_t::sda
pin_name_t sda
Definition: microwave6.h:129
microwave6_read_raw_adc
err_t microwave6_read_raw_adc(microwave6_t *ctx, uint16_t *raw_adc)
Microwave 6 read raw ADC value function.
microwave6_drv_interface_selection
void microwave6_drv_interface_selection(microwave6_cfg_t *cfg, microwave6_drv_t drv_sel)
Microwave 6 driver interface setup function.
microwave6_drv_t
microwave6_drv_t
Microwave 6 Click driver selector.
Definition: microwave6.h:100
microwave6_set_vref
err_t microwave6_set_vref(microwave6_t *ctx, float vref)
Microwave 6 set vref function.
microwave6_cfg_t::drv_sel
microwave6_drv_t drv_sel
Definition: microwave6.h:137