Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: max32625pico USBDevice
Diff: main.cpp
- Revision:
- 4:1c6819a42db0
- Parent:
- 3:7264c8044625
- Child:
- 5:39fe91b6d3f0
--- a/main.cpp Sun Nov 20 23:58:11 2016 +0000
+++ b/main.cpp Fri Dec 09 22:17:16 2016 +0000
@@ -4,26 +4,94 @@
MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
-DigitalOut rLED(LED1);
-DigitalOut gLED(LED2);
+// Hardware serial port over DAPLink
+Serial daplink(P2_1, P2_0);
+
+DigitalOut rLED(LED1, LED_ON);
+DigitalOut gLED(LED2, LED_OFF);
+DigitalOut bLED(LED3, LED_OFF);
+AnalogIn monIn(AIN_0);
+AnalogIn vddbIn(AIN_6);
+AnalogIn vdd18In(AIN_7);
+AnalogIn vdd12In(AIN_8);
+AnalogIn vrtcIn(AIN_9);
+
+// Function to report failure
+void testFailed()
+{
+ daplink.printf("\r\n! Test Failed !\r\n");
+ rLED = LED_ON;
+ gLED = LED_OFF;
+ bLED = LED_OFF;
+ while(1) {
+ Thread::wait(500);
+ gLED = !gLED;
+ }
+}
+
+// Function to read monitor port
+float readMon(MAX14690::monCfg_t monCfg){
+ pegasus.max14690.monSet(monCfg, MAX14690::MON_DIV4);
+ Thread::wait(5);
+ return (4.8f * monIn);
+}
// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
int main()
{
- gLED = LED_OFF;
- rLED = LED_ON;
+ float aIn;
+ daplink.printf("Initializing MAX32630FTHR\r\n");
pegasus.init();
+ daplink.printf("Checking Supplies\r\n");
+ aIn = 2.4f * vdd12In;
+ daplink.printf("vdd12 = %f\r\n", aIn);
+ if ((aIn < 1.0f) || (aIn > 1.4f)) { testFailed(); }
+ aIn = 2.4f * vdd18In;
+ daplink.printf("vdd18 = %f\r\n", aIn);
+ if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
+ aIn = 4.8f * vddbIn;
+ daplink.printf("vddb = %f\r\n", aIn);
+ if ((aIn < 3.0f) || (aIn > 3.6f)) { testFailed(); }
+ aIn = 2.4f * vrtcIn;
+ daplink.printf("vrtc = %f\r\n", aIn);
+ if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_SYS);
+ daplink.printf("sys = %f\r\n", aIn);
+ if ((aIn < 3.0f) || (aIn > 5.0f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_BUCK1);
+ daplink.printf("buck1 = %f\r\n", aIn);
+ if ((aIn < 1.0f) || (aIn > 1.4f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_BUCK2);
+ daplink.printf("buck2 = %f\r\n", aIn);
+ if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_LDO1);
+ daplink.printf("ldo1 = %f\r\n", aIn);
+ if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_LDO2);
+ daplink.printf("ldo2 = %f\r\n", aIn);
+ if ((aIn < 3.0f) || (aIn > 3.6f)) { testFailed(); }
+ aIn = readMon(MAX14690::MON_LDO3);
+ daplink.printf("ldo3 = %f\r\n", aIn);
+ aIn = readMon(MAX14690::MON_LDO3);
gLED = LED_ON;
- Thread::wait(100);
USBMSD_SD sd(P0_5, P0_6, P0_4, P0_7); // mosi, miso, sclk, cs
rLED = LED_OFF;
+ bLED = LED_ON;
+ daplink.printf("Self Test Passed\r\n");
+
while (true) {
- gLED = !gLED;
Thread::wait(500);
+ rLED = LED_OFF;
+ gLED = LED_ON;
+ bLED = LED_OFF;
+ Thread::wait(500);
+ rLED = LED_ON;
+ gLED = LED_ON;
+ bLED = LED_ON;
}
}