precision-converters-firmware
Functions
ltc2488.c File Reference
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include "ltc2488.h"
#include "no_os_error.h"
#include "no_os_delay.h"
Include dependency graph for ltc2488.c:

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 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. More...
 

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: