MAX32625PICO Self Test

Dependencies:   USBDevice maxim-dev mbed-rtos

Fork of FTHR_self_test by Greg Steiert

Committer:
switches
Date:
Fri Mar 24 16:48:24 2017 +0000
Revision:
9:674b1077b3ec
Parent:
8:26dc73d09bd9
Updated with development library that fixes button.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:60a522ae2e35 1 #include "mbed.h"
switches 8:26dc73d09bd9 2 #include "rtos.h"
switches 7:62efbc5411c8 3 #include "USBKeyboard.h"
switches 0:60a522ae2e35 4
switches 4:1c6819a42db0 5 // Hardware serial port over DAPLink
switches 4:1c6819a42db0 6 Serial daplink(P2_1, P2_0);
switches 4:1c6819a42db0 7
switches 4:1c6819a42db0 8 DigitalOut rLED(LED1, LED_ON);
switches 4:1c6819a42db0 9 DigitalOut gLED(LED2, LED_OFF);
switches 4:1c6819a42db0 10 DigitalOut bLED(LED3, LED_OFF);
switches 9:674b1077b3ec 11 DigitalIn button(P2_7, PullUp);
switches 8:26dc73d09bd9 12 DigitalOut en3V3(P3_6, 0);
switches 8:26dc73d09bd9 13 DigitalOut enIOH(P2_2, 0);
switches 8:26dc73d09bd9 14 DigitalOut selSWD(P2_3, 0);
switches 8:26dc73d09bd9 15 AnalogIn dipIOH(AIN_4);
switches 8:26dc73d09bd9 16 AnalogIn swdIOH(AIN_5);
switches 4:1c6819a42db0 17 AnalogIn vddbIn(AIN_6);
switches 4:1c6819a42db0 18 AnalogIn vdd18In(AIN_7);
switches 4:1c6819a42db0 19 AnalogIn vdd12In(AIN_8);
switches 4:1c6819a42db0 20 AnalogIn vrtcIn(AIN_9);
switches 4:1c6819a42db0 21
switches 7:62efbc5411c8 22 USBKeyboard keyboard;
switches 7:62efbc5411c8 23
switches 4:1c6819a42db0 24 // Function to report failure
switches 4:1c6819a42db0 25 void testFailed()
switches 4:1c6819a42db0 26 {
switches 4:1c6819a42db0 27 daplink.printf("\r\n! Test Failed !\r\n");
switches 8:26dc73d09bd9 28 // rLED = LED_ON;
switches 8:26dc73d09bd9 29 // gLED = LED_OFF;
switches 8:26dc73d09bd9 30 // bLED = LED_OFF;
switches 4:1c6819a42db0 31 while(1) {
switches 4:1c6819a42db0 32 Thread::wait(500);
switches 8:26dc73d09bd9 33 rLED = !rLED;
switches 7:62efbc5411c8 34 }
switches 4:1c6819a42db0 35 }
switches 4:1c6819a42db0 36
switches 0:60a522ae2e35 37 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 38 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 39 int main()
switches 0:60a522ae2e35 40 {
switches 4:1c6819a42db0 41 float aIn;
switches 7:62efbc5411c8 42 int ledCnt = 0;
switches 8:26dc73d09bd9 43
switches 4:1c6819a42db0 44 daplink.printf("Checking Supplies\r\n");
switches 4:1c6819a42db0 45 aIn = 2.4f * vdd12In;
switches 4:1c6819a42db0 46 daplink.printf("vdd12 = %f\r\n", aIn);
switches 7:62efbc5411c8 47 if ((aIn < 1.0f) || (aIn > 1.4f)) {
switches 7:62efbc5411c8 48 testFailed();
switches 7:62efbc5411c8 49 }
switches 4:1c6819a42db0 50 aIn = 2.4f * vdd18In;
switches 4:1c6819a42db0 51 daplink.printf("vdd18 = %f\r\n", aIn);
switches 7:62efbc5411c8 52 if ((aIn < 1.6f) || (aIn > 2.0f)) {
switches 7:62efbc5411c8 53 testFailed();
switches 7:62efbc5411c8 54 }
switches 4:1c6819a42db0 55 aIn = 4.8f * vddbIn;
switches 4:1c6819a42db0 56 daplink.printf("vddb = %f\r\n", aIn);
switches 7:62efbc5411c8 57 if ((aIn < 3.0f) || (aIn > 3.6f)) {
switches 7:62efbc5411c8 58 testFailed();
switches 7:62efbc5411c8 59 }
switches 4:1c6819a42db0 60 aIn = 2.4f * vrtcIn;
switches 4:1c6819a42db0 61 daplink.printf("vrtc = %f\r\n", aIn);
switches 7:62efbc5411c8 62 if ((aIn < 1.6f) || (aIn > 2.0f)) {
switches 7:62efbc5411c8 63 testFailed();
switches 7:62efbc5411c8 64 }
switches 8:26dc73d09bd9 65
switches 8:26dc73d09bd9 66 en3V3 = 1;
switches 8:26dc73d09bd9 67 bLED = LED_ON;
switches 8:26dc73d09bd9 68 Thread::wait(100);
switches 8:26dc73d09bd9 69
switches 8:26dc73d09bd9 70 daplink.printf("Checking Switches\r\n");
switches 8:26dc73d09bd9 71 aIn = 6.0f * dipIOH;
switches 8:26dc73d09bd9 72 Thread::wait(100);
switches 8:26dc73d09bd9 73 aIn = 6.0f * dipIOH;
switches 8:26dc73d09bd9 74 daplink.printf("dipIOH(open) = %f\r\n", aIn);
switches 8:26dc73d09bd9 75 if (aIn > 0.1f) {
switches 7:62efbc5411c8 76 testFailed();
switches 7:62efbc5411c8 77 }
switches 8:26dc73d09bd9 78 aIn = 6.0f * swdIOH;
switches 8:26dc73d09bd9 79 Thread::wait(100);
switches 8:26dc73d09bd9 80 aIn = 6.0f * swdIOH;
switches 8:26dc73d09bd9 81 daplink.printf("swdIOH(open) = %f\r\n", aIn);
switches 8:26dc73d09bd9 82 if (aIn > 0.1f) {
switches 7:62efbc5411c8 83 testFailed();
switches 7:62efbc5411c8 84 }
switches 8:26dc73d09bd9 85
switches 8:26dc73d09bd9 86 enIOH = 1;
switches 8:26dc73d09bd9 87 rLED = LED_OFF;
switches 8:26dc73d09bd9 88 Thread::wait(100);
switches 8:26dc73d09bd9 89
switches 8:26dc73d09bd9 90 aIn = 6.0f * dipIOH;
switches 8:26dc73d09bd9 91 Thread::wait(100);
switches 8:26dc73d09bd9 92 aIn = 6.0f * dipIOH;
switches 8:26dc73d09bd9 93 daplink.printf("dipIOH(closed) = %f\r\n", aIn);
switches 8:26dc73d09bd9 94 // aIn = 6.0f * swdIOH;
switches 8:26dc73d09bd9 95 // daplink.printf("swdIOH(closed) = %f\r\n", aIn);
switches 8:26dc73d09bd9 96 if ((aIn < 3.0f) || (aIn > 3.6f)) {
switches 8:26dc73d09bd9 97 // testFailed();
switches 7:62efbc5411c8 98 }
switches 8:26dc73d09bd9 99
switches 8:26dc73d09bd9 100 selSWD = 1;
switches 8:26dc73d09bd9 101 gLED = LED_ON;
switches 8:26dc73d09bd9 102 Thread::wait(100);
switches 8:26dc73d09bd9 103
switches 8:26dc73d09bd9 104 aIn = 6.0f * swdIOH;
switches 8:26dc73d09bd9 105 Thread::wait(100);
switches 8:26dc73d09bd9 106 aIn = 6.0f * swdIOH;
switches 8:26dc73d09bd9 107 daplink.printf("swdIOH(closed) = %f\r\n", aIn);
switches 8:26dc73d09bd9 108 // aIn = 6.0f * dipIOH;
switches 8:26dc73d09bd9 109 // daplink.printf("dipIOH(closed) = %f\r\n", aIn);
switches 7:62efbc5411c8 110 if ((aIn < 3.0f) || (aIn > 3.6f)) {
switches 7:62efbc5411c8 111 testFailed();
switches 7:62efbc5411c8 112 }
switches 1:464c8b3634dc 113
switches 8:26dc73d09bd9 114 bLED = LED_OFF;
switches 8:26dc73d09bd9 115 Thread::wait(250);
switches 7:62efbc5411c8 116
switches 4:1c6819a42db0 117 daplink.printf("Self Test Passed\r\n");
switches 7:62efbc5411c8 118 rLED = LED_ON;
switches 7:62efbc5411c8 119 gLED = LED_ON;
switches 7:62efbc5411c8 120 bLED = LED_ON;
switches 7:62efbc5411c8 121
switches 0:60a522ae2e35 122 while (true) {
switches 7:62efbc5411c8 123 if (!button) {
switches 7:62efbc5411c8 124 keyboard.mediaControl(KEY_MUTE);
switches 7:62efbc5411c8 125 ledCnt++;
switches 8:26dc73d09bd9 126 gLED = (ledCnt & 1);
switches 8:26dc73d09bd9 127 bLED = (ledCnt & 2);
switches 8:26dc73d09bd9 128 rLED = gLED ^ bLED;
switches 7:62efbc5411c8 129 Thread::wait(500);
switches 7:62efbc5411c8 130 } else {
switches 7:62efbc5411c8 131 Thread::wait(50);
switches 7:62efbc5411c8 132 }
switches 0:60a522ae2e35 133 }
switches 0:60a522ae2e35 134 }
switches 0:60a522ae2e35 135