pico is recognized
Dependencies: max32625pico mbed SerialInterface USBDevice
main2.txt@9:42ab3b212395, 2020-01-31 (annotated)
- Committer:
- mjoun
- Date:
- Fri Jan 31 18:27:53 2020 +0000
- Revision:
- 9:42ab3b212395
- Parent:
- 7:8bc9fad71b8c
changed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjoun | 7:8bc9fad71b8c | 1 | #include "mbed.h" |
mjoun | 7:8bc9fad71b8c | 2 | #include "rtos.h" |
mjoun | 7:8bc9fad71b8c | 3 | #include "max32625pico.h" |
mjoun | 7:8bc9fad71b8c | 4 | #include "USBKeyboard.h" |
mjoun | 7:8bc9fad71b8c | 5 | |
mjoun | 7:8bc9fad71b8c | 6 | // Hardware serial port over DAPLink |
mjoun | 7:8bc9fad71b8c | 7 | Serial daplink(P2_1, P2_0); |
mjoun | 7:8bc9fad71b8c | 8 | |
mjoun | 7:8bc9fad71b8c | 9 | DigitalOut rLED(LED1, LED_OFF); |
mjoun | 7:8bc9fad71b8c | 10 | DigitalOut gLED(LED2, LED_OFF); |
mjoun | 7:8bc9fad71b8c | 11 | DigitalOut bLED(LED3, LED_OFF); |
mjoun | 7:8bc9fad71b8c | 12 | DigitalIn button(P2_7, PullUp); |
mjoun | 7:8bc9fad71b8c | 13 | AnalogIn dipIOH(AIN_4); |
mjoun | 7:8bc9fad71b8c | 14 | AnalogIn swdIOH(AIN_5); |
mjoun | 7:8bc9fad71b8c | 15 | AnalogIn vddbIn(AIN_6); |
mjoun | 7:8bc9fad71b8c | 16 | AnalogIn vdd18In(AIN_7); |
mjoun | 7:8bc9fad71b8c | 17 | AnalogIn vdd12In(AIN_8); |
mjoun | 7:8bc9fad71b8c | 18 | AnalogIn vrtcIn(AIN_9); |
mjoun | 7:8bc9fad71b8c | 19 | |
mjoun | 7:8bc9fad71b8c | 20 | USBKeyboard keyboard; |
mjoun | 7:8bc9fad71b8c | 21 | |
mjoun | 7:8bc9fad71b8c | 22 | MAX32625PICO pico(MAX32625PICO::IOH_DIP_IN, MAX32625PICO::VIO_IOH, MAX32625PICO::VIO_1V8); |
mjoun | 7:8bc9fad71b8c | 23 | |
mjoun | 7:8bc9fad71b8c | 24 | // Function to report failure |
mjoun | 7:8bc9fad71b8c | 25 | void testFailed() |
mjoun | 7:8bc9fad71b8c | 26 | { |
mjoun | 7:8bc9fad71b8c | 27 | daplink.printf("\r\n! Test Failed !\r\n"); |
mjoun | 7:8bc9fad71b8c | 28 | rLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 29 | gLED = LED_OFF; |
mjoun | 7:8bc9fad71b8c | 30 | bLED = LED_OFF; |
mjoun | 7:8bc9fad71b8c | 31 | while(1) { |
mjoun | 7:8bc9fad71b8c | 32 | Thread::wait(500); |
mjoun | 7:8bc9fad71b8c | 33 | gLED = !gLED; |
mjoun | 7:8bc9fad71b8c | 34 | } |
mjoun | 7:8bc9fad71b8c | 35 | } |
mjoun | 7:8bc9fad71b8c | 36 | |
mjoun | 7:8bc9fad71b8c | 37 | // main() runs in its own thread in the OS |
mjoun | 7:8bc9fad71b8c | 38 | // (note the calls to Thread::wait below for delays) |
mjoun | 7:8bc9fad71b8c | 39 | int main() |
mjoun | 7:8bc9fad71b8c | 40 | { |
mjoun | 7:8bc9fad71b8c | 41 | float aIn; |
mjoun | 7:8bc9fad71b8c | 42 | int ledCnt = 0; |
mjoun | 7:8bc9fad71b8c | 43 | |
mjoun | 7:8bc9fad71b8c | 44 | rLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 45 | gLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 46 | bLED = LED_OFF; |
mjoun | 7:8bc9fad71b8c | 47 | |
mjoun | 7:8bc9fad71b8c | 48 | daplink.printf("Checking Supplies\r\n"); |
mjoun | 7:8bc9fad71b8c | 49 | aIn = 2.4f * vdd12In; |
mjoun | 7:8bc9fad71b8c | 50 | daplink.printf("vdd12 = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 51 | if ((aIn < 1.0f) || (aIn > 1.4f)) { |
mjoun | 7:8bc9fad71b8c | 52 | testFailed(); |
mjoun | 7:8bc9fad71b8c | 53 | } |
mjoun | 7:8bc9fad71b8c | 54 | aIn = 2.4f * vdd18In; |
mjoun | 7:8bc9fad71b8c | 55 | daplink.printf("vdd18 = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 56 | if ((aIn < 1.6f) || (aIn > 2.0f)) { |
mjoun | 7:8bc9fad71b8c | 57 | testFailed(); |
mjoun | 7:8bc9fad71b8c | 58 | } |
mjoun | 7:8bc9fad71b8c | 59 | aIn = 4.8f * vddbIn; |
mjoun | 7:8bc9fad71b8c | 60 | daplink.printf("vddb = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 61 | if ((aIn < 3.0f) || (aIn > 3.6f)) { |
mjoun | 7:8bc9fad71b8c | 62 | testFailed(); |
mjoun | 7:8bc9fad71b8c | 63 | } |
mjoun | 7:8bc9fad71b8c | 64 | aIn = 2.4f * vrtcIn; |
mjoun | 7:8bc9fad71b8c | 65 | daplink.printf("vrtc = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 66 | if ((aIn < 1.6f) || (aIn > 2.0f)) { |
mjoun | 7:8bc9fad71b8c | 67 | testFailed(); |
mjoun | 7:8bc9fad71b8c | 68 | } |
mjoun | 7:8bc9fad71b8c | 69 | |
mjoun | 7:8bc9fad71b8c | 70 | aIn = 6.0f * dipIOH; |
mjoun | 7:8bc9fad71b8c | 71 | daplink.printf("dipIOH = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 72 | |
mjoun | 7:8bc9fad71b8c | 73 | aIn = 6.0f * swdIOH; |
mjoun | 7:8bc9fad71b8c | 74 | daplink.printf("swdIOH = %f\r\n", aIn); |
mjoun | 7:8bc9fad71b8c | 75 | |
mjoun | 7:8bc9fad71b8c | 76 | |
mjoun | 7:8bc9fad71b8c | 77 | |
mjoun | 7:8bc9fad71b8c | 78 | rLED = LED_OFF; |
mjoun | 7:8bc9fad71b8c | 79 | Thread::wait(250); |
mjoun | 7:8bc9fad71b8c | 80 | |
mjoun | 7:8bc9fad71b8c | 81 | daplink.printf("Self Test Passed\r\n"); |
mjoun | 7:8bc9fad71b8c | 82 | rLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 83 | gLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 84 | bLED = LED_ON; |
mjoun | 7:8bc9fad71b8c | 85 | |
mjoun | 7:8bc9fad71b8c | 86 | while (true) { |
mjoun | 7:8bc9fad71b8c | 87 | if (!button) { |
mjoun | 7:8bc9fad71b8c | 88 | keyboard.mediaControl(KEY_MUTE); |
mjoun | 7:8bc9fad71b8c | 89 | ledCnt++; |
mjoun | 7:8bc9fad71b8c | 90 | gLED = ((ledCnt % 4) != 1); |
mjoun | 7:8bc9fad71b8c | 91 | bLED = ((ledCnt % 4) != 2); |
mjoun | 7:8bc9fad71b8c | 92 | rLED = ((ledCnt % 4) != 3); |
mjoun | 7:8bc9fad71b8c | 93 | Thread::wait(500); |
mjoun | 7:8bc9fad71b8c | 94 | } else { |
mjoun | 7:8bc9fad71b8c | 95 | Thread::wait(50); |
mjoun | 7:8bc9fad71b8c | 96 | } |
mjoun | 7:8bc9fad71b8c | 97 | } |
mjoun | 7:8bc9fad71b8c | 98 | } |
mjoun | 7:8bc9fad71b8c | 99 |