Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
TestRGBLed.cpp@7:48375cb50f3a, 2014-09-25 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Sep 25 07:17:44 2014 +0000
- Revision:
- 7:48375cb50f3a
- Parent:
- 3:7ef908e84ae1
Fixed audio test volume issues and issues with the touch controller.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 2:2f4b7535ceb3 | 1 | /* |
embeddedartists | 2:2f4b7535ceb3 | 2 | * Copyright 2013 Embedded Artists AB |
embeddedartists | 2:2f4b7535ceb3 | 3 | * |
embeddedartists | 2:2f4b7535ceb3 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
embeddedartists | 2:2f4b7535ceb3 | 5 | * you may not use this file except in compliance with the License. |
embeddedartists | 2:2f4b7535ceb3 | 6 | * You may obtain a copy of the License at |
embeddedartists | 2:2f4b7535ceb3 | 7 | * |
embeddedartists | 2:2f4b7535ceb3 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
embeddedartists | 2:2f4b7535ceb3 | 9 | * |
embeddedartists | 2:2f4b7535ceb3 | 10 | * Unless required by applicable law or agreed to in writing, software |
embeddedartists | 2:2f4b7535ceb3 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
embeddedartists | 2:2f4b7535ceb3 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
embeddedartists | 2:2f4b7535ceb3 | 13 | * See the License for the specific language governing permissions and |
embeddedartists | 2:2f4b7535ceb3 | 14 | * limitations under the License. |
embeddedartists | 2:2f4b7535ceb3 | 15 | */ |
embeddedartists | 2:2f4b7535ceb3 | 16 | |
embeddedartists | 2:2f4b7535ceb3 | 17 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 18 | * Includes |
embeddedartists | 2:2f4b7535ceb3 | 19 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 20 | |
embeddedartists | 2:2f4b7535ceb3 | 21 | #include "mbed.h" |
embeddedartists | 2:2f4b7535ceb3 | 22 | #include "TestRGBLed.h" |
embeddedartists | 2:2f4b7535ceb3 | 23 | |
embeddedartists | 2:2f4b7535ceb3 | 24 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 25 | * Defines and typedefs |
embeddedartists | 2:2f4b7535ceb3 | 26 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 27 | |
embeddedartists | 2:2f4b7535ceb3 | 28 | #define LED_ON 0 |
embeddedartists | 2:2f4b7535ceb3 | 29 | #define LED_OFF 1 |
embeddedartists | 2:2f4b7535ceb3 | 30 | |
embeddedartists | 2:2f4b7535ceb3 | 31 | #define BUTTON_PRESSED 0 |
embeddedartists | 2:2f4b7535ceb3 | 32 | #define BUTTON_RELEASED 1 |
embeddedartists | 2:2f4b7535ceb3 | 33 | |
embeddedartists | 2:2f4b7535ceb3 | 34 | /****************************************************************************** |
embeddedartists | 2:2f4b7535ceb3 | 35 | * Public Functions |
embeddedartists | 2:2f4b7535ceb3 | 36 | *****************************************************************************/ |
embeddedartists | 2:2f4b7535ceb3 | 37 | |
embeddedartists | 2:2f4b7535ceb3 | 38 | TestRGBLed::TestRGBLed(PinName red, PinName green, PinName blue, PinName button) : |
embeddedartists | 2:2f4b7535ceb3 | 39 | _redPin(red), _greenPin(green), _bluePin(blue), _button(button) { |
embeddedartists | 2:2f4b7535ceb3 | 40 | |
embeddedartists | 2:2f4b7535ceb3 | 41 | _button.mode(PullUp); |
embeddedartists | 2:2f4b7535ceb3 | 42 | } |
embeddedartists | 2:2f4b7535ceb3 | 43 | |
embeddedartists | 2:2f4b7535ceb3 | 44 | void TestRGBLed::showStartupPattern() { |
embeddedartists | 2:2f4b7535ceb3 | 45 | // Have to create the DigitalOut instances here (as opposed to |
embeddedartists | 2:2f4b7535ceb3 | 46 | // create them in the constructor) as some of the pins are shared |
embeddedartists | 2:2f4b7535ceb3 | 47 | // with other functionality on the LPC4088 Experiment Base Board |
embeddedartists | 2:2f4b7535ceb3 | 48 | DigitalOut ledRed(_redPin); |
embeddedartists | 2:2f4b7535ceb3 | 49 | DigitalOut ledGreen(_greenPin); |
embeddedartists | 2:2f4b7535ceb3 | 50 | DigitalOut ledBlue(_bluePin); |
embeddedartists | 2:2f4b7535ceb3 | 51 | |
embeddedartists | 2:2f4b7535ceb3 | 52 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 53 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 54 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 55 | |
embeddedartists | 3:7ef908e84ae1 | 56 | #if 1 |
embeddedartists | 3:7ef908e84ae1 | 57 | for (int i = 0; i < 2; i++) { |
embeddedartists | 3:7ef908e84ae1 | 58 | ledRed = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 59 | wait(0.1); |
embeddedartists | 3:7ef908e84ae1 | 60 | ledRed = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 61 | ledGreen = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 62 | wait(0.1); |
embeddedartists | 3:7ef908e84ae1 | 63 | ledGreen = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 64 | ledBlue = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 65 | wait(0.1); |
embeddedartists | 3:7ef908e84ae1 | 66 | ledBlue = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 67 | } |
embeddedartists | 3:7ef908e84ae1 | 68 | #else |
embeddedartists | 2:2f4b7535ceb3 | 69 | for(int i=0; i<10; i++) |
embeddedartists | 2:2f4b7535ceb3 | 70 | { |
embeddedartists | 2:2f4b7535ceb3 | 71 | ledRed = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 72 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 73 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 74 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 75 | } |
embeddedartists | 2:2f4b7535ceb3 | 76 | wait(0.5); |
embeddedartists | 2:2f4b7535ceb3 | 77 | for(int i=0; i<10; i++) |
embeddedartists | 2:2f4b7535ceb3 | 78 | { |
embeddedartists | 2:2f4b7535ceb3 | 79 | ledGreen = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 80 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 81 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 82 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 83 | } |
embeddedartists | 2:2f4b7535ceb3 | 84 | wait(0.5); |
embeddedartists | 2:2f4b7535ceb3 | 85 | for(int i=0; i<10; i++) |
embeddedartists | 2:2f4b7535ceb3 | 86 | { |
embeddedartists | 2:2f4b7535ceb3 | 87 | ledBlue = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 88 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 89 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 90 | wait(0.05); |
embeddedartists | 2:2f4b7535ceb3 | 91 | } |
embeddedartists | 2:2f4b7535ceb3 | 92 | wait(0.5); |
embeddedartists | 3:7ef908e84ae1 | 93 | #endif |
embeddedartists | 2:2f4b7535ceb3 | 94 | } |
embeddedartists | 2:2f4b7535ceb3 | 95 | |
embeddedartists | 2:2f4b7535ceb3 | 96 | void TestRGBLed::showStatus(bool success) { |
embeddedartists | 2:2f4b7535ceb3 | 97 | // Have to create the DigitalOut instances here (as opposed to |
embeddedartists | 2:2f4b7535ceb3 | 98 | // create them in the constructor) as some of the pins are shared |
embeddedartists | 2:2f4b7535ceb3 | 99 | // with other functionality on the LPC4088 Experiment Base Board |
embeddedartists | 2:2f4b7535ceb3 | 100 | DigitalOut ledRed(_redPin); |
embeddedartists | 2:2f4b7535ceb3 | 101 | DigitalOut ledGreen(_greenPin); |
embeddedartists | 2:2f4b7535ceb3 | 102 | DigitalOut ledBlue(_bluePin); |
embeddedartists | 2:2f4b7535ceb3 | 103 | |
embeddedartists | 2:2f4b7535ceb3 | 104 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 105 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 106 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 107 | if (success) { |
embeddedartists | 2:2f4b7535ceb3 | 108 | ledGreen = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 109 | } else { |
embeddedartists | 2:2f4b7535ceb3 | 110 | ledRed = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 111 | } |
embeddedartists | 2:2f4b7535ceb3 | 112 | } |
embeddedartists | 2:2f4b7535ceb3 | 113 | |
embeddedartists | 2:2f4b7535ceb3 | 114 | void TestRGBLed::waitForButtonClick() { |
embeddedartists | 2:2f4b7535ceb3 | 115 | // wait for button to be pressed |
embeddedartists | 2:2f4b7535ceb3 | 116 | while(_button.read() == BUTTON_RELEASED); |
embeddedartists | 2:2f4b7535ceb3 | 117 | |
embeddedartists | 2:2f4b7535ceb3 | 118 | // small delay to avoid contact bounce |
embeddedartists | 2:2f4b7535ceb3 | 119 | wait_ms(40); |
embeddedartists | 2:2f4b7535ceb3 | 120 | |
embeddedartists | 2:2f4b7535ceb3 | 121 | // wait for button to be released |
embeddedartists | 2:2f4b7535ceb3 | 122 | while(_button.read() == BUTTON_PRESSED); |
embeddedartists | 2:2f4b7535ceb3 | 123 | } |
embeddedartists | 2:2f4b7535ceb3 | 124 | |
embeddedartists | 2:2f4b7535ceb3 | 125 | bool TestRGBLed::runTest() { |
embeddedartists | 2:2f4b7535ceb3 | 126 | // Have to create the DigitalOut instances here (as opposed to |
embeddedartists | 2:2f4b7535ceb3 | 127 | // create them in the constructor) as some of the pins are shared |
embeddedartists | 2:2f4b7535ceb3 | 128 | // with other functionality on the LPC4088 Experiment Base Board |
embeddedartists | 2:2f4b7535ceb3 | 129 | DigitalOut ledRed(_redPin); |
embeddedartists | 2:2f4b7535ceb3 | 130 | DigitalOut ledGreen(_greenPin); |
embeddedartists | 2:2f4b7535ceb3 | 131 | DigitalOut ledBlue(_bluePin); |
embeddedartists | 2:2f4b7535ceb3 | 132 | |
embeddedartists | 3:7ef908e84ae1 | 133 | //printf("LED Tests: All off. Press button to continue\n"); |
embeddedartists | 3:7ef908e84ae1 | 134 | //ledRed = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 135 | //ledGreen = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 136 | //ledBlue = LED_OFF; |
embeddedartists | 3:7ef908e84ae1 | 137 | //waitForButtonClick(); |
embeddedartists | 2:2f4b7535ceb3 | 138 | |
embeddedartists | 2:2f4b7535ceb3 | 139 | printf("LED Tests: RED on. Press button to continue\n"); |
embeddedartists | 2:2f4b7535ceb3 | 140 | ledRed = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 141 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 142 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 143 | waitForButtonClick(); |
embeddedartists | 2:2f4b7535ceb3 | 144 | |
embeddedartists | 2:2f4b7535ceb3 | 145 | printf("LED Tests: GREEN on. Press button to continue\n"); |
embeddedartists | 2:2f4b7535ceb3 | 146 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 147 | ledGreen = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 148 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 149 | waitForButtonClick(); |
embeddedartists | 2:2f4b7535ceb3 | 150 | |
embeddedartists | 2:2f4b7535ceb3 | 151 | printf("LED Tests: BLUE on. Press button to continue\n"); |
embeddedartists | 2:2f4b7535ceb3 | 152 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 153 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 154 | ledBlue = LED_ON; |
embeddedartists | 2:2f4b7535ceb3 | 155 | waitForButtonClick(); |
embeddedartists | 2:2f4b7535ceb3 | 156 | |
embeddedartists | 3:7ef908e84ae1 | 157 | //printf("LED Tests: All on. Press button to continue\n"); |
embeddedartists | 3:7ef908e84ae1 | 158 | //ledRed = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 159 | //ledGreen = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 160 | //ledBlue = LED_ON; |
embeddedartists | 3:7ef908e84ae1 | 161 | //waitForButtonClick(); |
embeddedartists | 2:2f4b7535ceb3 | 162 | |
embeddedartists | 2:2f4b7535ceb3 | 163 | // Turn them off again |
embeddedartists | 2:2f4b7535ceb3 | 164 | ledRed = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 165 | ledGreen = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 166 | ledBlue = LED_OFF; |
embeddedartists | 2:2f4b7535ceb3 | 167 | |
embeddedartists | 2:2f4b7535ceb3 | 168 | return true; |
embeddedartists | 2:2f4b7535ceb3 | 169 | } |
embeddedartists | 2:2f4b7535ceb3 | 170 | |
embeddedartists | 2:2f4b7535ceb3 | 171 |