Loading...
Searching...
No Matches
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
48extern "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
72enum {
75};
76
80enum {
84 AD7746_NODATA = -3
85};
86
96
107
115
129
133typedef enum {
136 AD7746_EXC_AB = 0x0A
138
153
160
171int ad7746_init(ad7746_t *dev, const ad7746_params_t *params);
172
190
208
226int ad7746_read_voltage_in(ad7746_t *dev, int *value);
227
244int ad7746_read_voltage_vdd(ad7746_t *dev, int *value);
245
263
281
294
307
318
329
330#ifdef __cplusplus
331}
332#endif
333
334#endif /* AD7746_H */
Low-level GPIO peripheral driver interface definitions.
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...
struct ad7746 ad7746_t
AD7746 device descriptor.
ad7746_exc_config_t
Excitation signal output configuration.
Definition ad7746.h:133
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_input_t
Capacitance channel input.
Definition ad7746.h:111
int ad7746_read_capacitance_2(ad7746_t *dev, int *value)
Reads the capacitance from the input 2 (CIN2).
int ad7746_init(ad7746_t *dev, const ad7746_params_t *params)
Initializes an AD7746 device.
ad7746_vt_mode_t
Voltage / Temperature channel modes.
Definition ad7746.h:100
int ad7746_read_voltage_in(ad7746_t *dev, int *value)
Reads the voltage from the external voltage input (VIN).
int ad7746_set_vt_sr(const ad7746_t *dev, ad7746_vt_sample_rate_t sr)
Sets the sample rate for the voltage / temperature channel.
int ad7746_read_capacitance_1(ad7746_t *dev, int *value)
Reads the capacitance from the input 1 (CIN1).
int ad7746_read_temperature_ext(ad7746_t *dev, int *value)
Reads the temperature from the external sensor (see datasheet).
struct ad7746_params ad7746_params_t
AD7746 params.
ad7746_vt_sample_rate_t
Voltage / Temperature channel sample rates.
Definition ad7746.h:90
int ad7746_read_voltage_vdd(ad7746_t *dev, int *value)
Reads the voltage from the VDD pin.
int ad7746_set_cap_sr(const ad7746_t *dev, ad7746_cap_sample_rate_t sr)
Sets the sample rate for the capacitance channel.
ad7746_cap_sample_rate_t
Capacitive channel sample rate.
Definition ad7746.h:119
int ad7746_read_temperature_int(ad7746_t *dev, int *value)
Reads the temperature from the internal sensor.
@ AD7746_READ_VT_CH
read voltage / temperature channel
Definition ad7746.h:74
@ AD7746_READ_CAP_CH
read capacitive channel
Definition ad7746.h:73
@ AD7746_EXC_B
enable only exc B output
Definition ad7746.h:135
@ AD7746_EXC_AB
enable exc A and B outputs
Definition ad7746.h:136
@ AD7746_EXC_A
enable only exc A output
Definition ad7746.h:134
@ AD7746_CAP_IN_1
CIN1 input.
Definition ad7746.h:112
@ AD7746_CAP_IN_2
CIN2 input.
Definition ad7746.h:113
@ AD7746_VT_MD_TEMP
internal temperature sensor
Definition ad7746.h:102
@ AD7746_VT_MD_DIS
channel disabled
Definition ad7746.h:101
@ AD7746_VT_MD_VDD
Vdd voltage monitor.
Definition ad7746.h:104
@ AD7746_VT_MD_ETEMP
external temperature sensor (see datasheet)
Definition ad7746.h:103
@ AD7746_VT_MD_VIN
external voltage input (Vin)
Definition ad7746.h:105
@ AD7746_VT_SR_082
8.2 Hz
Definition ad7746.h:94
@ AD7746_VT_SR_312
31.2 Hz
Definition ad7746.h:92
@ AD7746_VT_SR_498
49.8 Hz
Definition ad7746.h:91
@ AD7746_VT_SR_161
16.1 Hz
Definition ad7746.h:93
@ AD7746_CAP_SR_109
10.9 Hz
Definition ad7746.h:126
@ AD7746_CAP_SR_130
13.0 Hz
Definition ad7746.h:125
@ AD7746_CAP_SR_263
26.3 Hz
Definition ad7746.h:123
@ AD7746_CAP_SR_500
50.0 Hz
Definition ad7746.h:122
@ AD7746_CAP_SR_161
16.1 Hz
Definition ad7746.h:124
@ AD7746_CAP_SR_091
9.1 Hz
Definition ad7746.h:127
@ AD7746_CAP_SR_909
90.9 Hz
Definition ad7746.h:120
@ AD7746_CAP_SR_838
83.8 Hz
Definition ad7746.h:121
@ AD7746_NOI2C
I2C communication failed.
Definition ad7746.h:82
@ AD7746_OK
everything was fine
Definition ad7746.h:81
@ AD7746_NODEV
no AD7746 device found on the bus
Definition ad7746.h:83
@ AD7746_NODATA
no data available
Definition ad7746.h:84
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:151
Low-level I2C peripheral driver interface definition.
AD7746 params.
Definition ad7746.h:142
uint8_t addr
i2c address
Definition ad7746.h:144
i2c_t i2c
i2c device
Definition ad7746.h:143
ad7746_exc_config_t exc_config
excitation signal config
Definition ad7746.h:147
ad7746_vt_mode_t vt_mode
mode of the voltage/temp ch
Definition ad7746.h:150
ad7746_cap_sample_rate_t cap_sample_rate
capacitance sample rate
Definition ad7746.h:148
uint8_t dac_b_cap
DAC B capacitance.
Definition ad7746.h:146
ad7746_cap_input_t cap_input
selected capacitance input
Definition ad7746.h:151
uint8_t dac_a_cap
DAC A capacitance.
Definition ad7746.h:145
ad7746_vt_sample_rate_t vt_sample_rate
voltage/temp sample rate
Definition ad7746.h:149
AD7746 device descriptor.
Definition ad7746.h:157
ad7746_params_t params
device driver configuration
Definition ad7746.h:158