79 void LTC2654_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
81 uint8_t data_array[3], rx_array[3];
86 data_array[2] = dac_command | dac_address;
87 data_array[1] = data.
LT_byte[1];
99 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
100 dac_code = (int32_t)float_code - LTC2654_offset;
103 return ((uint16_t)dac_code);
110 dac_voltage = ((float)(dac_code + LTC2654_offset)*
LTC2654_lsb);
111 return (dac_voltage);
118 *LTC2654_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
119 temp_offset = voltage1/(*LTC2654_lsb) - dac_code1;
120 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
121 *LTC2654_offset = (int16_t)temp_offset;
Header File for Linduino Libraries and Demo Code.
static int16_t LTC2654_offset[5]
DAC offset - index 4 for "all DACs".
union LT_union_int32_4bytes data
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
void LTC2654_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2654_lsb, int16_t *LTC2654_offset)
Calculate the LTC2654 offset and LSB voltage given two measured voltages and their corresponding code...
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
float LTC2654_code_to_voltage(uint16_t dac_code, float LTC2654_lsb, int16_t LTC2654_offset)
Calculate the LTC2654 DAC output voltage given the DAC code, offset, and LSB value.
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...
static float LTC2654_lsb[5]
The LTC2654 lsb - index 4 for "all DACs".
uint16_t LTC2654_voltage_to_code(float dac_voltage, float LTC2654_lsb, int16_t LTC2654_offset)
Calculate a LTC2654 DAC code given the desired output voltage and DAC address (0-3) ...
void LTC2654_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2654.
LTC2654: Quad SPI 16-/12-Bit Rail-to-Rail DACs with 10ppm/C Max Reference.