isoadc3 2.0.0.0
isoadc3.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 ISOADC3_H
29#define ISOADC3_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_i2c_master.h"
38
59#define ISOADC3_RESOLUTION 4096
60#define ISOADC3_OFFSET 1287
61#define ISOADC3_ADC_NUM_OF_MEASURE 100.0
62#define ISOADC3_12_BIT_DATA 0x0FFF
63#define ISOADC3_GAIN 4
64
70#define ISOADC3_VREF_3V3 3336
71#define ISOADC3_VREF_5V 5070
72
78#define ISOADC3_SET_DEV_ADDR 0x4D
79 // isoadc3_set
81
96#define ISOADC3_MAP_MIKROBUS( cfg, mikrobus ) \
97 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
98 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
99 // isoadc3_map // isoadc3
102
107typedef struct
108{
109 // Modules
110 i2c_master_t i2c;
112 // I2C slave address
115} isoadc3_t;
116
121typedef struct
122{
123 pin_name_t scl;
124 pin_name_t sda;
126 uint32_t i2c_speed;
127 uint8_t i2c_address;
130
135typedef enum
136{
138 ISOADC3_ERROR = -1
139
141
158
174
190err_t isoadc3_generic_write ( isoadc3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );
191
206err_t isoadc3_generic_read ( isoadc3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len );
207
215uint16_t isoadc3_read_adc ( isoadc3_t *ctx );
216
225uint16_t isoadc3_get_adc_voltage ( isoadc3_t *ctx, uint16_t v_ref );
226
235uint16_t isoadc3_read_voltage ( isoadc3_t *ctx, uint16_t v_ref );
236
237#ifdef __cplusplus
238}
239#endif
240#endif // ISOADC3_H
241 // isoadc3
243
244// ------------------------------------------------------------------------ END
uint16_t isoadc3_read_voltage(isoadc3_t *ctx, uint16_t v_ref)
Read voltage function.
err_t isoadc3_generic_write(isoadc3_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
ISO ADC 3 I2C writing function.
err_t isoadc3_generic_read(isoadc3_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
ISO ADC 3 I2C reading function.
uint16_t isoadc3_read_adc(isoadc3_t *ctx)
Read ADC function.
uint16_t isoadc3_get_adc_voltage(isoadc3_t *ctx, uint16_t v_ref)
Read ADC voltage function.
err_t isoadc3_init(isoadc3_t *ctx, isoadc3_cfg_t *cfg)
ISO ADC 3 initialization function.
void isoadc3_cfg_setup(isoadc3_cfg_t *cfg)
ISO ADC 3 configuration object setup function.
isoadc3_return_value_t
ISO ADC 3 Click return value data.
Definition: isoadc3.h:136
@ ISOADC3_OK
Definition: isoadc3.h:137
@ ISOADC3_ERROR
Definition: isoadc3.h:138
ISO ADC 3 Click configuration object.
Definition: isoadc3.h:122
uint32_t i2c_speed
Definition: isoadc3.h:126
pin_name_t scl
Definition: isoadc3.h:123
pin_name_t sda
Definition: isoadc3.h:124
uint8_t i2c_address
Definition: isoadc3.h:127
ISO ADC 3 Click context object.
Definition: isoadc3.h:108
i2c_master_t i2c
Definition: isoadc3.h:110
uint8_t slave_address
Definition: isoadc3.h:113