Test program running on MAX32625MBED. Control through USB Serial commands using a terminal emulator such as teraterm or putty.
Dependencies: MaximTinyTester CmdLine MAX541 USBDevice
Diff: MAX11043/MAX11043.cpp
- Revision:
- 75:0900a57f2e5d
- Parent:
- 74:f4f969c9a7a9
- Child:
- 76:0397493d7baf
--- a/MAX11043/MAX11043.cpp Sun Feb 23 11:38:40 2020 +0000 +++ b/MAX11043/MAX11043.cpp Sun Feb 23 12:34:49 2020 +0000 @@ -56,6 +56,12 @@ // Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected // WIP MAX11043 interrupt EOC echo - moving DigitalOut ScopeTrigger to global scope, it compiles but there is no activity on scope extern DigitalInOut digitalInOut5; // declared in Test_Main_MAX11043.cpp (D5, PIN_INPUT, PullUp, 1) +const size_t byteCount_onEOCFallingEdge = 1 + (2 * 4); +const uint8_t mosiData_onEOCFallingEdge[9] = { + MAX11043::CMD_0001_1010_d16o8_d16o8_d16o8_d16o8_Rd06_ADCabcd, + 0, 0, 0, 0, 0, 0, 0, 0 +}; +uint8_t misoData_onEOCFallingEdge[9]; #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5 // Device Name = MAX11043 @@ -255,7 +261,7 @@ digitalInOut5.write(1); // ScopeTrigger #endif // MAX11043_ScopeTrigger_MAX32625MBED_D5 #endif -#if 0 +#if 1 // TODO: read 4 channels in response to EOC# falling edge // WIP MAX11043 interrupt CRASH on Menu item HH CONVRUN High // @@ -268,10 +274,53 @@ // For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115 // -- MbedOS Error Info -- extern MAX11043 g_MAX11043_device; - g_MAX11043_device.Read_ADCabcd(); + //~ g_MAX11043_device.Read_ADCabcd(); // read register ADCabcd -> &adca, &adcb, &adcc, &adcd // g_MAX11043_device.RegRead(CMD_0001_1010_d16o8_d16o8_d16o8_d16o8_Rd06_ADCabcd, 0); + // SPI 8+64 = 72-bit transfer + // 1234 5678 ___[1]_16 ___[2]_24 ___[3]_32 ___[4]_40 ___[5]_48 ___[6]_56 ___[7]_64 ___[8]_72 + // SPI MOSI = 1aaa_aaaa_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000 ... _0000 + // SPI MISO = xxxx_xxxx_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd_dddd ... _xxxx + // global const size_t byteCount_onEOCFallingEdge = 1 + (2 * 4); + // global const uint8_t mosiData_onEOCFallingEdge[9] = { + // global CMD_0001_1010_d16o8_d16o8_d16o8_d16o8_Rd06_ADCabcd, + // global 0, 0, 0, 0, 0, 0, 0, 0 + // global }; + // global uint8_t misoData_onEOCFallingEdge[9]; + // SPIreadWriteWithLowCS(size_t byteCount, uint8_t mosiData[], uint8_t misoData[]); + // SPIreadWriteWithLowCS(byteCount_onEOCFallingEdge, mosiData_onEOCFallingEdge, misoData_onEOCFallingEdge); + // onSPIprint() is not interrupt-safe + // unsigned int numBytesTransferred = m_spi.write((char*)mosiData, byteCount, (char*)misoData, byteCount); + // g_MAX11043_device.m_spi is inaccessible + extern SPI spi; // declared in Test_Main_MAX11043.cpp + spi.write((char*)mosiData_onEOCFallingEdge, byteCount_onEOCFallingEdge, (char*)misoData_onEOCFallingEdge, byteCount_onEOCFallingEdge); + // + // ++ MbedOS Error Info ++ + // Error Status: 0x80020115 Code: 277 Module: 2 + // Error Message: Mutex lock failed + // Location: 0xBABB + // Error Value: 0xFFFFFFFA + // Current Thread: main Id: 0x20002CD0 Entry: 0xBD9F StackSize: 0x1000 StackMem: 0x20001CD0 SP: 0x20027F10 + // For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80020115 + // -- MbedOS Error Info -- + // + //if (ptrRegData) { (*ptrRegData) = (misoData[1] << 8) | misoData[2]; } + //if (commandByte == CMD_0001_1010_d16o8_d16o8_d16o8_d16o8_Rd06_ADCabcd) { + // TODO1: update adca + //g_MAX11043_device.adca = (misoData_onEOCFallingEdge[1] << 8) | misoData_onEOCFallingEdge[2]; + // TODO1: update adcb + //g_MAX11043_device.adcb = (misoData_onEOCFallingEdge[3] << 8) | misoData_onEOCFallingEdge[4]; + // TODO1: update adcc + //g_MAX11043_device.adcc = (misoData_onEOCFallingEdge[5] << 8) | misoData_onEOCFallingEdge[6]; + // TODO1: update adcd + //g_MAX11043_device.adcd = (misoData_onEOCFallingEdge[7] << 8) | misoData_onEOCFallingEdge[8]; + //} #endif +#if MAX11043_ScopeTrigger_MAX32625MBED_D5 +// Diagnostic: Use MAX32625MBED pin D5 as DigitalOut EOC#-detected + digitalInOut5.write(0); // ScopeTrigger + digitalInOut5.write(1); // ScopeTrigger +#endif // MAX11043_ScopeTrigger_MAX32625MBED_D5 } #endif // MAX11043_EOC_INTERRUPT_POLLING