precision-converters-firmware
Classes | Macros | Enumerations | Functions
ltc2488.h File Reference
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_util.h"
Include dependency graph for ltc2488.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  ltc2488_dev
 Device driver structure. More...
 
struct  ltc2488_dev_init
 Device driver initialization parameters. More...
 

Macros

#define LTC2488_VREF   4.096
 
#define LTC2488_CHANNEL_CONV_TIME   150
 
#define LTC2488_CHANNEL_EOC_MASK   NO_OS_BIT(23)
 
#define LTC2488_CHANNEL_SIGN_BIT_MASK   NO_OS_BIT(21)
 
#define LTC2488_CHANNEL_MSB_BIT_MASK   NO_OS_BIT(20)
 
#define LTC2488_CHANNEL_MASK_17BITS   NO_OS_GENMASK(16,0)
 
#define LTC2488_FS_VOLTAGE   (LTC2488_VREF*0.5)
 
#define LTC2488_SINGLE_CH0   0xB0
 
#define LTC2488_SINGLE_CH1   0xB8
 
#define LTC2488_SINGLE_CH2   0xB1
 
#define LTC2488_SINGLE_CH3   0xB9
 
#define LTC2488_CHANNEL_CONF_DISABLE   0x80
 
#define LTC2488_CHANNEL_CONF_ENABLE   0xA0
 
#define LTC2488_INPUT_RANGE(x)
 
#define LTC2488_EOC_DETECT(x)    ((x & LTC2488_CHANNEL_EOC_MASK ) ? false : true)
 
#define LTC2488_GET_ADC_DATA(x)   ((x >> 4) & LTC2488_CHANNEL_MASK_17BITS)
 
#define LTC2488_SIGN_EXTEND_ADC_DATA(x)
 

Enumerations

enum  input_status {
  UNDER_RANGE ,
  NEGATIVE_RANGE ,
  POSITIVE_RANGE ,
  OVER_RANGE
}
 Various Input range. More...
 

Functions

enum input_status ltc2488_data_process (const uint32_t *adc_code, int32_t *adc_value)
 Extracts the actual 17-Bit ADC value from the ADC code, returns the 32-bit sign extended value along with over/underrange status. The ADC value to be returned has been to limited to +1 the max 17-bit positive value (for over-range) or -1 the minimum 17-bit value (for under-range) to avoid the ADC value being misinterpreted when not in desired range. More...
 
float ltc2488_code_to_voltage (const int32_t *adc_data)
 Calculates the voltage corresponding to an adc code, given the reference voltage (in volts). Currently this function only supports the single-ended configuration. More...
 
int32_t ltc2488_init (struct ltc2488_dev **device, struct ltc2488_dev_init *init_param)
 Initialize the ltc2488 device structure. More...
 
int32_t ltc2488_remove (struct ltc2488_dev *dev)
 Free any resource used by the driver. More...
 
int32_t ltc2488_read_write (struct no_os_spi_desc *desc, uint8_t buff_cmd, uint32_t *adc_buff)
 Reads/writes data from/to LTC2488 ADC that accepts a 8 bit configuration and returns a 24 bit result. More...
 

Macro Definition Documentation

◆ LTC2488_CHANNEL_CONF_DISABLE

#define LTC2488_CHANNEL_CONF_DISABLE   0x80

◆ LTC2488_CHANNEL_CONF_ENABLE

#define LTC2488_CHANNEL_CONF_ENABLE   0xA0

◆ LTC2488_CHANNEL_CONV_TIME

#define LTC2488_CHANNEL_CONV_TIME   150

◆ LTC2488_CHANNEL_EOC_MASK

#define LTC2488_CHANNEL_EOC_MASK   NO_OS_BIT(23)

◆ LTC2488_CHANNEL_MASK_17BITS

#define LTC2488_CHANNEL_MASK_17BITS   NO_OS_GENMASK(16,0)

◆ LTC2488_CHANNEL_MSB_BIT_MASK

#define LTC2488_CHANNEL_MSB_BIT_MASK   NO_OS_BIT(20)

◆ LTC2488_CHANNEL_SIGN_BIT_MASK

#define LTC2488_CHANNEL_SIGN_BIT_MASK   NO_OS_BIT(21)

◆ LTC2488_EOC_DETECT

#define LTC2488_EOC_DETECT (   x)     ((x & LTC2488_CHANNEL_EOC_MASK ) ? false : true)

◆ LTC2488_FS_VOLTAGE

#define LTC2488_FS_VOLTAGE   (LTC2488_VREF*0.5)

◆ LTC2488_GET_ADC_DATA

#define LTC2488_GET_ADC_DATA (   x)    ((x >> 4) & LTC2488_CHANNEL_MASK_17BITS)

