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;
151  ad7746_cap_input_t cap_input;
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 
293 int ad7746_set_cap_ch_input(const ad7746_t *dev, ad7746_cap_input_t input);
294 
307 
318 
329 
330 #ifdef __cplusplus
331 }
332 #endif
333 
334 #endif /* AD7746_H */
335 
10.9 Hz
Definition: ad7746.h:126
ad7746_cap_input_t
Capacitance channel input.
Definition: ad7746.h:111
8.2 Hz
Definition: ad7746.h:94
int ad7746_set_cap_sr(const ad7746_t *dev, ad7746_cap_sample_rate_t sr)
Sets the sample rate for the capacitance channel.
13.0 Hz
Definition: ad7746.h:125
ad7746_cap_sample_rate_t
Capacitive channel sample rate.
Definition: ad7746.h:119
Low-level GPIO peripheral driver interface definitions.
int ad7746_init(ad7746_t *dev, const ad7746_params_t *params)
Initializes an AD7746 device.
ad7746_vt_sample_rate_t vt_sample_rate
voltage/temp sample rate
Definition: ad7746.h:149
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_exc_config_t exc_config
excitation signal config
Definition: ad7746.h:147
int ad7746_read_capacitance_2(ad7746_t *dev, int *value)
Reads the capacitance from the input 2 (CIN2).
external temperature sensor (see datasheet)
Definition: ad7746.h:103
no data available
Definition: ad7746.h:84
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:157
uint8_t dac_a_cap
DAC A capacitance.
Definition: ad7746.h:145
CIN1 input.
Definition: ad7746.h:112
internal temperature sensor
Definition: ad7746.h:102
uint8_t addr
i2c address
Definition: ad7746.h:144
ad7746_vt_mode_t
Voltage / Temperature channel modes.
Definition: ad7746.h:100
50.0 Hz
Definition: ad7746.h:122
49.8 Hz
Definition: ad7746.h:91
int ad7746_read_temperature_ext(ad7746_t *dev, int *value)
Reads the temperature from the external sensor (see datasheet).
int ad7746_read_temperature_int(ad7746_t *dev, int *value)
Reads the temperature from the internal sensor.
ad7746_cap_input_t cap_input
selected capacitance input
Definition: ad7746.h:151
channel disabled
Definition: ad7746.h:101
AD7746 device descriptor.
Definition: ad7746.h:157
83.8 Hz
Definition: ad7746.h:121
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_vt_sample_rate_t
Voltage / Temperature channel sample rates.
Definition: ad7746.h:90
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...
everything was fine
Definition: ad7746.h:81
int ad7746_read_capacitance_1(ad7746_t *dev, int *value)
Reads the capacitance from the input 1 (CIN1).
ad7746_params_t params
device driver configuration
Definition: ad7746.h:158
int ad7746_read_voltage_in(ad7746_t *dev, int *value)
Reads the voltage from the external voltage input (VIN).
struct ad7746_params ad7746_params_t
AD7746 params.
26.3 Hz
Definition: ad7746.h:123
ad7746_exc_config_t
Excitation signal output configuration.
Definition: ad7746.h:133
struct ad7746 ad7746_t
AD7746 device descriptor.
16.1 Hz
Definition: ad7746.h:93
i2c_t i2c
i2c device
Definition: ad7746.h:143
90.9 Hz
Definition: ad7746.h:120
CIN2 input.
Definition: ad7746.h:113
I2C communication failed.
Definition: ad7746.h:82
16.1 Hz
Definition: ad7746.h:124
31.2 Hz
Definition: ad7746.h:92
int ad7746_read_voltage_vdd(ad7746_t *dev, int *value)
Reads the voltage from the VDD pin.
read voltage / temperature channel
Definition: ad7746.h:74
external voltage input (Vin)
Definition: ad7746.h:105
enable exc A and B outputs
Definition: ad7746.h:136
enable only exc A output
Definition: ad7746.h:134
Vdd voltage monitor.
Definition: ad7746.h:104
ad7746_vt_mode_t vt_mode
mode of the voltage/temp ch
Definition: ad7746.h:150
AD7746 params.
Definition: ad7746.h:142
read capacitive channel
Definition: ad7746.h:73
enable only exc B output
Definition: ad7746.h:135
no AD7746 device found on the bus
Definition: ad7746.h:83
uint8_t dac_b_cap
DAC B capacitance.
Definition: ad7746.h:146
ad7746_cap_sample_rate_t cap_sample_rate
capacitance sample rate
Definition: ad7746.h:148
Low-level I2C peripheral driver interface definition.