ad7746.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
44 #ifndef AD7746_H
45 #define AD7746_H
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 #include "periph/i2c.h"
52 #include "periph/gpio.h"
53 
57 #define AD7746_ZERO_SCALE_CODE (0x800000LL)
58 
62 #define AD7746_INTERNAL_VREF (1170)
63 
67 #define AD7746_DAC_MAX (0x7F)
68 
72 enum {
75 };
76 
80 enum {
81  AD7746_OK = 0,
82  AD7746_NOI2C = -1,
83  AD7746_NODEV = -2,
85 };
86 
90 typedef enum {
96 
100 typedef enum {
107 
111 typedef enum {
115 
119 typedef enum {
129 
133 typedef enum {
134  AD7746_EXC_A = 0x06,
135  AD7746_EXC_B = 0x09,
138 
142 typedef struct ad7746_params {
144  uint8_t addr;
145  uint8_t dac_a_cap;
146  uint8_t dac_b_cap;
153 
157 typedef struct ad7746 {
159 } ad7746_t;
160 
171 int ad7746_init(ad7746_t *dev, const ad7746_params_t *params);
172 
189 int ad7746_read_capacitance_1(ad7746_t *dev, int *value);
190 
207 int ad7746_read_capacitance_2(ad7746_t *dev, int *value);
208 
226 int ad7746_read_voltage_in(ad7746_t *dev, int *value);
227 
244 int ad7746_read_voltage_vdd(ad7746_t *dev, int *value);
245 
262 int ad7746_read_temperature_int(ad7746_t *dev, int *value);
263 
280 int ad7746_read_temperature_ext(ad7746_t *dev, int *value);
281 
294 
307 
318 
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif /* AD7746_H */
335 
AD7746_EXC_AB
@ AD7746_EXC_AB
enable exc A and B outputs
Definition: ad7746.h:136
AD7746_VT_MD_VIN
@ AD7746_VT_MD_VIN
external voltage input (Vin)
Definition: ad7746.h:105
ad7746_cap_input_t
ad7746_cap_input_t
Capacitance channel input.
Definition: ad7746.h:111
ad7746_vt_mode_t
ad7746_vt_mode_t
Voltage / Temperature channel modes.
Definition: ad7746.h:100
ad7746_init
int ad7746_init(ad7746_t *dev, const ad7746_params_t *params)
Initializes an AD7746 device.
AD7746_CAP_IN_1
@ AD7746_CAP_IN_1
CIN1 input.
Definition: ad7746.h:112
AD7746_CAP_SR_263
@ AD7746_CAP_SR_263
26.3 Hz
Definition: ad7746.h:123
ad7746_set_cap_sr
int ad7746_set_cap_sr(const ad7746_t *dev, ad7746_cap_sample_rate_t sr)
Sets the sample rate for the capacitance channel.
ad7746_params::cap_sample_rate
ad7746_cap_sample_rate_t cap_sample_rate
capacitance sample rate
Definition: ad7746.h:148
ad7746_read_temperature_int
int ad7746_read_temperature_int(ad7746_t *dev, int *value)
Reads the temperature from the internal sensor.
AD7746_CAP_SR_161
@ AD7746_CAP_SR_161
16.1 Hz
Definition: ad7746.h:124
ad7746_params::vt_mode
ad7746_vt_mode_t vt_mode
mode of the voltage/temp ch
Definition: ad7746.h:150
AD7746_CAP_SR_500
@ AD7746_CAP_SR_500
50.0 Hz
Definition: ad7746.h:122
AD7746_CAP_SR_838
@ AD7746_CAP_SR_838
83.8 Hz
Definition: ad7746.h:121
AD7746_VT_SR_082
@ AD7746_VT_SR_082
8.2 Hz
Definition: ad7746.h:94
ad7746_read_capacitance_2
int ad7746_read_capacitance_2(ad7746_t *dev, int *value)
Reads the capacitance from the input 2 (CIN2).
ad7746_cap_sample_rate_t
ad7746_cap_sample_rate_t
Capacitive channel sample rate.
Definition: ad7746.h:119
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
ad7746_params::exc_config
ad7746_exc_config_t exc_config
excitation signal config
Definition: ad7746.h:147
AD7746_CAP_SR_109
@ AD7746_CAP_SR_109
10.9 Hz
Definition: ad7746.h:126
ad7746_params::dac_a_cap
uint8_t dac_a_cap
DAC A capacitance.
Definition: ad7746.h:145
AD7746_CAP_SR_909
@ AD7746_CAP_SR_909
90.9 Hz
Definition: ad7746.h:120
ad7746_read_capacitance_1
int ad7746_read_capacitance_1(ad7746_t *dev, int *value)
Reads the capacitance from the input 1 (CIN1).
ad7746_params::dac_b_cap
uint8_t dac_b_cap
DAC B capacitance.
Definition: ad7746.h:146
AD7746_EXC_A
@ AD7746_EXC_A
enable only exc A output
Definition: ad7746.h:134
AD7746_NOI2C
@ AD7746_NOI2C
I2C communication failed.
Definition: ad7746.h:82
ad7746::params
ad7746_params_t params
device driver configuration
Definition: ad7746.h:158
ad7746_vt_sample_rate_t
ad7746_vt_sample_rate_t
Voltage / Temperature channel sample rates.
Definition: ad7746.h:90
AD7746_CAP_SR_130
@ AD7746_CAP_SR_130
13.0 Hz
Definition: ad7746.h:125
ad7746_t
struct ad7746 ad7746_t
AD7746 device descriptor.
AD7746_VT_MD_VDD
@ AD7746_VT_MD_VDD
Vdd voltage monitor.
Definition: ad7746.h:104
ad7746_read_voltage_in
int ad7746_read_voltage_in(ad7746_t *dev, int *value)
Reads the voltage from the external voltage input (VIN).
ad7746_params::vt_sample_rate
ad7746_vt_sample_rate_t vt_sample_rate
voltage/temp sample rate
Definition: ad7746.h:149
ad7746_params_t
struct ad7746_params ad7746_params_t
AD7746 params.
ad7746_params::cap_input
ad7746_cap_input_t cap_input
selected capacitance input
Definition: ad7746.h:151
ad7746_set_cap_ch_input
int ad7746_set_cap_ch_input(const ad7746_t *dev, ad7746_cap_input_t input)
Sets the current input for the capacitive measurement.If not configured manually, the driver sets the...
AD7746_VT_MD_TEMP
@ AD7746_VT_MD_TEMP
internal temperature sensor
Definition: ad7746.h:102
AD7746_VT_SR_312
@ AD7746_VT_SR_312
31.2 Hz
Definition: ad7746.h:92
ad7746_set_vt_sr
int ad7746_set_vt_sr(const ad7746_t *dev, ad7746_vt_sample_rate_t sr)
Sets the sample rate for the voltage / temperature channel.
ad7746_read_temperature_ext
int ad7746_read_temperature_ext(ad7746_t *dev, int *value)
Reads the temperature from the external sensor (see datasheet).
ad7746_set_vt_ch_mode
int ad7746_set_vt_ch_mode(ad7746_t *dev, ad7746_vt_mode_t mode)
Sets the mode for the voltage / temperature channel and updates the descriptor with the new configura...
AD7746_CAP_IN_2
@ AD7746_CAP_IN_2
CIN2 input.
Definition: ad7746.h:113
ad7746_read_voltage_vdd
int ad7746_read_voltage_vdd(ad7746_t *dev, int *value)
Reads the voltage from the VDD pin.
ad7746_exc_config_t
ad7746_exc_config_t
Excitation signal output configuration.
Definition: ad7746.h:133
AD7746_VT_SR_498
@ AD7746_VT_SR_498
49.8 Hz
Definition: ad7746.h:91
ad7746_params::i2c
i2c_t i2c
i2c device
Definition: ad7746.h:143
gpio.h
Low-level GPIO peripheral driver interface definitions.
AD7746_VT_MD_DIS
@ AD7746_VT_MD_DIS
channel disabled
Definition: ad7746.h:101
AD7746_EXC_B
@ AD7746_EXC_B
enable only exc B output
Definition: ad7746.h:135
ad7746
AD7746 device descriptor.
Definition: ad7746.h:157
ad7746_params
AD7746 params.
Definition: ad7746.h:142
AD7746_CAP_SR_091
@ AD7746_CAP_SR_091
9.1 Hz
Definition: ad7746.h:127
AD7746_READ_CAP_CH
@ AD7746_READ_CAP_CH
read capacitive channel
Definition: ad7746.h:73
AD7746_VT_MD_ETEMP
@ AD7746_VT_MD_ETEMP
external temperature sensor (see datasheet)
Definition: ad7746.h:103
AD7746_READ_VT_CH
@ AD7746_READ_VT_CH
read voltage / temperature channel
Definition: ad7746.h:74
AD7746_VT_SR_161
@ AD7746_VT_SR_161
16.1 Hz
Definition: ad7746.h:93
AD7746_NODEV
@ AD7746_NODEV
no AD7746 device found on the bus
Definition: ad7746.h:83
AD7746_NODATA
@ AD7746_NODATA
no data available
Definition: ad7746.h:84
AD7746_OK
@ AD7746_OK
everything was fine
Definition: ad7746.h:81
i2c.h
Low-level I2C peripheral driver interface definition.
ad7746_params::addr
uint8_t addr
i2c address
Definition: ad7746.h:144