97 code = voltage / reference_voltage * 0xFFFF ;
101 code = (voltage * 0x7FFF)/reference_voltage + 0x7FFF;
112 voltage = code * reference_voltage / 0xFFFF ;
116 code = (int16_t)code;
117 voltage = (((float)code/0x7FFF) - 1) * reference_voltage;
Header File for Linduino Libraries and Demo Code.
union LT_union_int32_4bytes data
uint16_t LTC2642_voltage_to_code(float voltage, float reference_voltage, uint8_t range)
Calculates the 16 bit data code from voltage.
void spi_transfer_word(uint8_t cs_pin, uint16_t tx, uint16_t *rx)
Reads and sends a word.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
float LTC2642_code_to_voltage(uint16_t code, float reference_voltage, uint8_t range)
Calculates the output voltage from the given digital code and reference voltage.
LTC2642: 16-/14-/12-Bit VOUT DAC with SPI Interface LTC2641: 16-/14-/12-Bit VOUT DAC with SPI Interfa...
static float reference_voltage
The reference voltage range, set to 5v through JP2 and JP3 by default.
void LTC2642_write(uint8_t cs, uint16_t data)
Writes the 16-bit data into the DAC.