precision-converters-firmware
|
#include <stdbool.h>
#include "no_os_spi.h"
#include "no_os_util.h"
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... | |
#define LTC2488_CHANNEL_CONF_DISABLE 0x80 |
#define LTC2488_CHANNEL_CONF_ENABLE 0xA0 |
#define LTC2488_CHANNEL_CONV_TIME 150 |
#define LTC2488_CHANNEL_EOC_MASK NO_OS_BIT(23) |
#define LTC2488_CHANNEL_MASK_17BITS NO_OS_GENMASK(16,0) |
#define LTC2488_CHANNEL_MSB_BIT_MASK NO_OS_BIT(20) |
#define LTC2488_CHANNEL_SIGN_BIT_MASK NO_OS_BIT(21) |
#define LTC2488_EOC_DETECT | ( | x | ) | ((x & LTC2488_CHANNEL_EOC_MASK ) ? false : true) |
#define LTC2488_FS_VOLTAGE (LTC2488_VREF*0.5) |
#define LTC2488_GET_ADC_DATA | ( | x | ) | ((x >> 4) & LTC2488_CHANNEL_MASK_17BITS) |
#define LTC2488_INPUT_RANGE | ( | x | ) |
#define LTC2488_SIGN_EXTEND_ADC_DATA | ( | x | ) |
#define LTC2488_SINGLE_CH0 0xB0 |
#define LTC2488_SINGLE_CH1 0xB8 |
#define LTC2488_SINGLE_CH2 0xB1 |
#define LTC2488_SINGLE_CH3 0xB9 |
#define LTC2488_VREF 4.096 |
enum input_status |
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.
adc_code | - Pointer to Read-Only 24bit ADC output word in 32bit format |
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
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 |
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.
device | - Pointer to location of device structure to write. |
init_param | - Pointer to configuration of the driver. |
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.
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. |
int32_t ltc2488_remove | ( | struct ltc2488_dev * | dev | ) |
Free any resource used by the driver.
dev | - The device structure. |