TEST_CODE_ApplyTo2V1_API
Dependencies: SDFileSystem max32630fthr USBDevice
Diff: main.cpp
- Revision:
- 1:7530b7eb757a
- Parent:
- 0:5a9619496af2
- Child:
- 3:35b05d91568d
diff -r 5a9619496af2 -r 7530b7eb757a main.cpp --- a/main.cpp Wed May 06 05:56:23 2020 +0000 +++ b/main.cpp Thu May 28 02:30:39 2020 +0000 @@ -34,13 +34,24 @@ #include "max32630fthr.h" #include "USBSerial.h" #include "I2CSlave.h" +#include "CmdHandler.h" +#include "DUT_RegConfig.h" +#include "AVDD_CONFIG.h" +#include "ServoRun.h" +#include "SDFileSystem.h" +#include "AnalogIn.h" + +#define EVIC + +void usb_rx_callback(void); +void usb_receive(void); MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); // Hardware serial port over DAPLink -Serial uart(P2_1, P2_0); +Serial uart(P3_1, P3_0); -I2C slave(P3_4, P3_5); +I2C i2c_v(P3_4, P3_5); // Virtual serial port over USB USBSerial microUSB; @@ -48,26 +59,119 @@ DigitalOut gLED(LED2); DigitalOut bLED(LED3); +//======for EVIC +#ifdef EVIC +AnalogIn ain(AIN_1); +DigitalOut xSHUT(P5_3); +InterruptIn chip_int(P3_2); +//AnalogIn() +DigitalOut AVDDEN(P3_3); +DigitalOut HIGH_EN(P5_6); +DigitalOut A0(P4_0); + +DigitalOut PULSE(P5_1); +DigitalOut DI(P5_2); + +SDFileSystem sd(P0_5, P0_6, P0_4, P0_7, "sd"); // mosi, miso, sclk, cs +#endif +//====== + +//======for Ofilm +#ifdef OFILM +DigitalOut xSHUT(P5_4); +DigitalOut EN_Power(P5_3); +DigitalOut EN_OSC(P5_5); +InterruptIn chip_int(P3_3); +#endif +//====== + + + +//Queue<uint8_t, 2048> cmd_queue; + +Thread cmd_handle_thread; +Thread coutinu_measure_thread; +Thread Histogram_thread; +Thread Sevo_Thread; +//Thread usb_receive_thread; + +Semaphore usb_semph(32); + // main() runs in its own thread in the OS // (note the calls to Thread::wait below for delays) int main() { - microUSB.printf("micro USB serial port\r\n"); + //microUSB.printf("micro USB serial port\r\n"); + + float v = 2.7; + uint8_t test = 0; + float V_I[10]; - rLED = LED_ON; - gLED = LED_ON; - bLED = LED_OFF; + #ifdef EVIC + xSHUT = 1; + AVDDEN = 1; + HIGH_EN = 0; + A0 = 0; + DI = 0; + PULSE = 0; + #endif + + #ifdef OFILM + xSHUT = 1; + EN_Power = 0; + EN_OSC = 0; + #endif + + //uart.baud(115200); + microUSB.attach(usb_rx_callback); + chip_int.rise(InterruptHandle); rLED = LED_OFF; + gLED = LED_OFF; + bLED = LED_OFF; + + i2c_v.frequency(100000); - slave.frequency(400000); - + SetVoltageAVDD(3.3); - while(1) - { - microUSB.printf("micro USB serial port\r\n"); + //wait(1); + DUT_RegInit(); + wait(1); + //DUT_FirmwareInit(); + + cmd_handle_thread.start(CmdHandleTask); + coutinu_measure_thread.start(ContinuousMeasureReport); + Histogram_thread.start(HistogramReport); + //usb_receive_thread.start(usb_receive); + Sevo_Thread.start(ServoRunThread); + + while(1) { + //microUSB.printf("micro USB serial port\r\n"); + //microUSB.writeBlock((uint8_t*)"Hello", 5); bLED = !bLED; + + V_I[0] = ain.read()*5000.0f; + HandleFreqReport(V_I); + //SetVoltageAVDD(v); + //v = v + 0.1; + //if(v > 3.7) + // v = 2.7; wait(2); + + //if(test < 10) + // ServoRun(1,10);//Back 10mm + //else if(test > 10) + // ServoRun(0,10);//Forward 10mm + //test++; + //if(test == 20) + // test = 0; } } +void usb_rx_callback(void) +{ + //usb_semph.release(); +} + + +