41#define CN0391_ADC_RESOLUTION 24
42#define CN0391_ADC_FULL_SCALE (1U << CN0391_ADC_RESOLUTION)
43#define CN0391_ADC_MIDSCALE (CN0391_ADC_FULL_SCALE >> 1)
46#define CN0391_RTD_GAIN 1
47#define CN0391_THERMO_RES 1600
48#define CN0391_ADC_REF_VOLTAGE 2.5
51#define CN0391_SETUP_TC_IDX 0
52#define CN0391_SETUP_RTD_IDX 1
55#define CN0391_ADC_CLK_HZ 614400ULL
57#define CN0391_FILTER_FS 384U
74#ifndef CN0391_FILTER_TYPE
75#define CN0391_FILTER_TYPE 0
78#if (CN0391_FILTER_TYPE == 0)
79#define CN0391_FILTER_ORDER 4U
80#elif (CN0391_FILTER_TYPE == 2)
81#define CN0391_FILTER_ORDER 3U
83#error "CN0391_FILTER_TYPE must be 0 (Sinc4) or 2 (Sinc3)"
90#define CN0391_FILTER_REG_VAL \
91 (AD7124_FILT_REG_FILTER(CN0391_FILTER_TYPE) | AD7124_FILT_REG_FS(CN0391_FILTER_FS))
99#define CN0391_CONV_TIME_US \
100 (((CN0391_FILTER_ORDER + 1U) * CN0391_FILTER_FS * 32ULL * 1000000ULL) \
111#define CN0391_SPI_RDY_POLL_CNT(spi_hz) \
112 ((CN0391_CONV_TIME_US * 2ULL * (spi_hz)) / (16ULL * 1000000ULL))
114#define CN0391_ADC_CHANNELS_PER_IIO_CH 3
116#define CN0391_NUM_IIO_CHANNELS 4
118#define CN0391_CH0_ID 0
119#define CN0391_CH1_ID 1
120#define CN0391_CH2_ID 2
121#define CN0391_CH3_ID 3
179 double *hot_junction_temp,
180 double *cold_junction_temp,
181 double *thermocouple_voltage,
182 double *rtd_resistance);
AD7124 header file. Devices: AD7124-4, AD7124-8.
struct ad7616_init_param init_param
Definition ad7616_sdz.c:106
int cn0391_init(struct cn0391_dev **dev, struct cn0391_init_param *init_param)
Initialize CN0391 device: set up AD7124 and configure IOUT.
Definition cn0391.c:89
int cn0391_read_temperature(struct cn0391_dev *dev, uint8_t ch_idx, double *hot_junction_temp, double *cold_junction_temp, double *thermocouple_voltage, double *rtd_resistance)
Perform a full temperature measurement cycle. Reads all 3 ADC channels (thermocouple,...
Definition cn0391.c:150
int cn0391_remove(struct cn0391_dev *dev)
Remove CN0391 device and free resources.
Definition cn0391.c:137
Header file of RTD temperature conversion routines.
Header file of thermocouple temperature conversion routines.
uint8_t r5
Definition cn0391.h:126
uint8_t iout_ain
Definition cn0391.h:128
uint8_t rtd
Definition cn0391.h:127
uint8_t tc
Definition cn0391.h:125
double tc_voltage
Definition cn0391.h:134
double rtd_resistance
Definition cn0391.h:135
double cold_junction_temp
Definition cn0391.h:133
double hot_junction_temp
Definition cn0391.h:132
struct cn0391_cache cache
Definition cn0391.h:142
struct ad7124_dev * ad7124_dev
Definition cn0391.h:139
int8_t cache_ch
Definition cn0391.h:141
struct ad7124_init_param * ad7124_init
Definition cn0391.h:146