System print
Dependencies: max32625pico SerialInterface USBDevice
Diff: main.cpp
- Revision:
- 10:227698c63531
- Parent:
- 9:674b1077b3ec
- Child:
- 14:2a4baa07d46d
diff -r 674b1077b3ec -r 227698c63531 main.cpp --- a/main.cpp Fri Mar 24 16:48:24 2017 +0000 +++ b/main.cpp Tue May 23 00:14:46 2017 +0000 @@ -1,17 +1,15 @@ #include "mbed.h" #include "rtos.h" +#include "max32625pico.h" #include "USBKeyboard.h" // Hardware serial port over DAPLink Serial daplink(P2_1, P2_0); -DigitalOut rLED(LED1, LED_ON); +DigitalOut rLED(LED1, LED_OFF); DigitalOut gLED(LED2, LED_OFF); DigitalOut bLED(LED3, LED_OFF); DigitalIn button(P2_7, PullUp); -DigitalOut en3V3(P3_6, 0); -DigitalOut enIOH(P2_2, 0); -DigitalOut selSWD(P2_3, 0); AnalogIn dipIOH(AIN_4); AnalogIn swdIOH(AIN_5); AnalogIn vddbIn(AIN_6); @@ -21,16 +19,18 @@ USBKeyboard keyboard; +MAX32625PICO pico(MAX32625PICO::IOH_DIP_IN, MAX32625PICO::VIO_IOH, MAX32625PICO::VIO_1V8); + // Function to report failure void testFailed() { daplink.printf("\r\n! Test Failed !\r\n"); -// rLED = LED_ON; -// gLED = LED_OFF; -// bLED = LED_OFF; + rLED = LED_ON; + gLED = LED_OFF; + bLED = LED_OFF; while(1) { Thread::wait(500); - rLED = !rLED; + gLED = !gLED; } } @@ -41,6 +41,10 @@ float aIn; int ledCnt = 0; + rLED = LED_ON; + gLED = LED_ON; + bLED = LED_OFF; + daplink.printf("Checking Supplies\r\n"); aIn = 2.4f * vdd12In; daplink.printf("vdd12 = %f\r\n", aIn); @@ -63,55 +67,15 @@ testFailed(); } - en3V3 = 1; - bLED = LED_ON; - Thread::wait(100); - - daplink.printf("Checking Switches\r\n"); aIn = 6.0f * dipIOH; - Thread::wait(100); - aIn = 6.0f * dipIOH; - daplink.printf("dipIOH(open) = %f\r\n", aIn); - if (aIn > 0.1f) { - testFailed(); - } - aIn = 6.0f * swdIOH; - Thread::wait(100); - aIn = 6.0f * swdIOH; - daplink.printf("swdIOH(open) = %f\r\n", aIn); - if (aIn > 0.1f) { - testFailed(); - } - - enIOH = 1; - rLED = LED_OFF; - Thread::wait(100); - - aIn = 6.0f * dipIOH; - Thread::wait(100); - aIn = 6.0f * dipIOH; - daplink.printf("dipIOH(closed) = %f\r\n", aIn); -// aIn = 6.0f * swdIOH; -// daplink.printf("swdIOH(closed) = %f\r\n", aIn); - if ((aIn < 3.0f) || (aIn > 3.6f)) { -// testFailed(); - } - - selSWD = 1; - gLED = LED_ON; - Thread::wait(100); + daplink.printf("dipIOH = %f\r\n", aIn); aIn = 6.0f * swdIOH; - Thread::wait(100); - aIn = 6.0f * swdIOH; - daplink.printf("swdIOH(closed) = %f\r\n", aIn); -// aIn = 6.0f * dipIOH; -// daplink.printf("dipIOH(closed) = %f\r\n", aIn); - if ((aIn < 3.0f) || (aIn > 3.6f)) { - testFailed(); - } + daplink.printf("swdIOH = %f\r\n", aIn); + - bLED = LED_OFF; + + rLED = LED_OFF; Thread::wait(250); daplink.printf("Self Test Passed\r\n"); @@ -123,9 +87,9 @@ if (!button) { keyboard.mediaControl(KEY_MUTE); ledCnt++; - gLED = (ledCnt & 1); - bLED = (ledCnt & 2); - rLED = gLED ^ bLED; + gLED = ((ledCnt % 4) != 1); + bLED = ((ledCnt % 4) != 2); + rLED = ((ledCnt % 4) != 3); Thread::wait(500); } else { Thread::wait(50);