92 uint8_t data_array[3], rx_array[3];
93 data_array[2] = dac_command;
94 data_array[1] = data.
LT_byte[1];
95 data_array[0] = data.
LT_byte[0];
105 dac_code = (dac_code > (floor(dac_code) + 0.5)) ? ceil(dac_code) : floor(dac_code);
111 return ((uint16_t)dac_code);
118 dac_voltage = ((float)(dac_code + LTC2640_offset)*
LTC2640_lsb);
119 return (dac_voltage);
126 *LTC2640_lsb = (voltage2 - voltage1) / ((
float) (dac_code2 - dac_code1));
127 temp_offset = voltage1/(*LTC2640_lsb) - dac_code1;
128 temp_offset = (temp_offset > (floor(temp_offset) + 0.5)) ? ceil(temp_offset) : floor(temp_offset);
129 *LTC2640_offset = (int16_t)temp_offset;
Header File for Linduino Libraries and Demo Code.
union LT_union_int32_4bytes data
uint16_t LTC2640_voltage_to_code(float dac_voltage, float LTC2640_lsb, int16_t LTC2640_offset)
Calculate the LTC2640 DAC code given the desired output voltage.
void LTC2640_calibrate(uint16_t dac_code1, uint16_t dac_code2, float voltage1, float voltage2, float *LTC2640_lsb, int16_t *LTC2640_offset)
Calculate the LTC2640 offset and LSB voltages given two measured voltages and their corresponding cod...
uint16_t LT_uint16
16-bit unsigned integer to be converted to two bytes
void LTC2640_write(uint8_t cs, uint8_t dac_command, uint16_t dac_code)
Write the dac_command and 16-bit dac_code to the LTC2640.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
float LTC2640_code_to_voltage(uint16_t dac_code, float LTC2640_lsb, int16_t LTC2640_offset)
Calculate the LTC2640 DAC output voltage given the DAC code, offset, and LSB value.
LTC2640: Single 12-/10-/8-Bit Rail-to-Rail DACs with 10ppm/C Reference.
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
static float LTC2640_lsb
DAC lsb.
void spi_transfer_block(uint8_t cs_pin, uint8_t *tx, uint8_t *rx, uint8_t length)
Reads and sends a byte array.
static int16_t LTC2640_offset
DAC offset.
uint8_t LT_byte[2]
2 bytes (unsigned 8-bit integers) to be converted to a 16-bit signed or unsigned integer ...