Demo for MAX32625PICO board library

Dependencies:   USBDevice max32625pico

Fork of PICO_self_test by Greg Steiert

Committer:
switches
Date:
Tue Dec 13 22:00:12 2016 +0000
Revision:
5:39fe91b6d3f0
Parent:
4:1c6819a42db0
Child:
6:fa0134a8ac32
Updated pegasus_dev and max32630fthr libraries.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:60a522ae2e35 1 #include "mbed.h"
switches 1:464c8b3634dc 2 #include "max32630fthr.h"
switches 1:464c8b3634dc 3 #include "USBMSD_SD.h"
switches 0:60a522ae2e35 4
switches 5:39fe91b6d3f0 5 MAX32630FTHR pegasus;
switches 3:7264c8044625 6
switches 4:1c6819a42db0 7 // Hardware serial port over DAPLink
switches 4:1c6819a42db0 8 Serial daplink(P2_1, P2_0);
switches 4:1c6819a42db0 9
switches 4:1c6819a42db0 10 DigitalOut rLED(LED1, LED_ON);
switches 4:1c6819a42db0 11 DigitalOut gLED(LED2, LED_OFF);
switches 4:1c6819a42db0 12 DigitalOut bLED(LED3, LED_OFF);
switches 4:1c6819a42db0 13 AnalogIn monIn(AIN_0);
switches 4:1c6819a42db0 14 AnalogIn vddbIn(AIN_6);
switches 4:1c6819a42db0 15 AnalogIn vdd18In(AIN_7);
switches 4:1c6819a42db0 16 AnalogIn vdd12In(AIN_8);
switches 4:1c6819a42db0 17 AnalogIn vrtcIn(AIN_9);
switches 4:1c6819a42db0 18
switches 4:1c6819a42db0 19 // Function to report failure
switches 4:1c6819a42db0 20 void testFailed()
switches 4:1c6819a42db0 21 {
switches 4:1c6819a42db0 22 daplink.printf("\r\n! Test Failed !\r\n");
switches 4:1c6819a42db0 23 rLED = LED_ON;
switches 4:1c6819a42db0 24 gLED = LED_OFF;
switches 4:1c6819a42db0 25 bLED = LED_OFF;
switches 4:1c6819a42db0 26 while(1) {
switches 4:1c6819a42db0 27 Thread::wait(500);
switches 4:1c6819a42db0 28 gLED = !gLED;
switches 4:1c6819a42db0 29 }
switches 4:1c6819a42db0 30 }
switches 4:1c6819a42db0 31
switches 4:1c6819a42db0 32 // Function to read monitor port
switches 4:1c6819a42db0 33 float readMon(MAX14690::monCfg_t monCfg){
switches 4:1c6819a42db0 34 pegasus.max14690.monSet(monCfg, MAX14690::MON_DIV4);
switches 4:1c6819a42db0 35 Thread::wait(5);
switches 4:1c6819a42db0 36 return (4.8f * monIn);
switches 4:1c6819a42db0 37 }
switches 0:60a522ae2e35 38
switches 0:60a522ae2e35 39 // main() runs in its own thread in the OS
switches 0:60a522ae2e35 40 // (note the calls to Thread::wait below for delays)
switches 0:60a522ae2e35 41 int main()
switches 0:60a522ae2e35 42 {
switches 4:1c6819a42db0 43 float aIn;
switches 4:1c6819a42db0 44 daplink.printf("Initializing MAX32630FTHR\r\n");
switches 5:39fe91b6d3f0 45 pegasus.init(MAX32630FTHR::VIO_3V3);
switches 4:1c6819a42db0 46 daplink.printf("Checking Supplies\r\n");
switches 4:1c6819a42db0 47 aIn = 2.4f * vdd12In;
switches 4:1c6819a42db0 48 daplink.printf("vdd12 = %f\r\n", aIn);
switches 4:1c6819a42db0 49 if ((aIn < 1.0f) || (aIn > 1.4f)) { testFailed(); }
switches 4:1c6819a42db0 50 aIn = 2.4f * vdd18In;
switches 4:1c6819a42db0 51 daplink.printf("vdd18 = %f\r\n", aIn);
switches 4:1c6819a42db0 52 if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
switches 4:1c6819a42db0 53 aIn = 4.8f * vddbIn;
switches 4:1c6819a42db0 54 daplink.printf("vddb = %f\r\n", aIn);
switches 4:1c6819a42db0 55 if ((aIn < 3.0f) || (aIn > 3.6f)) { testFailed(); }
switches 4:1c6819a42db0 56 aIn = 2.4f * vrtcIn;
switches 4:1c6819a42db0 57 daplink.printf("vrtc = %f\r\n", aIn);
switches 4:1c6819a42db0 58 if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
switches 4:1c6819a42db0 59 aIn = readMon(MAX14690::MON_SYS);
switches 4:1c6819a42db0 60 daplink.printf("sys = %f\r\n", aIn);
switches 4:1c6819a42db0 61 if ((aIn < 3.0f) || (aIn > 5.0f)) { testFailed(); }
switches 4:1c6819a42db0 62 aIn = readMon(MAX14690::MON_BUCK1);
switches 4:1c6819a42db0 63 daplink.printf("buck1 = %f\r\n", aIn);
switches 4:1c6819a42db0 64 if ((aIn < 1.0f) || (aIn > 1.4f)) { testFailed(); }
switches 4:1c6819a42db0 65 aIn = readMon(MAX14690::MON_BUCK2);
switches 4:1c6819a42db0 66 daplink.printf("buck2 = %f\r\n", aIn);
switches 4:1c6819a42db0 67 if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
switches 4:1c6819a42db0 68 aIn = readMon(MAX14690::MON_LDO1);
switches 4:1c6819a42db0 69 daplink.printf("ldo1 = %f\r\n", aIn);
switches 4:1c6819a42db0 70 if ((aIn < 1.6f) || (aIn > 2.0f)) { testFailed(); }
switches 4:1c6819a42db0 71 aIn = readMon(MAX14690::MON_LDO2);
switches 4:1c6819a42db0 72 daplink.printf("ldo2 = %f\r\n", aIn);
switches 4:1c6819a42db0 73 if ((aIn < 3.0f) || (aIn > 3.6f)) { testFailed(); }
switches 4:1c6819a42db0 74 aIn = readMon(MAX14690::MON_LDO3);
switches 4:1c6819a42db0 75 daplink.printf("ldo3 = %f\r\n", aIn);
switches 4:1c6819a42db0 76 aIn = readMon(MAX14690::MON_LDO3);
switches 1:464c8b3634dc 77
switches 1:464c8b3634dc 78 gLED = LED_ON;
switches 1:464c8b3634dc 79
switches 1:464c8b3634dc 80 USBMSD_SD sd(P0_5, P0_6, P0_4, P0_7); // mosi, miso, sclk, cs
switches 1:464c8b3634dc 81 rLED = LED_OFF;
switches 0:60a522ae2e35 82
switches 4:1c6819a42db0 83 bLED = LED_ON;
switches 4:1c6819a42db0 84 daplink.printf("Self Test Passed\r\n");
switches 4:1c6819a42db0 85
switches 0:60a522ae2e35 86 while (true) {
switches 0:60a522ae2e35 87 Thread::wait(500);
switches 4:1c6819a42db0 88 rLED = LED_OFF;
switches 4:1c6819a42db0 89 gLED = LED_ON;
switches 4:1c6819a42db0 90 bLED = LED_OFF;
switches 4:1c6819a42db0 91 Thread::wait(500);
switches 4:1c6819a42db0 92 rLED = LED_ON;
switches 4:1c6819a42db0 93 gLED = LED_ON;
switches 4:1c6819a42db0 94 bLED = LED_ON;
switches 0:60a522ae2e35 95 }
switches 0:60a522ae2e35 96 }
switches 0:60a522ae2e35 97