87 adc_voltage=((float)(adc_code+LTC1867_offset_unipolar_code))*LTC1867_lsb;
97 adc_code = (adc_code ^ 0xFFFF)+1;
100 adc_voltage=((float)(adc_code+LTC1867_offset_bipolar_code))*LTC1867_lsb*sign;
108 *LTC1867_lsb = (fs_voltage-zero_voltage)/((
float)(fs_code - zero_unipolar_code));
110 temp_offset = (zero_voltage/ *
LTC1867_lsb) - zero_unipolar_code;
111 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
112 *LTC1867_offset_unipolar_code = (int32_t)temp_offset;
114 temp_offset = (zero_voltage / *
LTC1867_lsb) - zero_bipolar_code ;
115 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
116 *LTC1867_offset_bipolar_code = (int32_t)temp_offset;
static uint8_t adc_command
static int32_t LTC1867_offset_unipolar_code
Ideal unipolar offset for a perfect part.
Header File for Linduino Libraries and Demo Code.
float LTC1867_unipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_unipolar_code)
Calculates the LTC1867 input's unipolar voltage given the binary data and lsb weight.
void LTC1867_cal_voltage(uint16_t zero_unipolar_code, uint16_t zero_bipolar_code, uint16_t fs_code, float zero_voltage, float fs_voltage, float *LTC1867_lsb, int32_t *LTC1867_offset_unipolar_code, int32_t *LTC1867_offset_bipolar_code)
Calibrate the offset and LSB voltage given two measured offset codes, and a full-scale voltage with t...
LTC1867: 16-bit 8-channel 200ksps ADC.
float LTC1867_bipolar_code_to_voltage(uint16_t adc_code, float LTC1867_lsb, int32_t LTC1867_offset_bipolar_code)
Calculates the LTC1867 input's bipolar voltage given the two's compliment data and lsb weight...
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
void LTC1867_read(uint8_t cs, uint8_t adc_command, uint16_t *adc_code)
Reads the ADC and returns 16-bit data.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static float LTC1867_lsb
Ideal LSB voltage for a perfect part.
static int32_t LTC1867_offset_bipolar_code
Ideal bipolar offset for a perfect part.