61 #define CS QUIKEVAL_CS 63 #define LTC2668_CS_ADDR 0 64 #define LTC2439_CS_ADDR 1
65 #define LTC2418_CS_ADDR 2
66 #define LTC2449_CS_ADDR 3
67 #define LTC2494_CS_ADDR 4
68 #define LTC2498_CS_ADDR 5
69 #define LTC2496_CS_ADDR 6
70 #define LTC2412_CS_ADDR 7
71 #define LTC2436_CS_ADDR 8
72 #define LTC2400_CS_ADDR 9
73 #define LTC2420_CS_ADDR 10
78 #define LTC2495_ADDR 0b0010100 // LOW LOW LOW 79 #define LTC2497_ADDR 0b0100110 // LOW HIGH LOW 80 #define LTC2499_ADDR 0b1010110 // HIGH LOW LOW 127 void print_all(
float *se_results,
float *diff_results);
150 Serial.begin(115200);
151 Serial.println(F(
"LTC24XX Test Suite\n"));
171 static float LTC24XX_vref = 5.0;
177 switch (demo_board_product_name_key)
225 Serial.println(F(
"\nTEST ALL\n"));
236 Serial.println(F(
"\nSingle Ended Results..."));
237 for (i=0; i<=15; i++)
239 Serial.print(F(
"CH "));
241 Serial.print(F(
": "));
242 Serial.print(se_results[i], 8);
243 if (!((i+1)%4)) Serial.println();
244 else Serial.print(F(
" "));
247 Serial.println(F(
"\nDifferential Results..."));
250 Serial.print(F(
"CH "));
252 Serial.print(F(
"-"));
253 Serial.print((i*2) + 1);
254 Serial.print(F(
": "));
255 Serial.print(diff_results[i], 8);
256 if (!((i+1)%4)) Serial.println();
257 else Serial.print(F(
" "));
264 if (CS_addr & 0b00000001)
266 digitalWrite(2, HIGH);
270 digitalWrite(2, LOW);
272 if (CS_addr & 0b00000010)
274 digitalWrite(3, HIGH);
278 digitalWrite(3, LOW);
280 if (CS_addr & 0b00000100)
282 digitalWrite(4, HIGH);
286 digitalWrite(4, LOW);
288 if (CS_addr & 0b00001000)
290 digitalWrite(5, HIGH);
294 digitalWrite(5, LOW);
308 Serial.println(F(
"\nTesting LTC2400 with a 32 bit read using LTC24XX_SPI_32bit_data..."));
318 Serial.print(F(
" Formatted LTC2400 ADC code: 0x"));
319 Serial.println(adc_code, HEX);
320 Serial.print(F(
" Voltage:"));
321 Serial.print(voltage, 8);
322 Serial.println(F(
" V"));
336 Serial.println(F(
"\nTesting LTC2412 with a 32 bit read..."));
341 for (i=0; i <= 1; ++
i)
348 Serial.print(F(
" Formatted LTC2412 ADC code CH"));
349 Serial.print(channel);
350 Serial.print(F(
": 0x"));
351 Serial.println(adc_code, HEX);
352 Serial.print(F(
" Voltage: "));
353 Serial.print(voltage, 8);
354 Serial.println(F(
" V"));
361 float se_results[16], diff_results[16];
368 Serial.println(F(
"\nTesting LTC2418, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_32bit_data() function"));
369 Serial.println(F(
"Reading Single-Ended channels..."));
374 for (i=0; i <= 15; i++)
381 Serial.println(F(
"Reading out all Differential channels..."));
386 for (i=0; i <= 7; i++)
406 Serial.println(F(
"\nTesting LTC2420 with a 24 bit read using LTC24XX_SPI_24bit_data..."));
416 Serial.print(F(
" Formatted LTC2412 ADC code: "));
417 Serial.println(adc_code, HEX);
418 Serial.print(F(
" Voltage: "));
419 Serial.print(voltage, 8);
420 Serial.println(F(
" V"));
434 Serial.println(F(
"\nTesting LTC2436 with a 24 bit read..."));
439 for (i=0; i <= 1; ++
i)
446 Serial.print(F(
" Formatted LTC2436 ADC code CH"));
447 Serial.print(channel);
448 Serial.print(F(
": 0x"));
449 Serial.println(adc_code, HEX);
450 Serial.print(F(
" Voltage: "));
451 Serial.print(voltage, 8);
452 Serial.println(F(
" V"));
459 float se_results[16], diff_results[16];
466 Serial.println(F(
"\nTesting LTC2439, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_24bit_data() function"));
467 Serial.println(F(
"Reading out all Single-Ended channels..."));
472 for (i=0; i<=15; i++)
479 Serial.println(F(
"Reading out all Differential channels..."));
497 float se_results[16], diff_results[16];
504 Serial.println(F(
"\nTesting LTC2449, 24 bit ADC with a 24 bit output word using LTC24XX_SPI_16bit_command_32bit_data() function"));
505 Serial.println(F(
"Reading out all Single-Ended channels..."));
510 for (i=0; i<=15; i++)
517 Serial.println(F(
"Reading out all Differential channels..."));
535 float se_results[16], diff_results[16];
542 Serial.println(F(
"\nTesting LTC2494, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_24bit_data() function"));
543 Serial.println(F(
"Reading out all Single-Ended channels..."));
548 for (i=0; i<=15; i++)
555 Serial.println(F(
"Reading out all Differential channels..."));
575 float se_results[16], diff_results[16];
579 Serial.println(F(
"\nTesting LTC2495, 24 bit output using LTC24XX_I2C_16bit_command_32bit_data..."));
580 Serial.println(F(
"Reading out all Single-Ended channels..."));
584 for (i=0; i <= 15; i++)
590 Serial.println(F(
"Reading out all Differential channels..."));
593 for (i=0; i <= 7; i++)
602 Serial.println(F(
"LTC2497 Nacked, check address."));
608 float se_results[16], diff_results[16];
615 Serial.println(F(
"\nTesting LTC2496, 16 bit ADC with a 19 bit output word using LTC24XX_SPI_8bit_command_32bit_data() function"));
616 Serial.println(F(
"Reading out all Single-Ended channels..."));
621 for (i=0; i<=15; i++)
628 Serial.println(F(
"Reading out all Differential channels..."));
648 float se_results[16], diff_results[16];
652 Serial.println(F(
"\nTesting LTC2497, 16 bit output using LTC24XX_I2C_8bit_command_24bit_data..."));
653 Serial.println(F(
"Reading out all Single-Ended channels..."));
657 for (i=0; i <= 15; i++)
663 Serial.println(F(
"Reading out all Differential channels..."));
667 for (i=0; i <= 7; i++)
676 Serial.println(F(
"LTC2497 Nacked, check address."));
682 float se_results[16], diff_results[16];
689 Serial.println(F(
"\nTesting LTC2498, 32 bit output using LTC24XX_SPI_16bit_command_32bit_data..."));
691 Serial.println(F(
"Reading out all Single-Ended channels..."));
694 for (i=0; i<=15; i++)
701 Serial.println(F(
"Reading out all Differential channels..."));
719 float se_results[16], diff_results[16];
723 Serial.println(F(
"\nTesting LTC2499, 24 bit output using LTC24XX_I2C_16bit_command_32bit_data..."));
724 Serial.println(F(
"Reading out all Single-Ended channels..."));
728 for (i=0; i <= 15; i++)
734 Serial.println(F(
"Reading out all Differential channels..."));
738 for (i=0; i <= 7; i++)
747 Serial.println(F(
"LTC2497 Nacked, check address."));
760 for (i=0; i <= 15; ++
i)
782 Serial.println(F(
"Done!"));
struct demo_board_type demo_board
Instantiate demo board structure.
#define LTC24XX_MULTI_CH_OSR_32768
#define LTC24XX_MULTI_CH_CH3
static void test_LTC2420(float vref, uint16_t eoc_timeout)
Reads the LTC2420 and displays the results.
#define LTC2412_CS_ADDR
Decoder address for the LTC2412 chip select.
void LTC24XX_SPI_32bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
#define LTC24XX_MULTI_CH_CH14
#define LTC24XX_MULTI_CH_OSR_8192
static void test_LTC2418(float vref, uint16_t eoc_timeout)
Reads the LTC2418 and displays the results.
char demo_name[]
Demo Board Name stored in QuikEval EEPROM.
#define LTC24XX_MULTI_CH_CH8
#define LTC24XX_MULTI_CH_CH15
#define LTC24XX_MULTI_CH_CH13
#define LTC24XX_MULTI_CH_CH1
#define LTC24XX_MULTI_CH_OSR_256
static void test_LTC2497(float vref, uint16_t eoc_timeout)
Reads the LTC2497 and displays the results.
#define LTC24XX_MULTI_CH_CH6
#define LTC24XX_MULTI_CH_P13_N12
#define LTC24XX_MULTI_CH_OSR_1024
#define LTC2494_CS_ADDR
Decoder address for the LTC2494 chip select.
#define LTC24XX_MULTI_CH_P1_N0
#define LTC2436_CS_ADDR
Decoder address for the LTC2436 chip select.
Header File for Linduino Libraries and Demo Code.
#define LTC2449_CS_ADDR
Decoder address for the LTC2449 chip select.
#define LTC2420_CS_ADDR
Decoder address for the LTC2420 chip select.
int8_t LTC24XX_EOC_timeout(uint8_t cs, uint16_t miso_timeout)
Checks for EOC with a specified timeout.
void LTC24XX_SPI_8bit_command_24bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit output word...
#define LTC24XX_MULTI_CH_CH5
static void print_all(float *se_results, float *diff_results)
Displays the the data in the arrays.
static uint8_t channel
LTC2305 Channel selection.
#define LTC24XX_MULTI_CH_P4_N5
#define LTC24XX_MULTI_CH_CH0
#define LTC2418_CS_ADDR
Decoder address for the LTC2418 chip select.
int8_t LTC2668_write(uint8_t cs, uint8_t dac_command, uint8_t dac_address, uint16_t dac_code)
Write the 16-bit dac_code to the LTC2668.
#define LTC24XX_MULTI_CH_CH11
int8_t LTC24XX_I2C_8bit_command_24bit_data(uint8_t i2c_address, uint8_t adc_command, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 24 bit result.
#define LTC2498_CS_ADDR
Decoder address for the LTC2498 chip select.
static void test_LTC2496(float vref, uint16_t eoc_timeout)
Reads the LTC2496 and displays the results.
void LTC24XX_SPI_8bit_command_32bit_data(uint8_t cs, uint8_t adc_command, int32_t *adc_code)
Reads from LTC24XX ADC that accepts an 8 bit configuration and returns a 32 bit result.
static void test_LTC2495(float vref, uint16_t eoc_timeout)
Reads the LTC2495 and displays the results.
LTC24XX General Library: Functions and defines for all SINC4 Delta Sigma ADCs.
#define LTC24XX_MULTI_CH_P9_N8
#define LTC24XX_MULTI_CH_P14_N15
void LTC24XX_SPI_16bit_command_32bit_data(uint8_t cs, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
#define LTC24XX_MULTI_CH_OSR_64
#define CS
The chip select.
#define LTC24XX_MULTI_CH_CH2
#define LTC2668_CS_ADDR
Decoder address for the LTC2668 chip select.
static void test_LTC2498(float vref, uint16_t eoc_timeout)
Reads the LTC2498 and displays the results.
static uint16_t eoc_timeout
timeout in ms
#define LTC2496_CS_ADDR
Decoder address for the LTC2496 chip select.
LTC2668: 16-Channel SPI 16-/12-Bit +/-10V Vout SoftSpan DACs with 10ppm/C Max Reference.
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC24XX_MULTI_CH_P3_N2
int8_t LTC24XX_I2C_16bit_command_32bit_data(uint8_t i2c_address, uint8_t adc_command_high, uint8_t adc_command_low, int32_t *adc_code, uint16_t eoc_timeout)
Reads from LTC24XX ADC that accepts a 16 bit configuration and returns a 32 bit result.
#define LTC24XX_MULTI_CH_OSR_4096
#define LTC24XX_MULTI_CH_P2_N3
#define LTC24XX_MULTI_CH_OSR_16384
#define LTC24XX_MULTI_CH_OSR_128
static void test_LTC2400(float vref, uint16_t eoc_timeout)
Reads the LTC2400 and displays the results.
static void setup()
Initialize Linduino.
void quikeval_SPI_init(void)
Configure the SPI port for 4Mhz SCK.
static void test_LTC2499(float vref, uint16_t eoc_timeout)
Reads the LTC2499 and displays the results.
static void test_LTC2494(float vref, uint16_t eoc_timeout)
Reads the LTC2494 and displays the results.
int8_t discover_demo_board(char *demo_name)
Read the ID string from the EEPROM and determine if the correct board is connected.
const uint8_t SINGLE_ENDED_CONFIG_ARRAY[16]
Lookup table to build the command for single-ended mode.
#define LTC24XX_MULTI_CH_P10_N11
#define LTC24XX_MULTI_CH_CH12
static void test_LTC2412(float vref, uint16_t eoc_timeout)
Reads the LTC2412 and displays the results.
#define LTC24XX_MULTI_CH_OSR_512
void LTC24XX_SPI_2ch_ping_pong_24bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
#define LTC24XX_MULTI_CH_P12_N13
#define LTC2439_CS_ADDR
Decoder address for the LTC2439 chip select.
LT_SPI: Routines to communicate with ATmega328P's hardware SPI port.
static void loop()
Repeats Linduino loop.
#define LTC24XX_MULTI_CH_CH7
#define LTC24XX_MULTI_CH_P5_N4
LT_I2C: Routines to communicate with ATmega328P's hardware I2C port.
#define LTC24XX_MULTI_CH_P8_N9
#define LTC24XX_MULTI_CH_P7_N6
float LTC24XX_diff_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
void quikeval_SPI_connect()
Connect SPI pins to QuikEval connector through the Linduino MUX. This will disconnect I2C...
static void test_LTC2436(float vref, uint16_t eoc_timeout)
Reads the LTC2436 and displays the results.
#define LTC24XX_MULTI_CH_CH10
#define LTC2668_CMD_WRITE_N_UPDATE_N
Write to input register n, update (power-up)
static uint16_t EOC_timout
#define LTC24XX_MULTI_CH_CH9
char product_name[15]
LTC Product (LTC2654-L16)
#define LTC24XX_MULTI_CH_P15_N14
static void test_LTC2449(float vref, uint16_t eoc_timeout)
Reads the LTC2449 and displays the results.
void LTC24XX_SPI_2ch_ping_pong_32bit_data(uint8_t cs, uint8_t *adc_channel, int32_t *code)
Reads from LTC24XX two channel "Ping-Pong" ADC, placing the channel information in the adc_channel pa...
static void test_LTC2439(float vref, uint16_t eoc_timeout)
Reads the LTC2439 and displays the results.
const uint8_t OSR_CONFIG_ARRAY[16]
Lookup table to build the OSR command.
void quikeval_I2C_init(void)
Initializes Linduino I2C port.
void quikeval_I2C_connect(void)
Switch MUX to connect I2C pins to QuikEval connector.
#define LTC2400_CS_ADDR
Decoder address for the LTC2400 chip select.
#define LTC24XX_MULTI_CH_P11_N10
#define LTC24XX_MULTI_CH_OSR_2048
float LTC24XX_SE_code_to_voltage(int32_t adc_code, float vref)
Calculates the voltage corresponding to an ADC code, given the reference voltage. ...
void LTC24XX_SPI_24bit_data(uint8_t cs, int32_t *adc_code)
Reads from LTC24XX ADC that has no configuration word and returns a 32 bit result.
#define LTC24XX_MULTI_CH_P0_N1
const uint8_t DIFF_CONFIG_ARRAY[16]
Lookup table to build the command for differential mode.
#define LTC24XX_MULTI_CH_CH4
static void test_all(float vref, uint16_t eoc_timeout)
Sets the LTC6998, reads all the ADCs, and displays the results.
#define LTC24XX_MULTI_CH_P6_N7
#define LTC2668_CS
Define the SPI CS pin.
static void set_CS_decoder(uint8_t CS_addr)