microwave4  2.1.0.0
microwave4.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 MICROWAVE4_H
29 #define MICROWAVE4_H
30 
31 #ifdef __cplusplus
32 extern "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_analog_in.h"
52 #include "drv_i2c_master.h"
53 
79 #define MICROWAVE4_ADC_RESOLUTION 0x0FFF
80 #define MICROWAVE4_VREF_3V3 3.3
81 #define MICROWAVE4_VREF_5V 5.0
82 
88 #define MICROWAVE4_SET_DEV_ADDR 0x4D
89  // microwave4_set
91 
106 #define MICROWAVE4_MAP_MIKROBUS( cfg, mikrobus ) \
107  cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
108  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
109  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
110  // microwave4_map // microwave4
113 
118 typedef enum
119 {
124 
129 typedef struct
130 {
131  analog_in_t adc;
132  i2c_master_t i2c;
134  uint8_t slave_address;
135  float vref;
138 } microwave4_t;
139 
144 typedef struct
145 {
146  pin_name_t an;
147  pin_name_t scl;
148  pin_name_t sda;
150  analog_in_resolution_t resolution;
151  float vref;
153  uint32_t i2c_speed;
154  uint8_t i2c_address;
159 
164 typedef enum
165 {
167  MICROWAVE4_ERROR = -1
168 
170 
187 
203 
218 
230 err_t microwave4_read_raw_adc ( microwave4_t *ctx, uint16_t *raw_adc );
231 
243 err_t microwave4_read_voltage ( microwave4_t *ctx, float *voltage );
244 
256 err_t microwave4_set_vref ( microwave4_t *ctx, float vref );
257 
258 #ifdef __cplusplus
259 }
260 #endif
261 #endif // MICROWAVE4_H
262  // microwave4
264 
265 // ------------------------------------------------------------------------ END
microwave4_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: microwave4.h:153
microwave4_cfg_t
Microwave 4 Click configuration object.
Definition: microwave4.h:145
microwave4_read_raw_adc
err_t microwave4_read_raw_adc(microwave4_t *ctx, uint16_t *raw_adc)
Microwave 4 read raw ADC value function.
microwave4_t::drv_sel
microwave4_drv_t drv_sel
Definition: microwave4.h:136
MICROWAVE4_DRV_SEL_ADC
@ MICROWAVE4_DRV_SEL_ADC
Definition: microwave4.h:120
microwave4_cfg_t::resolution
analog_in_resolution_t resolution
Definition: microwave4.h:150
microwave4_cfg_t::an
pin_name_t an
Definition: microwave4.h:146
MICROWAVE4_ERROR
@ MICROWAVE4_ERROR
Definition: microwave4.h:167
microwave4_drv_t
microwave4_drv_t
Microwave 4 Click driver selector.
Definition: microwave4.h:119
microwave4_t::adc
analog_in_t adc
Definition: microwave4.h:131
MICROWAVE4_DRV_SEL_I2C
@ MICROWAVE4_DRV_SEL_I2C
Definition: microwave4.h:121
microwave4_t
Microwave 4 Click context object.
Definition: microwave4.h:130
MICROWAVE4_OK
@ MICROWAVE4_OK
Definition: microwave4.h:166
microwave4_cfg_t::scl
pin_name_t scl
Definition: microwave4.h:147
microwave4_init
err_t microwave4_init(microwave4_t *ctx, microwave4_cfg_t *cfg)
Microwave 4 initialization function.
microwave4_cfg_setup
void microwave4_cfg_setup(microwave4_cfg_t *cfg)
Microwave 4 configuration object setup function.
microwave4_t::i2c
i2c_master_t i2c
Definition: microwave4.h:132
microwave4_cfg_t::drv_sel
microwave4_drv_t drv_sel
Definition: microwave4.h:156
microwave4_cfg_t::sda
pin_name_t sda
Definition: microwave4.h:148
microwave4_cfg_t::i2c_address
uint8_t i2c_address
Definition: microwave4.h:154
microwave4_set_vref
err_t microwave4_set_vref(microwave4_t *ctx, float vref)
Microwave 4 set vref function.
microwave4_drv_interface_sel
void microwave4_drv_interface_sel(microwave4_cfg_t *cfg, microwave4_drv_t drv_sel)
Microwave 4 driver interface setup function.
microwave4_return_value_t
microwave4_return_value_t
Microwave 4 Click return value data.
Definition: microwave4.h:165
microwave4_cfg_t::vref
float vref
Definition: microwave4.h:151
microwave4_read_voltage
err_t microwave4_read_voltage(microwave4_t *ctx, float *voltage)
Microwave 4 read voltage level function.
microwave4_t::vref
float vref
Definition: microwave4.h:135
microwave4_t::slave_address
uint8_t slave_address
Definition: microwave4.h:134