no-OS
Loading...
Searching...
No Matches
ltc2378.h File Reference

Header file of the LTC2378 Driver. More...

#include <stdint.h>
#include "no_os_spi.h"
#include "no_os_gpio.h"
#include "no_os_delay.h"
#include "no_os_error.h"
Include dependency graph for ltc2378.h:

Classes

struct  ltc2378_dev
 Device descriptor for LTC2378-20. More...
 
struct  ltc2378_init_param
 Initialization parameters for LTC2378-20. More...
 

Macros

#define LTC2378_RESOLUTION_UNIPOLAR   (1 << 20) /* 2^20 = 1048576 */
 
#define LTC2378_RESOLUTION_BIPOLAR   (1 << 19) /* 2^19 = 524288 */
 
#define LTC2378_BUSY_TIMEOUT_US   1000 /* Timeout for BUSY signal in microseconds */
 
#define LTC2378_CNV_PULSE_WIDTH_US   1 /* CNV pulse width in microseconds */
 
#define LTC2378_CONVERSION_DELAY_US   1 /* Conversion delay when BUSY not available */
 
#define LTC2378_POWERDOWN_DELAY_US   2 /* Power-down setup time in microseconds */
 
#define LTC2378_IIO_SCALE_UNIPOLAR_SHIFT   20 /* 2^20 for unipolar mode */
 
#define LTC2378_IIO_SCALE_BIPOLAR_SHIFT   19 /* 2^19 for bipolar mode */
 
#define LTC2378_DATA_MASK   0xFFFFF /* 20-bit data mask */
 
#define LTC2378_DATA_SHIFT_BYTE0   12 /* Shift for byte 0 */
 
#define LTC2378_DATA_SHIFT_BYTE1   4 /* Shift for byte 1 */
 
#define LTC2378_DATA_SHIFT_BYTE2   4 /* Right shift for byte 2 */
 
#define LTC2378_SIGN_BIT_POSITION   19 /* Sign bit position for bipolar mode */
 

Enumerations

enum  ltc2378_input_mode {
  LTC2378_BIPOLAR ,
  LTC2378_UNIPOLAR
}
 Input mode configuration for LTC2378-20. More...
 

Functions

int ltc2378_init (struct ltc2378_dev **device, const struct ltc2378_init_param *init_param)
 Initialize the LTC2378-20 device.
 
int ltc2378_remove (struct ltc2378_dev *dev)
 Remove the LTC2378-20 device and free allocated resources.
 
int ltc2378_start_conversion (struct ltc2378_dev *dev)
 Start a single ADC conversion.
 
int ltc2378_read_raw (struct ltc2378_dev *dev, uint32_t *data)
 Read a single raw ADC conversion result.
 
int ltc2378_read_avg (struct ltc2378_dev *dev, uint32_t *avg_data, uint16_t samples)
 Read and average multiple ADC conversion results.
 
int ltc2378_raw_to_uv (struct ltc2378_dev *dev, uint32_t raw, int32_t *voltage_uv)
 Convert raw ADC value to voltage in microvolts.
 
int ltc2378_power_down (struct ltc2378_dev *dev)
 Put the LTC2378-20 into power-down mode.
 

Detailed Description

Header file of the LTC2378 Driver.

Author
Cherrence Sarip (cherr.nosp@m.ence.nosp@m..sari.nosp@m.p@an.nosp@m.alog..nosp@m.com)

Copyright 2025(c) Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Macro Definition Documentation

◆ LTC2378_BUSY_TIMEOUT_US

#define LTC2378_BUSY_TIMEOUT_US   1000 /* Timeout for BUSY signal in microseconds */

◆ LTC2378_CNV_PULSE_WIDTH_US

#define LTC2378_CNV_PULSE_WIDTH_US   1 /* CNV pulse width in microseconds */

◆ LTC2378_CONVERSION_DELAY_US

#define LTC2378_CONVERSION_DELAY_US   1 /* Conversion delay when BUSY not available */

◆ LTC2378_DATA_MASK

#define LTC2378_DATA_MASK   0xFFFFF /* 20-bit data mask */

◆ LTC2378_DATA_SHIFT_BYTE0

#define LTC2378_DATA_SHIFT_BYTE0   12 /* Shift for byte 0 */

◆ LTC2378_DATA_SHIFT_BYTE1

#define LTC2378_DATA_SHIFT_BYTE1   4 /* Shift for byte 1 */

◆ LTC2378_DATA_SHIFT_BYTE2

#define LTC2378_DATA_SHIFT_BYTE2   4 /* Right shift for byte 2 */

◆ LTC2378_IIO_SCALE_BIPOLAR_SHIFT

#define LTC2378_IIO_SCALE_BIPOLAR_SHIFT   19 /* 2^19 for bipolar mode */

◆ LTC2378_IIO_SCALE_UNIPOLAR_SHIFT

#define LTC2378_IIO_SCALE_UNIPOLAR_SHIFT   20 /* 2^20 for unipolar mode */

◆ LTC2378_POWERDOWN_DELAY_US

#define LTC2378_POWERDOWN_DELAY_US   2 /* Power-down setup time in microseconds */

◆ LTC2378_RESOLUTION_BIPOLAR

#define LTC2378_RESOLUTION_BIPOLAR   (1 << 19) /* 2^19 = 524288 */

◆ LTC2378_RESOLUTION_UNIPOLAR

#define LTC2378_RESOLUTION_UNIPOLAR   (1 << 20) /* 2^20 = 1048576 */

◆ LTC2378_SIGN_BIT_POSITION

#define LTC2378_SIGN_BIT_POSITION   19 /* Sign bit position for bipolar mode */

Enumeration Type Documentation

◆ ltc2378_input_mode

Input mode configuration for LTC2378-20.

Enumerator
LTC2378_BIPOLAR 
LTC2378_UNIPOLAR 

Function Documentation

◆ ltc2378_init()

int ltc2378_init ( struct ltc2378_dev ** device,
const struct ltc2378_init_param * init_param )

Initialize the LTC2378-20 device.

Parameters
device- Pointer to device structure pointer
init_param- Pointer to initialization parameters structure
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_power_down()

int ltc2378_power_down ( struct ltc2378_dev * dev)

Put the LTC2378-20 into power-down mode.

Parameters
dev- Device structure pointer
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_raw_to_uv()

int ltc2378_raw_to_uv ( struct ltc2378_dev * dev,
uint32_t raw,
int32_t * voltage_uv )

Convert raw ADC value to voltage in microvolts.

Parameters
dev- Device structure pointer
raw- Raw ADC value (20-bit)
voltage_uv- Pointer to store the voltage in microvolts
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_read_avg()

int ltc2378_read_avg ( struct ltc2378_dev * dev,
uint32_t * avg_data,
uint16_t samples )

Read and average multiple ADC conversion results.

Parameters
dev- Device structure pointer
avg_data- Pointer to store the averaged raw ADC data
samples- Number of samples to average (1-65535)
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_read_raw()

int ltc2378_read_raw ( struct ltc2378_dev * dev,
uint32_t * data )

Read a single raw ADC conversion result.

Parameters
dev- Device structure pointer
data- Pointer to store the raw ADC data (20-bit value)
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_remove()

int ltc2378_remove ( struct ltc2378_dev * dev)

Remove the LTC2378-20 device and free allocated resources.

Parameters
dev- Device structure pointer
Returns
0 in case of success, negative error code otherwise

◆ ltc2378_start_conversion()

int ltc2378_start_conversion ( struct ltc2378_dev * dev)

Start a single ADC conversion.

Parameters
dev- Device structure pointer
Returns
0 in case of success, negative error code otherwise