◆ LTC2488_INPUT_RANGE

#define LTC2488_INPUT_RANGE (   x)
Value:
(enum input_status)(((x) & \
#define LTC2488_CHANNEL_SIGN_BIT_MASK
Definition: ltc2488.h:33
#define LTC2488_CHANNEL_MSB_BIT_MASK
Definition: ltc2488.h:34
input_status
Various Input range.
Definition: ltc2488.h:78

◆ LTC2488_SIGN_EXTEND_ADC_DATA

#define LTC2488_SIGN_EXTEND_ADC_DATA (   x)

◆ LTC2488_SINGLE_CH0

#define LTC2488_SINGLE_CH0   0xB0

◆ LTC2488_SINGLE_CH1

#define LTC2488_SINGLE_CH1   0xB8

◆ LTC2488_SINGLE_CH2

#define LTC2488_SINGLE_CH2   0xB1

◆ LTC2488_SINGLE_CH3

#define LTC2488_SINGLE_CH3   0xB9

◆ LTC2488_VREF

#define LTC2488_VREF   4.096

Enumeration Type Documentation

◆ input_status

Various Input range.

Enumerator
UNDER_RANGE 
NEGATIVE_RANGE 
POSITIVE_RANGE 
OVER_RANGE 

Function Documentation

◆ ltc2488_code_to_voltage()

float ltc2488_code_to_voltage ( const int32_t *  adc_data)

Calculates the voltage corresponding to an adc code, given the reference voltage (in volts). Currently this function only supports the single-ended configuration.

Parameters
adc_code- Pointer to Read-Only 24bit ADC output word in 32bit format
Returns
Corresponding Voltage Output

◆ ltc2488_data_process()

enum input_status ltc2488_data_process ( const uint32_t *  adc_code,
int32_t *  adc_value 
)

Extracts the actual 17-Bit ADC value from the ADC code, returns the 32-bit sign extended value along with over/underrange status. The ADC value to be returned has been to limited to +1 the max 17-bit positive value (for over-range) or -1 the minimum 17-bit value (for under-range) to avoid the ADC value being misinterpreted when not in desired range.

SPI DATA FORMAT (MSB First): Byte #1 Byte #2

Data Out : !EOC DMY SIG MSB D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 Data In : 1 0 EN SGL OS A2 A1 A0 X X X X X X X X

      Byte #3

Data Out : D3 D2 D1 D0 - - - - Data In : X X X X X X X X

!EOC : End of Conversion Bit (Active Low) DMY : Dummy Bit (Always 0) SIG : Sign Bit (1-data positive, 0-data negative) MSB : Most Significant Bit (Provides under range and over range indication) Dx : Data Bits EN : Enable Bit (0-keep previous mode, 1-change mode) SGL : Enable Single-Ended Bit (0-differential, 1-single-ended) OS : ODD/Sign Bit Sx : Address Select Bit

Command Byte 1 0 EN SGL OS A2 A1 A0 Comments 1 0 0 X X X X X Keep Previous Mode 1 0 1 0 X X X X Differential Mode 1 0 1 1 X X X X Single-Ended Mode

Parameters
adc_code- Pointer to Read-Only 24bit ADC output word in 32bit format
adc_value- Pointer to buffer to store the 32 bit sign extended adc value. Under-Range : 0xFFFDFFFF , Over-Range : 0x00020000
Returns
Input range

◆ ltc2488_init()

int32_t ltc2488_init ( struct ltc2488_dev **  device,
struct ltc2488_dev_init init_param 
)

Initialize the ltc2488 device structure.

Performs memory allocation of the device structure.

Parameters
device- Pointer to location of device structure to write.
init_param- Pointer to configuration of the driver.
Returns
ret - return code. Example: FAILURE- Errors Encountered. SUCCESS - No errors encountered.
Here is the caller graph for this function:

◆ ltc2488_read_write()

int32_t ltc2488_read_write ( struct no_os_spi_desc *  desc,
uint8_t  adc_cmd,
uint32_t *  adc_buff 
)

Reads/writes data from/to LTC2488 ADC that accepts a 8 bit configuration and returns a 24 bit result.

Parameters
device- Pointer to the lcoation of SPI device descriptor.
adc_cmd- 8 bit adc command word.
adc_buff- The buffer to receive 24 bit output data word.
Returns
Status of SPI transaction

◆ ltc2488_remove()

int32_t ltc2488_remove ( struct ltc2488_dev dev)

Free any resource used by the driver.

Parameters
dev- The device structure.
Returns
ret - return code. Example: -EIO - SPI communication error. SUCCESS - No errors encountered.
Here is the caller graph for this function: