70 int8_t
LTC2662_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
73 uint8_t data_array[4], rx_array[4];
79 data_array[2] = dac_command | dac_address;
80 data_array[1] = data.
LT_byte[1];
81 data_array[0] = data.
LT_byte[0];
94 float_code = 65535.0 * dac_current / max_output;
95 float_code = (float_code > (floor(float_code) + 0.5)) ? ceil(float_code) : floor(float_code);
96 if (float_code < 0.0) float_code = 0.0;
97 if (float_code > 65535.0) float_code = 65535.0;
98 dac_code = (uint16_t) (float_code);
107 dac_current = ((float) dac_code / 65535.0) * max_output;
108 return (dac_current);
int8_t LTC2662_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2662.
Header File for Linduino Libraries and Demo Code.
union LT_union_int32_4bytes data
int16_t LT_int16
16-bit signed integer to be converted to two bytes
float LTC2662_code_to_current(uint16_t dac_code, float max_output)
Calculate the LTC2662 DAC output current given the DAC code and max output.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
LTC2662: 5-Channel 16-/12-Bit 300mA SoftSpan Current Source DACs.
uint16_t LTC2662_current_to_code(float dac_current, float max_output)
Calculate a LTC2662 DAC code given the desired output current.
This union splits one int16_t (16-bit signed integer) or uint16_t (16-bit unsigned integer) into two ...
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 ...