no-OS
Loading...
Searching...
No Matches
ltc2378.h
Go to the documentation of this file.
1/***************************************************************************/
33
34#ifndef __LTC2378_H__
35#define __LTC2378_H__
36
37#include <stdint.h>
38#include "no_os_spi.h"
39#include "no_os_gpio.h"
40#include "no_os_delay.h"
41#include "no_os_error.h"
42
43#define LTC2378_RESOLUTION_UNIPOLAR (1 << 20) /* 2^20 = 1048576 */
44#define LTC2378_RESOLUTION_BIPOLAR (1 << 19) /* 2^19 = 524288 */
45
46/* Timing constants */
47#define LTC2378_BUSY_TIMEOUT_US 1000 /* Timeout for BUSY signal in microseconds */
48#define LTC2378_CNV_PULSE_WIDTH_US 1 /* CNV pulse width in microseconds */
49#define LTC2378_CONVERSION_DELAY_US 1 /* Conversion delay when BUSY not available */
50#define LTC2378_POWERDOWN_DELAY_US 2 /* Power-down setup time in microseconds */
51
52/* IIO scale calculation constants */
53#define LTC2378_IIO_SCALE_UNIPOLAR_SHIFT 20 /* 2^20 for unipolar mode */
54#define LTC2378_IIO_SCALE_BIPOLAR_SHIFT 19 /* 2^19 for bipolar mode */
55
56/* SPI data parsing constants */
57#define LTC2378_DATA_MASK 0xFFFFF /* 20-bit data mask */
58#define LTC2378_DATA_SHIFT_BYTE0 12 /* Shift for byte 0 */
59#define LTC2378_DATA_SHIFT_BYTE1 4 /* Shift for byte 1 */
60#define LTC2378_DATA_SHIFT_BYTE2 4 /* Right shift for byte 2 */
61#define LTC2378_SIGN_BIT_POSITION 19 /* Sign bit position for bipolar mode */
62
68 LTC2378_BIPOLAR, /* Bipolar input: -Vref to +Vref */
69 LTC2378_UNIPOLAR /* Unipolar input: 0 to Vref */
70};
71
83
95
96/* Function declarations */
97
98/* Initialize the LTC2378-20 device */
100 const struct ltc2378_init_param *init_param);
101
102/* Remove the LTC2378-20 device and free allocated resources */
103int ltc2378_remove(struct ltc2378_dev *dev);
104
105/* Start a single ADC conversion */
107
108/* Read a single raw ADC conversion result */
109int ltc2378_read_raw(struct ltc2378_dev *dev, uint32_t *data);
110
111/* Read and average multiple ADC conversion results */
112int ltc2378_read_avg(struct ltc2378_dev *dev, uint32_t *avg_data,
113 uint16_t samples);
114
115/* Convert raw ADC value to voltage in microvolts */
116int ltc2378_raw_to_uv(struct ltc2378_dev *dev, uint32_t raw,
117 int32_t *voltage_uv);
118
119/* Put the LTC2378-20 into power-down mode */
120int ltc2378_power_down(struct ltc2378_dev *dev);
121
122#endif /* __LTC2378_H__ */
struct ad7616_init_param init_param
Definition ad7616_sdz.c:107
ltc2378_input_mode
Input mode configuration for LTC2378-20.
Definition ltc2378.h:67
@ LTC2378_BIPOLAR
Definition ltc2378.h:68
@ LTC2378_UNIPOLAR
Definition ltc2378.h:69
int ltc2378_read_avg(struct ltc2378_dev *dev, uint32_t *avg_data, uint16_t samples)
Read and average multiple ADC conversion results.
Definition ltc2378.c:195
int ltc2378_raw_to_uv(struct ltc2378_dev *dev, uint32_t raw, int32_t *voltage_uv)
Convert raw ADC value to voltage in microvolts.
Definition ltc2378.c:224
int ltc2378_remove(struct ltc2378_dev *dev)
Remove the LTC2378-20 device and free allocated resources.
Definition ltc2378.c:103
int ltc2378_read_raw(struct ltc2378_dev *dev, uint32_t *data)
Read a single raw ADC conversion result.
Definition ltc2378.c:148
int ltc2378_start_conversion(struct ltc2378_dev *dev)
Start a single ADC conversion.
Definition ltc2378.c:122
int ltc2378_power_down(struct ltc2378_dev *dev)
Put the LTC2378-20 into power-down mode.
Definition ltc2378.c:255
int ltc2378_init(struct ltc2378_dev **device, const struct ltc2378_init_param *init_param)
Initialize the LTC2378-20 device.
Definition ltc2378.c:46
Header file of Delay functions.
Error codes definition.
Header file of GPIO Interface.
Header file of SPI Interface.
Definition ad9361_util.h:63
Device descriptor for LTC2378-20.
Definition ltc2378.h:76
struct no_os_gpio_desc * gpio_cnv
Definition ltc2378.h:78
struct no_os_spi_desc * spi_desc
Definition ltc2378.h:77
enum ltc2378_input_mode input_mode
Definition ltc2378.h:81
struct no_os_gpio_desc * gpio_busy
Definition ltc2378.h:79
uint32_t vref_uv
Definition ltc2378.h:80
Initialization parameters for LTC2378-20.
Definition ltc2378.h:88
enum ltc2378_input_mode input_mode
Definition ltc2378.h:93
uint32_t vref_uv
Definition ltc2378.h:92
const struct no_os_gpio_init_param * gpio_cnv_init
Definition ltc2378.h:90
const struct no_os_gpio_init_param * gpio_busy_init
Definition ltc2378.h:91
const struct no_os_spi_init_param * spi_init
Definition ltc2378.h:89
Structure holding the GPIO descriptor.
Definition no_os_gpio.h:84
Structure holding the parameters for GPIO initialization.
Definition no_os_gpio.h:67
Structure holding SPI descriptor.
Definition no_os_spi.h:180
Structure holding the parameters for SPI initialization.
Definition no_os_spi.h:128