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
32extern "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
65#define MICROWAVE4_ADC_RESOLUTION 0x0FFF
66#define MICROWAVE4_VREF_3V3 3.3
67#define MICROWAVE4_VREF_5V 5.0
68
74#define MICROWAVE4_SET_DEV_ADDR 0x4D
75 // microwave4_set
77
92#define MICROWAVE4_MAP_MIKROBUS( cfg, mikrobus ) \
93 cfg.an = MIKROBUS( mikrobus, MIKROBUS_AN ); \
94 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
95 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
96 // microwave4_map // microwave4
99
104typedef enum
105{
110
115typedef struct
116{
117 analog_in_t adc;
118 i2c_master_t i2c;
121 float vref;
125
130typedef struct
131{
132 pin_name_t an;
133 pin_name_t scl;
134 pin_name_t sda;
136 analog_in_resolution_t resolution;
137 float vref;
139 uint32_t i2c_speed;
140 uint8_t i2c_address;
145
150typedef enum
151{
154
156
173
189
204
218
230err_t microwave4_read_raw_adc ( microwave4_t *ctx, uint16_t *raw_adc );
231
243err_t microwave4_read_voltage ( microwave4_t *ctx, float *voltage );
244
256err_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
err_t microwave4_default_cfg(microwave4_t *ctx)
Microwave 4 default configuration function.
err_t microwave4_read_raw_adc(microwave4_t *ctx, uint16_t *raw_adc)
Microwave 4 read raw ADC value function.
void microwave4_cfg_setup(microwave4_cfg_t *cfg)
Microwave 4 configuration object setup function.
err_t microwave4_init(microwave4_t *ctx, microwave4_cfg_t *cfg)
Microwave 4 initialization function.
err_t microwave4_read_voltage(microwave4_t *ctx, float *voltage)
Microwave 4 read voltage level function.
void microwave4_drv_interface_selection(microwave4_cfg_t *cfg, microwave4_drv_t drv_sel)
Microwave 4 driver interface setup function.
err_t microwave4_set_vref(microwave4_t *ctx, float vref)
Microwave 4 set vref function.
microwave4_return_value_t
Microwave 4 Click return value data.
Definition: microwave4.h:151
@ MICROWAVE4_OK
Definition: microwave4.h:152
@ MICROWAVE4_ERROR
Definition: microwave4.h:153
microwave4_drv_t
Microwave 4 Click driver selector.
Definition: microwave4.h:105
@ MICROWAVE4_DRV_SEL_I2C
Definition: microwave4.h:107
@ MICROWAVE4_DRV_SEL_ADC
Definition: microwave4.h:106
Microwave 4 Click configuration object.
Definition: microwave4.h:131
microwave4_drv_t drv_sel
Definition: microwave4.h:142
analog_in_resolution_t resolution
Definition: microwave4.h:136
float vref
Definition: microwave4.h:137
uint32_t i2c_speed
Definition: microwave4.h:139
pin_name_t scl
Definition: microwave4.h:133
pin_name_t sda
Definition: microwave4.h:134
pin_name_t an
Definition: microwave4.h:132
uint8_t i2c_address
Definition: microwave4.h:140
Microwave 4 Click context object.
Definition: microwave4.h:116
microwave4_drv_t drv_sel
Definition: microwave4.h:122
float vref
Definition: microwave4.h:121
i2c_master_t i2c
Definition: microwave4.h:118
uint8_t slave_address
Definition: microwave4.h:120
analog_in_t adc
Definition: microwave4.h:117