Production Test Program (PTP) for the LPC4088 Experiment Base Board

Dependencies:   EALib I2S LM75B SDFileSystem mbed

Committer:
embeddedartists
Date:
Thu Aug 28 09:36:13 2014 +0000
Revision:
2:2f4b7535ceb3
Child:
3:7ef908e84ae1
Moved each test into separate classes.

Who changed what in which revision?

UserRevisionLine numberNew 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 2:2f4b7535ceb3 56 for(int i=0; i<10; i++)
embeddedartists 2:2f4b7535ceb3 57 {
embeddedartists 2:2f4b7535ceb3 58 ledRed = LED_ON;
embeddedartists 2:2f4b7535ceb3 59 wait(0.05);
embeddedartists 2:2f4b7535ceb3 60 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 61 wait(0.05);
embeddedartists 2:2f4b7535ceb3 62 }
embeddedartists 2:2f4b7535ceb3 63 wait(0.5);
embeddedartists 2:2f4b7535ceb3 64 for(int i=0; i<10; i++)
embeddedartists 2:2f4b7535ceb3 65 {
embeddedartists 2:2f4b7535ceb3 66 ledGreen = LED_ON;
embeddedartists 2:2f4b7535ceb3 67 wait(0.05);
embeddedartists 2:2f4b7535ceb3 68 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 69 wait(0.05);
embeddedartists 2:2f4b7535ceb3 70 }
embeddedartists 2:2f4b7535ceb3 71 wait(0.5);
embeddedartists 2:2f4b7535ceb3 72 for(int i=0; i<10; i++)
embeddedartists 2:2f4b7535ceb3 73 {
embeddedartists 2:2f4b7535ceb3 74 ledBlue = LED_ON;
embeddedartists 2:2f4b7535ceb3 75 wait(0.05);
embeddedartists 2:2f4b7535ceb3 76 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 77 wait(0.05);
embeddedartists 2:2f4b7535ceb3 78 }
embeddedartists 2:2f4b7535ceb3 79 wait(0.5);
embeddedartists 2:2f4b7535ceb3 80 }
embeddedartists 2:2f4b7535ceb3 81
embeddedartists 2:2f4b7535ceb3 82 void TestRGBLed::showStatus(bool success) {
embeddedartists 2:2f4b7535ceb3 83 // Have to create the DigitalOut instances here (as opposed to
embeddedartists 2:2f4b7535ceb3 84 // create them in the constructor) as some of the pins are shared
embeddedartists 2:2f4b7535ceb3 85 // with other functionality on the LPC4088 Experiment Base Board
embeddedartists 2:2f4b7535ceb3 86 DigitalOut ledRed(_redPin);
embeddedartists 2:2f4b7535ceb3 87 DigitalOut ledGreen(_greenPin);
embeddedartists 2:2f4b7535ceb3 88 DigitalOut ledBlue(_bluePin);
embeddedartists 2:2f4b7535ceb3 89
embeddedartists 2:2f4b7535ceb3 90 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 91 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 92 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 93 if (success) {
embeddedartists 2:2f4b7535ceb3 94 ledGreen = LED_ON;
embeddedartists 2:2f4b7535ceb3 95 } else {
embeddedartists 2:2f4b7535ceb3 96 ledRed = LED_ON;
embeddedartists 2:2f4b7535ceb3 97 }
embeddedartists 2:2f4b7535ceb3 98 }
embeddedartists 2:2f4b7535ceb3 99
embeddedartists 2:2f4b7535ceb3 100 void TestRGBLed::waitForButtonClick() {
embeddedartists 2:2f4b7535ceb3 101 // wait for button to be pressed
embeddedartists 2:2f4b7535ceb3 102 while(_button.read() == BUTTON_RELEASED);
embeddedartists 2:2f4b7535ceb3 103
embeddedartists 2:2f4b7535ceb3 104 // small delay to avoid contact bounce
embeddedartists 2:2f4b7535ceb3 105 wait_ms(40);
embeddedartists 2:2f4b7535ceb3 106
embeddedartists 2:2f4b7535ceb3 107 // wait for button to be released
embeddedartists 2:2f4b7535ceb3 108 while(_button.read() == BUTTON_PRESSED);
embeddedartists 2:2f4b7535ceb3 109 }
embeddedartists 2:2f4b7535ceb3 110
embeddedartists 2:2f4b7535ceb3 111 bool TestRGBLed::runTest() {
embeddedartists 2:2f4b7535ceb3 112 // Have to create the DigitalOut instances here (as opposed to
embeddedartists 2:2f4b7535ceb3 113 // create them in the constructor) as some of the pins are shared
embeddedartists 2:2f4b7535ceb3 114 // with other functionality on the LPC4088 Experiment Base Board
embeddedartists 2:2f4b7535ceb3 115 DigitalOut ledRed(_redPin);
embeddedartists 2:2f4b7535ceb3 116 DigitalOut ledGreen(_greenPin);
embeddedartists 2:2f4b7535ceb3 117 DigitalOut ledBlue(_bluePin);
embeddedartists 2:2f4b7535ceb3 118
embeddedartists 2:2f4b7535ceb3 119 printf("LED Tests: All off. Press button to continue\n");
embeddedartists 2:2f4b7535ceb3 120 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 121 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 122 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 123 waitForButtonClick();
embeddedartists 2:2f4b7535ceb3 124
embeddedartists 2:2f4b7535ceb3 125 printf("LED Tests: RED on. Press button to continue\n");
embeddedartists 2:2f4b7535ceb3 126 ledRed = LED_ON;
embeddedartists 2:2f4b7535ceb3 127 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 128 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 129 waitForButtonClick();
embeddedartists 2:2f4b7535ceb3 130
embeddedartists 2:2f4b7535ceb3 131 printf("LED Tests: GREEN on. Press button to continue\n");
embeddedartists 2:2f4b7535ceb3 132 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 133 ledGreen = LED_ON;
embeddedartists 2:2f4b7535ceb3 134 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 135 waitForButtonClick();
embeddedartists 2:2f4b7535ceb3 136
embeddedartists 2:2f4b7535ceb3 137 printf("LED Tests: BLUE on. Press button to continue\n");
embeddedartists 2:2f4b7535ceb3 138 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 139 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 140 ledBlue = LED_ON;
embeddedartists 2:2f4b7535ceb3 141 waitForButtonClick();
embeddedartists 2:2f4b7535ceb3 142
embeddedartists 2:2f4b7535ceb3 143 printf("LED Tests: All on. Press button to continue\n");
embeddedartists 2:2f4b7535ceb3 144 ledRed = LED_ON;
embeddedartists 2:2f4b7535ceb3 145 ledGreen = LED_ON;
embeddedartists 2:2f4b7535ceb3 146 ledBlue = LED_ON;
embeddedartists 2:2f4b7535ceb3 147 waitForButtonClick();
embeddedartists 2:2f4b7535ceb3 148
embeddedartists 2:2f4b7535ceb3 149 // Turn them off again
embeddedartists 2:2f4b7535ceb3 150 ledRed = LED_OFF;
embeddedartists 2:2f4b7535ceb3 151 ledGreen = LED_OFF;
embeddedartists 2:2f4b7535ceb3 152 ledBlue = LED_OFF;
embeddedartists 2:2f4b7535ceb3 153
embeddedartists 2:2f4b7535ceb3 154 return true;
embeddedartists 2:2f4b7535ceb3 155 }
embeddedartists 2:2f4b7535ceb3 156
embeddedartists 2:2f4b7535ceb3 157