![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
main.cpp@3:7ef908e84ae1, 2014-09-08 (annotated)
- Committer:
- embeddedartists
- Date:
- Mon Sep 08 11:34:53 2014 +0000
- Revision:
- 3:7ef908e84ae1
- Parent:
- 2:2f4b7535ceb3
Added audio test. Shortened RGB LED startup sequence and added message for user when uSD card not inserted to explain the long delay.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:0d5190d379d3 | 1 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 2 | * Includes |
embeddedartists | 0:0d5190d379d3 | 3 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 4 | #include "mbed.h" |
embeddedartists | 0:0d5190d379d3 | 5 | |
embeddedartists | 2:2f4b7535ceb3 | 6 | #include "TestRGBLed.h" |
embeddedartists | 2:2f4b7535ceb3 | 7 | #include "TestFileSystemMCI.h" |
embeddedartists | 2:2f4b7535ceb3 | 8 | #include "TestFileSystemSPI.h" |
embeddedartists | 2:2f4b7535ceb3 | 9 | #include "TestAcc.h" |
embeddedartists | 2:2f4b7535ceb3 | 10 | #include "TestTemperature.h" |
embeddedartists | 2:2f4b7535ceb3 | 11 | #include "TestTrimpot.h" |
embeddedartists | 2:2f4b7535ceb3 | 12 | #include "TestJoystick.h" |
embeddedartists | 2:2f4b7535ceb3 | 13 | #include "TestAudio.h" |
embeddedartists | 2:2f4b7535ceb3 | 14 | #include "TestShiftreg.h" |
embeddedartists | 2:2f4b7535ceb3 | 15 | #include "TestDisplay.h" |
embeddedartists | 0:0d5190d379d3 | 16 | |
embeddedartists | 0:0d5190d379d3 | 17 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 18 | * Typedefs and defines |
embeddedartists | 0:0d5190d379d3 | 19 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 20 | |
embeddedartists | 0:0d5190d379d3 | 21 | |
embeddedartists | 0:0d5190d379d3 | 22 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 23 | * Local variables |
embeddedartists | 0:0d5190d379d3 | 24 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 25 | |
embeddedartists | 0:0d5190d379d3 | 26 | DigitalOut myled(LED1); |
embeddedartists | 0:0d5190d379d3 | 27 | |
embeddedartists | 0:0d5190d379d3 | 28 | /****************************************************************************** |
embeddedartists | 0:0d5190d379d3 | 29 | * Local functions |
embeddedartists | 0:0d5190d379d3 | 30 | *****************************************************************************/ |
embeddedartists | 0:0d5190d379d3 | 31 | |
embeddedartists | 1:47680ec5d783 | 32 | |
embeddedartists | 1:47680ec5d783 | 33 | static void setupSerial(int baudrate) |
embeddedartists | 1:47680ec5d783 | 34 | { |
embeddedartists | 1:47680ec5d783 | 35 | // This works because both the default serial (used by printf) and the s instance |
embeddedartists | 1:47680ec5d783 | 36 | // (used by s.printf) would use the same underlying UART code so setting the baudrate |
embeddedartists | 1:47680ec5d783 | 37 | // in one affects the other. |
embeddedartists | 1:47680ec5d783 | 38 | Serial s(USBTX, USBRX); |
embeddedartists | 1:47680ec5d783 | 39 | s.baud(baudrate); |
embeddedartists | 1:47680ec5d783 | 40 | } |
embeddedartists | 1:47680ec5d783 | 41 | |
embeddedartists | 0:0d5190d379d3 | 42 | int main() { |
embeddedartists | 1:47680ec5d783 | 43 | setupSerial(115200); |
embeddedartists | 1:47680ec5d783 | 44 | printf("\n" |
embeddedartists | 1:47680ec5d783 | 45 | "---\n" |
embeddedartists | 1:47680ec5d783 | 46 | "Production Test Program: LPC4088 Experiment Base Board\n" |
embeddedartists | 1:47680ec5d783 | 47 | "Build Date: " __DATE__ " at " __TIME__ "\n" |
embeddedartists | 1:47680ec5d783 | 48 | "\n"); |
embeddedartists | 0:0d5190d379d3 | 49 | |
embeddedartists | 2:2f4b7535ceb3 | 50 | // run all tests |
embeddedartists | 2:2f4b7535ceb3 | 51 | int failed = 0; |
embeddedartists | 0:0d5190d379d3 | 52 | |
embeddedartists | 2:2f4b7535ceb3 | 53 | TestRGBLed rgb; |
embeddedartists | 2:2f4b7535ceb3 | 54 | TestFileSystemMCI mcifs; |
embeddedartists | 2:2f4b7535ceb3 | 55 | TestAcc acc; |
embeddedartists | 2:2f4b7535ceb3 | 56 | // TestFileSystemSPI spifs; |
embeddedartists | 2:2f4b7535ceb3 | 57 | TestTemperature temp; |
embeddedartists | 2:2f4b7535ceb3 | 58 | TestTrimpot trim; |
embeddedartists | 2:2f4b7535ceb3 | 59 | TestJoystick joy; |
embeddedartists | 2:2f4b7535ceb3 | 60 | TestShiftreg shift; |
embeddedartists | 2:2f4b7535ceb3 | 61 | TestDisplay display; |
embeddedartists | 3:7ef908e84ae1 | 62 | TestAudio audio; |
embeddedartists | 3:7ef908e84ae1 | 63 | |
embeddedartists | 3:7ef908e84ae1 | 64 | /* NOTE: Audio must be initialized AFTER the display as they both reference the same pins |
embeddedartists | 3:7ef908e84ae1 | 65 | (P0_4, P0_5, P0_6, P0_7, P0_8, P0_9). However the display only uses those pins |
embeddedartists | 3:7ef908e84ae1 | 66 | for 24-bit color depth and we only use 16-bit in this demo. */ |
embeddedartists | 2:2f4b7535ceb3 | 67 | |
embeddedartists | 2:2f4b7535ceb3 | 68 | //startup flash behaviour |
embeddedartists | 2:2f4b7535ceb3 | 69 | rgb.showStartupPattern(); |
embeddedartists | 2:2f4b7535ceb3 | 70 | |
embeddedartists | 2:2f4b7535ceb3 | 71 | if (!mcifs.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 72 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 73 | } |
embeddedartists | 2:2f4b7535ceb3 | 74 | |
embeddedartists | 2:2f4b7535ceb3 | 75 | // if (!spifs.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 76 | // failed++; |
embeddedartists | 2:2f4b7535ceb3 | 77 | // } |
embeddedartists | 0:0d5190d379d3 | 78 | |
embeddedartists | 2:2f4b7535ceb3 | 79 | if (!acc.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 80 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 81 | } |
embeddedartists | 2:2f4b7535ceb3 | 82 | |
embeddedartists | 2:2f4b7535ceb3 | 83 | if (!temp.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 84 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 85 | } |
embeddedartists | 2:2f4b7535ceb3 | 86 | |
embeddedartists | 2:2f4b7535ceb3 | 87 | if (!trim.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 88 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 89 | } |
embeddedartists | 0:0d5190d379d3 | 90 | |
embeddedartists | 2:2f4b7535ceb3 | 91 | if (!joy.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 92 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 93 | } |
embeddedartists | 2:2f4b7535ceb3 | 94 | |
embeddedartists | 2:2f4b7535ceb3 | 95 | if (!rgb.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 96 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 97 | } |
embeddedartists | 2:2f4b7535ceb3 | 98 | |
embeddedartists | 2:2f4b7535ceb3 | 99 | if (!audio.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 100 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 101 | } |
embeddedartists | 1:47680ec5d783 | 102 | |
embeddedartists | 2:2f4b7535ceb3 | 103 | if (!display.runTest()) { |
embeddedartists | 2:2f4b7535ceb3 | 104 | failed++; |
embeddedartists | 2:2f4b7535ceb3 | 105 | } |
embeddedartists | 2:2f4b7535ceb3 | 106 | |
embeddedartists | 2:2f4b7535ceb3 | 107 | if (failed == 0) { |
embeddedartists | 2:2f4b7535ceb3 | 108 | printf("\n\n---\nTest PASSED\n\n"); |
embeddedartists | 2:2f4b7535ceb3 | 109 | printf("NOTE: The display as well as the shift register LEDs\n" |
embeddedartists | 2:2f4b7535ceb3 | 110 | " must be manually checked as well\n\n"); |
embeddedartists | 2:2f4b7535ceb3 | 111 | } else { |
embeddedartists | 2:2f4b7535ceb3 | 112 | printf("\n\n---\nTest FAILED (%d failed parts)\n\n", failed); |
embeddedartists | 2:2f4b7535ceb3 | 113 | } |
embeddedartists | 2:2f4b7535ceb3 | 114 | rgb.showStatus(failed == 0); |
embeddedartists | 2:2f4b7535ceb3 | 115 | display.showStatus(failed == 0); |
embeddedartists | 0:0d5190d379d3 | 116 | |
embeddedartists | 0:0d5190d379d3 | 117 | while(1) { |
embeddedartists | 2:2f4b7535ceb3 | 118 | shift.runTest(); |
embeddedartists | 0:0d5190d379d3 | 119 | myled = 1; |
embeddedartists | 0:0d5190d379d3 | 120 | wait(0.2); |
embeddedartists | 0:0d5190d379d3 | 121 | myled = 0; |
embeddedartists | 0:0d5190d379d3 | 122 | wait(0.2); |
embeddedartists | 0:0d5190d379d3 | 123 | } |
embeddedartists | 0:0d5190d379d3 | 124 | } |