76 uint16_t timer_count = 0;
80 if (
input(MISO) == 0)
break;
81 if (timer_count++>miso_timeout)
111 adc_code = adc_code>>6;
113 adc_voltage=((float)adc_code+LTC2418_offset_code)*(
LTC2418_lsb);
120 zero_code = zero_code >> 6;
121 zero_code -= 8388608;
122 fs_code = fs_code >> 6;
126 *LTC2418_lsb = (fs_voltage-zero_voltage)/((
float)(fs_code - zero_code));
128 temp_offset = (zero_voltage/ *
LTC2418_lsb) - zero_code;
129 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
130 *LTC2418_offset_code = (int32_t)temp_offset;
static uint8_t adc_command
uint8_t LT_byte[4]
4 bytes (unsigned 8-bit integers) to be converted to a 32-bit signed or unsigned integer ...
#define output_high(pin)
Set "pin" high.
static int32_t LTC2418_offset_code
Ideal offset for a perfect part.
void LTC2418_cal_voltage(int32_t zero_code, int32_t fs_code, float zero_voltage, float fs_voltage, float *LTC2418_lsb, int32_t *LTC2418_offset_code)
Calibrate the lsb.
Header File for Linduino Libraries and Demo Code.
union LT_union_int32_4bytes data
static float LTC2418_lsb
Ideal LSB voltage for a perfect part.
LTC2418: 16-Channel 24-Bit No Latency Delta-Sigma ADC.
#define output_low(pin)
Set "pin" low.
#define input(pin)
Return the state of pin "pin".
int32_t LT_int32
32-bit signed integer to be converted to four bytes
float LTC2418_code_to_voltage(int32_t adc_code, float LTC2418_lsb, int32_t LTC2418_offset_code)
Calculates the LTC2418 input bipolar voltage.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
int8_t LTC2418_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
This union splits one int32_t (32-bit signed integer) or uint32_t (32-bit unsigned integer) four uint...
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
void LTC2418_read(uint8_t cs, uint8_t adc_command, uint32_t *adc_code)
Reads the LTC2418 result and programs the configuration for the next conversion.