87 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
88 dac_code = (int32_t)float_code - LTC2756_offset;
91 if (dac_code > 262143)
93 return ((uint32_t)dac_code);
100 *LTC2756_lsb = (fs_voltage - zero_voltage) / ((
float) (fs_code - zero_code));
101 temp_offset = zero_voltage/(*LTC2756_lsb) - (float)zero_code;
102 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
103 *LTC2756_offset = (int32_t)temp_offset;
static int32_t LTC2756_offset
Header File for Linduino Libraries and Demo Code.
LTC2756: Serial 18-Bit SoftSpan IOUT DAC.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
void LTC2756_calibrate(uint32_t zero_code, uint32_t fs_code, float zero_voltage, float fs_voltage, float *LTC2756_lsb, int32_t *LTC2756_offset)
Calculate the LTC2756 offset and LSB voltage given two measured voltages and their corresponding code...
uint32_t LTC2756_voltage_to_code(float dac_voltage, float LTC2756_lsb, int32_t LTC2756_offset)
Converts voltage to code.
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
void LTC2756_transfer_4bytes(uint8_t cs, uint8_t *tx, uint8_t *rx)
Transfers four bytes to the LTC2756.