Demo for MAX32625PICO board library
Dependencies: USBDevice max32625pico
Fork of PICO_self_test by
main.cpp@13:6c2d1cdcde12, 2018-08-22 (annotated)
- Committer:
- switches
- Date:
- Wed Aug 22 17:40:45 2018 +0000
- Revision:
- 13:6c2d1cdcde12
- Parent:
- 10:227698c63531
Switching to official mbed library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:60a522ae2e35 | 1 | #include "mbed.h" |
switches | 8:26dc73d09bd9 | 2 | #include "rtos.h" |
switches | 10:227698c63531 | 3 | #include "max32625pico.h" |
switches | 7:62efbc5411c8 | 4 | #include "USBKeyboard.h" |
switches | 0:60a522ae2e35 | 5 | |
switches | 4:1c6819a42db0 | 6 | // Hardware serial port over DAPLink |
switches | 4:1c6819a42db0 | 7 | Serial daplink(P2_1, P2_0); |
switches | 4:1c6819a42db0 | 8 | |
switches | 10:227698c63531 | 9 | DigitalOut rLED(LED1, LED_OFF); |
switches | 4:1c6819a42db0 | 10 | DigitalOut gLED(LED2, LED_OFF); |
switches | 4:1c6819a42db0 | 11 | DigitalOut bLED(LED3, LED_OFF); |
switches | 9:674b1077b3ec | 12 | DigitalIn button(P2_7, PullUp); |
switches | 8:26dc73d09bd9 | 13 | AnalogIn dipIOH(AIN_4); |
switches | 8:26dc73d09bd9 | 14 | AnalogIn swdIOH(AIN_5); |
switches | 4:1c6819a42db0 | 15 | AnalogIn vddbIn(AIN_6); |
switches | 4:1c6819a42db0 | 16 | AnalogIn vdd18In(AIN_7); |
switches | 4:1c6819a42db0 | 17 | AnalogIn vdd12In(AIN_8); |
switches | 4:1c6819a42db0 | 18 | AnalogIn vrtcIn(AIN_9); |
switches | 4:1c6819a42db0 | 19 | |
switches | 7:62efbc5411c8 | 20 | USBKeyboard keyboard; |
switches | 7:62efbc5411c8 | 21 | |
switches | 10:227698c63531 | 22 | MAX32625PICO pico(MAX32625PICO::IOH_DIP_IN, MAX32625PICO::VIO_IOH, MAX32625PICO::VIO_1V8); |
switches | 10:227698c63531 | 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 | 10:227698c63531 | 28 | rLED = LED_ON; |
switches | 10:227698c63531 | 29 | gLED = LED_OFF; |
switches | 10:227698c63531 | 30 | bLED = LED_OFF; |
switches | 4:1c6819a42db0 | 31 | while(1) { |
switches | 4:1c6819a42db0 | 32 | Thread::wait(500); |
switches | 10:227698c63531 | 33 | gLED = !gLED; |
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 | 10:227698c63531 | 44 | rLED = LED_ON; |
switches | 10:227698c63531 | 45 | gLED = LED_ON; |
switches | 10:227698c63531 | 46 | bLED = LED_OFF; |
switches | 10:227698c63531 | 47 | |
switches | 4:1c6819a42db0 | 48 | daplink.printf("Checking Supplies\r\n"); |
switches | 4:1c6819a42db0 | 49 | aIn = 2.4f * vdd12In; |
switches | 4:1c6819a42db0 | 50 | daplink.printf("vdd12 = %f\r\n", aIn); |
switches | 7:62efbc5411c8 | 51 | if ((aIn < 1.0f) || (aIn > 1.4f)) { |
switches | 7:62efbc5411c8 | 52 | testFailed(); |
switches | 7:62efbc5411c8 | 53 | } |
switches | 4:1c6819a42db0 | 54 | aIn = 2.4f * vdd18In; |
switches | 4:1c6819a42db0 | 55 | daplink.printf("vdd18 = %f\r\n", aIn); |
switches | 7:62efbc5411c8 | 56 | if ((aIn < 1.6f) || (aIn > 2.0f)) { |
switches | 7:62efbc5411c8 | 57 | testFailed(); |
switches | 7:62efbc5411c8 | 58 | } |
switches | 4:1c6819a42db0 | 59 | aIn = 4.8f * vddbIn; |
switches | 4:1c6819a42db0 | 60 | daplink.printf("vddb = %f\r\n", aIn); |
switches | 7:62efbc5411c8 | 61 | if ((aIn < 3.0f) || (aIn > 3.6f)) { |
switches | 7:62efbc5411c8 | 62 | testFailed(); |
switches | 7:62efbc5411c8 | 63 | } |
switches | 4:1c6819a42db0 | 64 | aIn = 2.4f * vrtcIn; |
switches | 4:1c6819a42db0 | 65 | daplink.printf("vrtc = %f\r\n", aIn); |
switches | 7:62efbc5411c8 | 66 | if ((aIn < 1.6f) || (aIn > 2.0f)) { |
switches | 7:62efbc5411c8 | 67 | testFailed(); |
switches | 7:62efbc5411c8 | 68 | } |
switches | 8:26dc73d09bd9 | 69 | |
switches | 8:26dc73d09bd9 | 70 | aIn = 6.0f * dipIOH; |
switches | 10:227698c63531 | 71 | daplink.printf("dipIOH = %f\r\n", aIn); |
switches | 8:26dc73d09bd9 | 72 | |
switches | 8:26dc73d09bd9 | 73 | aIn = 6.0f * swdIOH; |
switches | 10:227698c63531 | 74 | daplink.printf("swdIOH = %f\r\n", aIn); |
switches | 10:227698c63531 | 75 | |
switches | 1:464c8b3634dc | 76 | |
switches | 10:227698c63531 | 77 | |
switches | 10:227698c63531 | 78 | rLED = LED_OFF; |
switches | 8:26dc73d09bd9 | 79 | Thread::wait(250); |
switches | 7:62efbc5411c8 | 80 | |
switches | 4:1c6819a42db0 | 81 | daplink.printf("Self Test Passed\r\n"); |
switches | 7:62efbc5411c8 | 82 | rLED = LED_ON; |
switches | 7:62efbc5411c8 | 83 | gLED = LED_ON; |
switches | 7:62efbc5411c8 | 84 | bLED = LED_ON; |
switches | 7:62efbc5411c8 | 85 | |
switches | 0:60a522ae2e35 | 86 | while (true) { |
switches | 7:62efbc5411c8 | 87 | if (!button) { |
switches | 7:62efbc5411c8 | 88 | keyboard.mediaControl(KEY_MUTE); |
switches | 7:62efbc5411c8 | 89 | ledCnt++; |
switches | 10:227698c63531 | 90 | gLED = ((ledCnt % 4) != 1); |
switches | 10:227698c63531 | 91 | bLED = ((ledCnt % 4) != 2); |
switches | 10:227698c63531 | 92 | rLED = ((ledCnt % 4) != 3); |
switches | 7:62efbc5411c8 | 93 | Thread::wait(500); |
switches | 7:62efbc5411c8 | 94 | } else { |
switches | 7:62efbc5411c8 | 95 | Thread::wait(50); |
switches | 7:62efbc5411c8 | 96 | } |
switches | 0:60a522ae2e35 | 97 | } |
switches | 0:60a522ae2e35 | 98 | } |
switches | 0:60a522ae2e35 | 99 |