Internal_Datalogger but with USB support removed (for MAX40108 Demo board), proof of concept that MAX32625 can be used successfully with VDDB(USB) left unpowered, as long as the USB library is not used.
Dependencies: max32625pico CmdLine
Diff: DataLogger_Internal.cpp
- Revision:
- 3:9055e17e181a
- Parent:
- 2:3caa9b974176
- Child:
- 4:d9b05924ad4c
diff -r 3caa9b974176 -r 9055e17e181a DataLogger_Internal.cpp --- a/DataLogger_Internal.cpp Fri Nov 06 06:12:35 2020 +0000 +++ b/DataLogger_Internal.cpp Wed Nov 25 06:18:08 2020 +0000 @@ -83,11 +83,16 @@ // - see https://os.mbed.com/teams/MaximIntegrated/wiki/MAX32625PICO-Firmware-Updates // // end Platform_Include_Boilerplate -//~ #include "MAX11410.h" - //-------------------------------------------------- - +// Option to use SPI connected ADC +#ifndef SPI_ADC_DeviceName +//~ #define SPI_ADC_DeviceName MAX11410 +#undef SPI_ADC_DeviceName +#endif +#if defined(SPI_ADC_DeviceName) // SPI connected ADC +#include "MAX11410.h" +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC #if defined(TARGET) // TARGET_NAME macros from targets/TARGET_Maxim/TARGET_MAX32625/device/mxc_device.h @@ -1553,13 +1558,79 @@ //-------------------------------------------------- // Option to validate SPI link by reading PART_ID register #ifndef VERIFY_PART_ID_IN_LOOP +#if defined(SPI_ADC_DeviceName) // SPI connected ADC +#define VERIFY_PART_ID_IN_LOOP 1 +#else #define VERIFY_PART_ID_IN_LOOP 0 +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC #endif +//-------------------------------------------------- +#define NUM_DUT_ANALOG_IN_CHANNELS 10 + +#if defined(SPI_ADC_DeviceName) // SPI connected ADC +// MAX11410 individual channels 1=LSB, 2=Volt, 0=Disabled +typedef enum SPI_AIN_Enable_t { + Disable = 0, + Enable_LSB = 1, + Enable_Volt = 2, +} SPI_AIN_Enable_t; +uint8_t SPI_AIN_Enable_ch[NUM_DUT_ANALOG_IN_CHANNELS] = { + Enable_LSB, // AIN0 1=LSB + Enable_LSB, // AIN1 1=LSB + Enable_LSB, // AIN2 1=LSB + Enable_LSB, // AIN3 1=LSB + Enable_LSB, // AIN4 1=LSB + Enable_LSB, // AIN5 1=LSB + Enable_LSB, // AIN6 1=LSB + Enable_LSB, // AIN7 1=LSB + Enable_LSB, // AIN8 1=LSB + Enable_LSB, // AIN9 1=LSB +}; +// +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC // ---------- Measure_Voltage_custom_props in Measure_Voltage @pre and in class properties ---------- -// const uint8_t custom_v_filter = 0x34; -// const uint8_t custom_v_ctrl = 0x34; -// const uint8_t custom_v_pga = 0x34; +#if defined(SPI_ADC_DeviceName) // SPI connected ADC +uint8_t SPI_AIN_Cfg_v_filter_ch[NUM_DUT_ANALOG_IN_CHANNELS] = { + 0x34, // AIN0 @ v_filter=0x34 + 0x34, // AIN1 @ v_filter=0x34 + 0x34, // AIN2 @ v_filter=0x34 + 0x34, // AIN3 @ v_filter=0x34 + 0x34, // AIN4 @ v_filter=0x34 + 0x34, // AIN5 @ v_filter=0x34 + 0x34, // AIN6 @ v_filter=0x34 + 0x34, // AIN7 @ v_filter=0x34 + 0x34, // AIN8 @ v_filter=0x34 + 0x34, // AIN9 @ v_filter=0x34 +}; +// +uint8_t SPI_AIN_Cfg_v_ctrl_ch[NUM_DUT_ANALOG_IN_CHANNELS] = { + 0x42, // AIN0 @ v_ctrl=0x42 + 0x42, // AIN1 @ v_ctrl=0x42 + 0x42, // AIN2 @ v_ctrl=0x42 + 0x42, // AIN3 @ v_ctrl=0x42 + 0x42, // AIN4 @ v_ctrl=0x42 + 0x42, // AIN5 @ v_ctrl=0x42 + 0x42, // AIN6 @ v_ctrl=0x42 + 0x42, // AIN7 @ v_ctrl=0x42 + 0x42, // AIN8 @ v_ctrl=0x42 + 0x42, // AIN9 @ v_ctrl=0x42 +}; +// +uint8_t SPI_AIN_Cfg_v_pga_ch[NUM_DUT_ANALOG_IN_CHANNELS] = { + 0x00, // AIN0 @ v_pga=0x00 + 0x00, // AIN1 @ v_pga=0x00 + 0x00, // AIN2 @ v_pga=0x00 + 0x00, // AIN3 @ v_pga=0x00 + 0x00, // AIN4 @ v_pga=0x00 + 0x00, // AIN5 @ v_pga=0x00 + 0x00, // AIN6 @ v_pga=0x00 + 0x00, // AIN7 @ v_pga=0x00 + 0x00, // AIN8 @ v_pga=0x00 + 0x00, // AIN9 @ v_pga=0x00 +}; +// +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC // ---------- Measure_Voltage_custom_props ---------- // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ---------- // filter register configuration in Measure_Voltage and Read_All_Voltages CONV_TYPE_01_Continuous @@ -1610,7 +1681,7 @@ // // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ---------- // ctrl register configuration in Measure_Voltage and Read_All_Voltages -//~ const uint8_t custom_v_ctrl = 0x02; // @ v_ctrl=0x02 -- 0x00 bipolar 2's complement, 0x02 REF_SEL_010_REF2P_REF2N +//~ const uint8_t custom_v_ctrl = 0x42; // @ v_ctrl=0x42 -- 0x40 unipolar, 0x02 REF_SEL_010_REF2P_REF2N //~ const uint8_t custom_v_ctrl = 0x40; // @ v_ctrl=0x40 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1 //~ const uint8_t custom_v_ctrl = 0x44; // @ v_ctrl=0x44 -- 0x40 unipolar, 0x04 REF_SEL_100_AIN0_AGND //~ const uint8_t custom_v_ctrl = 0x58; // @ v_ctrl=0x58 -- 0x40 unipolar, 0x00 REF_SEL_000_AIN0_AIN1, 0x18 refbuf @@ -1630,6 +1701,7 @@ //~ const uint8_t custom_v_ctrl = 0x07; // @ v_ctrl=0x07 -- 0x00 bipolar 2's complement, 0x07 REF_SEL_111_AVDD_AGND // ---------- CUSTOMIZED from MAX11410_Hello ---------- +#if defined(SPI_ADC_DeviceName) // SPI connected ADC // example code declare SPI interface (GPIO controlled CS) #if defined(TARGET_MAX32625MBED) SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 @@ -1650,16 +1722,22 @@ DigitalOut spi_cs(SPI_CS); // TARGET_NUCLEO_F446RE: PB_6 Arduino 10-pin header D10 // #else -//~ SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 -//~ DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 +SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 +DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 #endif // example code declare GPIO interface pins // example code declare device instance -//~ MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC); +MAX11410 g_MAX11410_device(spi, spi_cs, MAX11410::MAX11410_IC); +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC //-------------------------------------------------- -// Option to use platform analog inputs +// Option to Datalog Arduino platform analog inputs +#ifndef LOG_PLATFORM_AIN +#define LOG_PLATFORM_AIN 6 +//~ #undef LOG_PLATFORM_AIN +#endif +#if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs //#ifndef NUM_PLATFORM_ANALOG_IN_CHANNELS //#define NUM_PLATFORM_ANALOG_IN_CHANNELS 6 //#endif @@ -1689,6 +1767,7 @@ #if LOG_PLATFORM_ANALOG_IN_VOLTS double Platform_Voltage[NUM_PLATFORM_ANALOG_IN_CHANNELS]; #endif +#endif // defined(LOG_PLATFORM_AIN) // CODE GENERATOR: example code for ADC: serial port declaration //-------------------------------------------------- @@ -1718,8 +1797,29 @@ //-------------------------------------------------- #elif defined(TARGET_MAX32625PICO) #include "USBSerial.h" +// Virtual serial port over USB // The baud rate does not affect the virtual USBSerial UART. -USBSerial serial; // virtual serial port over USB (DEV connector) +USBSerial serial; +//-------------------------------------------------- +#elif defined(TARGET_MAX32620FTHR) +#warning "TARGET_MAX32620FTHR not previously tested; need to define serial pins..." +// Hardware serial port over DAPLink +// The default baud rate for the DapLink UART is 9600 +Serial DAPLINKserial(USBTX, USBRX); // tx, rx MAX32620FTHR: P2_1,P2_0 +//Serial DAPLINKserial(STDIO_UART_TX, STDIO_UART_RX); // tx, rx + #define HAS_DAPLINK_SERIAL 1 +// Virtual serial port over USB +// The baud rate does not affect the virtual USBSerial UART. +// #include "USBSerial.h" +//USBSerial serial; +//Serial serial(UART0_TX, UART0_RX); // tx, rx MAX32620FTHR: P0_1,P0_0 (PMOD Port 0) +//Serial serial(UART1_TX, UART1_RX); // tx, rx MAX32620FTHR: P2_1,P2_0 (DAPLINK) +Serial serial(UART2_TX, UART2_RX); // tx, rx MAX32620FTHR: P3_1,P3_0 (J1.15,J1.14) +//Serial serial(UART3_TX, UART3_RX); // tx, rx MAX32620FTHR: P5_4,P5_3 (J2.7,J2.8) +//Serial serial(SERIAL_TX, SERIAL_RX); // tx, rx +//Serial serial(USBTX, USBRX); // tx, rx +//Serial serial(UART_TX, UART_RX); // tx, rx +// //-------------------------------------------------- #elif defined(TARGET_MAX32600) #include "USBSerial.h" @@ -1763,80 +1863,156 @@ // example code: serial port banner message wait(3); // 3000ms timing delay function, platform-specific +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + cmdLine.serial().printf("\r\nDataLogger_MAX11410\r\n"); // instead of Hello_MAX11410 +#else // defined(SPI_ADC_DeviceName) // SPI connected ADC cmdLine.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410 - +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\nInternal_DataLogger\r\n"); // instead of Hello_MAX11410 +# endif // HAS_DAPLINK_SERIAL +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC + // CODE GENERATOR: get spi properties from device - // if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency()) - // { // Device limits SPI SCLK frequency - // g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency(); - // cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz); -// - // g_MAX11410_device.Init(); - // } - // if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz) - // { // Platform limits SPI SCLK frequency - // g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); - // cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz); -// - // g_MAX11410_device.Init(); - // } +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + if (g_SPI_SCLK_Hz > g_MAX11410_device.get_spi_frequency()) + { // Device limits SPI SCLK frequency + g_SPI_SCLK_Hz = g_MAX11410_device.get_spi_frequency(); + cmdLine.serial().printf("\r\nMAX11410 limits SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz); + + g_MAX11410_device.Init(); + } + if (g_MAX11410_device.get_spi_frequency() > g_SPI_SCLK_Hz) + { // Platform limits SPI SCLK frequency + g_MAX11410_device.spi_frequency(g_SPI_SCLK_Hz); + cmdLine.serial().printf("\r\nPlatform limits MAX11410 SPI SCLK frequency to %ld Hz\r\n", g_SPI_SCLK_Hz); + + g_MAX11410_device.Init(); + } // g_SPI_dataMode = g_MAX11410_device.get_spi_dataMode(); - // while (g_MAX11410_device.Init() == 0) - // { - // wait(3); // 3000ms timing delay function, platform-specific - // cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n"); -// - // } + while (g_MAX11410_device.Init() == 0) + { + wait(3); // 3000ms timing delay function, platform-specific + cmdLine.serial().printf("\r\nMAX11410 Init failed; retry...\r\n"); + + } // ---------- CUSTOMIZED from MAX11410_Hello after g_MAX11410_device.Init() ---------- - //~ g_MAX11410_device.v_filter = custom_v_filter; - //~ g_MAX11410_device.v_pga = custom_v_pga; - //~ g_MAX11410_device.v_ctrl = custom_v_ctrl; +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0]; + g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0]; + g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0]; +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC // ---------- CUSTOMIZED from MAX11410_Hello ---------- +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC // CODE GENERATOR: example code: has no member function REF // CODE GENERATOR: example code for ADC: repeat-forever convert and print conversion result, one record per line // CODE GENERATOR: ResolutionBits = 24 // CODE GENERATOR: FScode = 0xffffff // CODE GENERATOR: NumChannels = 10 // CODE GENERATOR: banner before DataLogHelloCppCodeList while(1) - //~ cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter); +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + cmdLine.serial().printf("v_filter = 0x%2.2x\r\n", g_MAX11410_device.v_filter); - //~ cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga); + cmdLine.serial().printf("v_pga = 0x%2.2x\r\n", g_MAX11410_device.v_pga); - //~ cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl); + cmdLine.serial().printf("v_ctrl = 0x%2.2x\r\n", g_MAX11410_device.v_ctrl); + +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC - // banner for csv data columns + // column header banner for csv data columns //~ cmdLine.serial().printf("\"AIN0_V\",\"AIN1_V\",\"AIN2_V\",\"AIN3_V\",\"AIN4_V\",\"AIN5_V\",\"AIN6_V\",\"AIN7_V\",\"AIN8_V\",\"AIN9_V\""); - // cmdLine.serial().printf("\"AIN%d_V\"", 0); - for (int index = 0; index < NUM_PLATFORM_ANALOG_IN_CHANNELS; index++) { - if (index > 0) { cmdLine.serial().printf(","); } - cmdLine.serial().printf("\"AIN%d", index); + int field_index = 0; +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; field_index++, channel_index++) { + if (SPI_AIN_Enable_ch[channel_index] == Disable) { + continue; + } + // comma between fields + if (field_index > 0) { + cmdLine.serial().printf(","); + } + // AIN_index column header prefix +#if SPI_ADC_DeviceName == MAX11410 // SPI connected ADC + // MAX11410 v_ctrl bipolar configuration or unipolar? + if ((SPI_AIN_Cfg_v_ctrl_ch[channel_index] & 0x40) == 0) { + cmdLine.serial().printf("\"AIN%d-%d_BIP", channel_index, channel_index+1); + } + else { + cmdLine.serial().printf("\"AIN%d", channel_index); + } +#else // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC + cmdLine.serial().printf("\"AIN%d", channel_index); +#endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC + if (SPI_AIN_Enable_ch[channel_index] == Enable_LSB) { + cmdLine_DAPLINKserial.serial().printf("\"AIN%d", channel_index); +# endif // HAS_DAPLINK_SERIAL #if LOG_PLATFORM_ANALOG_IN_LSB + // _LSB column header suffix + cmdLine.serial().printf("_LSB\""); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("_LSB\""); +# endif // HAS_DAPLINK_SERIAL + } + else if (SPI_AIN_Enable_ch[channel_index] == Enable_Volt) { + // _V column header suffix + cmdLine.serial().printf("_V\""); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("_V\""); +# endif // HAS_DAPLINK_SERIAL + } + } + +#if VERIFY_PART_ID_IN_LOOP + // PART_ID field: Device ID Validation + cmdLine.serial().printf(",\"PART_ID\""); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf(",\"PART_ID\""); +# endif // HAS_DAPLINK_SERIAL +#endif // VERIFY_PART_ID_IN_LOOP +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC +#if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs + for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; field_index++, channel_index++) { + // comma between fields + if (field_index > 0) { + cmdLine.serial().printf(","); + } + // AIN_index column header prefix + cmdLine.serial().printf("\"A%d", channel_index); +#if LOG_PLATFORM_ANALOG_IN_LSB + // _LSB column header suffix cmdLine.serial().printf("_LSB\""); #elif LOG_PLATFORM_ANALOG_IN_VOLTS + // _V column header suffix cmdLine.serial().printf("_V\""); #endif } - -#if VERIFY_PART_ID_IN_LOOP - cmdLine.serial().printf(",\"PART_ID\""); -#endif // VERIFY_PART_ID_IN_LOOP +#endif // defined(LOG_PLATFORM_AIN) + // end of column header line cmdLine.serial().printf("\r\n"); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\n"); +# endif // HAS_DAPLINK_SERIAL while(1) { // this code repeats forever // this code repeats forever // CODE GENERATOR: example code: has no member function ScanStandardExternalClock // CODE GENERATOR: example code: has no member function ReadAINcode // CODE GENERATOR: example code: member function Read_All_Voltages +#if defined(SPI_ADC_DeviceName) // SPI connected ADC // Measure ADC channels in sequence from AIN0 to channelNumber_0_9. // @param[in] g_MAX11410_device.channelNumber_0_15: AIN Channel Number // @param[in] g_MAX11410_device.PowerManagement_0_2: 0=Normal, 1=AutoShutdown, 2=AutoStandby // @param[in] g_MAX11410_device.chan_id_0_1: ADC_MODE_CONTROL.CHAN_ID - //~ int channelId_0_9 = 9; + int channelId_0_9 = NUM_DUT_ANALOG_IN_CHANNELS-1+1; //g_MAX11410_device.channelNumber_0_15 = channelId_0_9; //g_MAX11410_device.PowerManagement_0_2 = 0; //g_MAX11410_device.chan_id_0_1 = 1; - //~ g_MAX11410_device.Read_All_Voltages(); + //---------------------------------------- + // scan AIN0..AIN9 + // + g_MAX11410_device.Read_All_Voltages(); +#endif // SPI_ADC_DeviceName == MAX11410 // SPI connected ADC +#if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs // mbed // Platform board uses simple analog inputs #if LOG_PLATFORM_ANALOG_IN_LSB @@ -1854,9 +2030,10 @@ Platform_Voltage[4] = analogIn4.read() * adc_full_scale_voltage[4]; Platform_Voltage[5] = analogIn5.read() * adc_full_scale_voltage[5]; #endif +#endif // defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs #if VERIFY_PART_ID_IN_LOOP - // Device ID Validation + // PART_ID field: Device ID Validation const uint32_t part_id_expect = 0x000F02; uint32_t part_id_readback; g_MAX11410_device.RegRead(MAX11410::CMD_r001_0001_xxxx_xxxx_xxxx_xxxx_xxxx_xddd_PART_ID, &part_id_readback); @@ -1865,29 +2042,68 @@ // wait(3.0); // CODE GENERATOR: print conversion result // Use Arduino Serial Plotter to view output: Tools | Serial Plotter - for (int index = 0; index < NUM_PLATFORM_ANALOG_IN_CHANNELS; index++) { - if (index > 0) { cmdLine.serial().printf(","); } -#if LOG_PLATFORM_ANALOG_IN_LSB - cmdLine.serial().printf("%u", Platform_LSB[index]); -#elif LOG_PLATFORM_ANALOG_IN_VOLTS - cmdLine.serial().printf("%6.6fV", Platform_Voltage[index]); -#endif + field_index = 0; +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + for (int channel_index = 0; channel_index < NUM_DUT_ANALOG_IN_CHANNELS; field_index++, channel_index++) { + if (SPI_AIN_Enable_ch[channel_index] == Disable) { + continue; + } + // comma between fields + if (field_index > 0) { + cmdLine.serial().printf(","); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf(","); +# endif // HAS_DAPLINK_SERIAL + } + cmdLine.serial().printf("%d", g_MAX11410_device.AINcode[channel_index]); } #if VERIFY_PART_ID_IN_LOOP + // PART_ID field: Device ID Validation if (part_id_readback != part_id_expect) { cmdLine.serial().printf(",\"FAIL\""); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf(",\"FAIL\""); +# endif // HAS_DAPLINK_SERIAL - //~ g_MAX11410_device.Init(); - //~ g_MAX11410_device.v_filter = custom_v_filter; - //~ g_MAX11410_device.v_pga = custom_v_pga; - //~ g_MAX11410_device.v_ctrl = custom_v_ctrl; +#if defined(SPI_ADC_DeviceName) // SPI connected ADC + g_MAX11410_device.Init(); + g_MAX11410_device.v_filter = SPI_AIN_Cfg_v_filter_ch[0]; + g_MAX11410_device.v_ctrl = SPI_AIN_Cfg_v_ctrl_ch[0]; + g_MAX11410_device.v_pga = SPI_AIN_Cfg_v_pga_ch[0]; +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC } else { cmdLine.serial().printf(",\"OK\""); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf(",\"OK\""); +# endif // HAS_DAPLINK_SERIAL } #endif // VERIFY_PART_ID_IN_LOOP +#endif // defined(SPI_ADC_DeviceName) // SPI connected ADC +#if defined(LOG_PLATFORM_AIN) // Datalog Arduino platform analog inputs + for (int channel_index = 0; channel_index < NUM_PLATFORM_ANALOG_IN_CHANNELS; field_index++, channel_index++) { + // comma between fields + if (field_index > 0) { + cmdLine.serial().printf(","); + } +#if LOG_PLATFORM_ANALOG_IN_LSB + cmdLine.serial().printf("%u", Platform_LSB[channel_index]); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("%u", Platform_LSB[channel_index]); +# endif // HAS_DAPLINK_SERIAL +#elif LOG_PLATFORM_ANALOG_IN_VOLTS + cmdLine.serial().printf("%6.6fV", Platform_Voltage[channel_index]); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("%6.6fV", Platform_Voltage[channel_index]); +# endif // HAS_DAPLINK_SERIAL +#endif // #if LOG_PLATFORM_ANALOG_IN_LSB LOG_PLATFORM_ANALOG_IN_VOLTS + } +#endif // defined(LOG_PLATFORM_AIN) cmdLine.serial().printf("\r\n"); +# if HAS_DAPLINK_SERIAL + cmdLine_DAPLINKserial.serial().printf("\r\n"); +# endif // HAS_DAPLINK_SERIAL } // this code repeats forever }