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

Dependencies:   EALib I2S LM75B SDFileSystem mbed

Committer:
embeddedartists
Date:
Wed Oct 01 11:16:38 2014 +0000
Revision:
9:eb6086159020
Parent:
2:2f4b7535ceb3
Updated used libraries

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 "TestTemperature.h"
embeddedartists 2:2f4b7535ceb3 23 #include "LM75B.h"
embeddedartists 2:2f4b7535ceb3 24
embeddedartists 2:2f4b7535ceb3 25 /******************************************************************************
embeddedartists 2:2f4b7535ceb3 26 * Defines and typedefs
embeddedartists 2:2f4b7535ceb3 27 *****************************************************************************/
embeddedartists 2:2f4b7535ceb3 28
embeddedartists 2:2f4b7535ceb3 29 #define MIN_TEMP (15.0f)
embeddedartists 2:2f4b7535ceb3 30 #define MAX_TEMP (45.0f)
embeddedartists 2:2f4b7535ceb3 31
embeddedartists 2:2f4b7535ceb3 32 /******************************************************************************
embeddedartists 2:2f4b7535ceb3 33 * Public Functions
embeddedartists 2:2f4b7535ceb3 34 *****************************************************************************/
embeddedartists 2:2f4b7535ceb3 35
embeddedartists 2:2f4b7535ceb3 36 /*
embeddedartists 2:2f4b7535ceb3 37 Prerequisites:
embeddedartists 2:2f4b7535ceb3 38
embeddedartists 2:2f4b7535ceb3 39 - For this test to work jumpers JP8 and JP9 on the LPC4088 Experiment Base Board
embeddedartists 2:2f4b7535ceb3 40 must both be in positions 1-2
embeddedartists 2:2f4b7535ceb3 41 */
embeddedartists 2:2f4b7535ceb3 42
embeddedartists 2:2f4b7535ceb3 43 bool TestTemperature::runTest() {
embeddedartists 2:2f4b7535ceb3 44 //Create an LM75B object at 0x92/0x93 (ADDRESS_1)
embeddedartists 2:2f4b7535ceb3 45 LM75B sensor(P0_27, P0_28, LM75B::ADDRESS_1);
embeddedartists 2:2f4b7535ceb3 46
embeddedartists 2:2f4b7535ceb3 47 printf("Testing LM75 temperature sensor...\n");
embeddedartists 2:2f4b7535ceb3 48
embeddedartists 2:2f4b7535ceb3 49 // Test waits up to 5 seconds, sampling the temperature twice per second,
embeddedartists 2:2f4b7535ceb3 50 // for the sensor to produce a value in the MIN_TEMP to MAX_TEMP range.
embeddedartists 2:2f4b7535ceb3 51
embeddedartists 2:2f4b7535ceb3 52 if (sensor.open()) {
embeddedartists 2:2f4b7535ceb3 53 printf("LM75 Device detected!\n");
embeddedartists 2:2f4b7535ceb3 54
embeddedartists 2:2f4b7535ceb3 55 int i = 10;
embeddedartists 2:2f4b7535ceb3 56 while (i--) {
embeddedartists 2:2f4b7535ceb3 57 float f = (float)sensor;
embeddedartists 2:2f4b7535ceb3 58
embeddedartists 2:2f4b7535ceb3 59 printf("Temp = %.3f\n", f);
embeddedartists 2:2f4b7535ceb3 60
embeddedartists 2:2f4b7535ceb3 61 if ((f >= MIN_TEMP) && (f <= MAX_TEMP)) {
embeddedartists 2:2f4b7535ceb3 62 printf("Temp in %.3f..%.3f range - test passed\n", MIN_TEMP, MAX_TEMP);
embeddedartists 2:2f4b7535ceb3 63 return true;
embeddedartists 2:2f4b7535ceb3 64 }
embeddedartists 2:2f4b7535ceb3 65
embeddedartists 2:2f4b7535ceb3 66 //Sleep for 0.5 seconds
embeddedartists 2:2f4b7535ceb3 67 wait(0.5);
embeddedartists 2:2f4b7535ceb3 68 }
embeddedartists 2:2f4b7535ceb3 69 if (i == 0) {
embeddedartists 2:2f4b7535ceb3 70 printf("LM75 No temp in range %.3f..%.3f!\n", MIN_TEMP, MAX_TEMP);
embeddedartists 2:2f4b7535ceb3 71 }
embeddedartists 2:2f4b7535ceb3 72 } else {
embeddedartists 2:2f4b7535ceb3 73 printf("LM75 Device not detected!\n");
embeddedartists 2:2f4b7535ceb3 74 }
embeddedartists 2:2f4b7535ceb3 75 return false;
embeddedartists 2:2f4b7535ceb3 76 }
embeddedartists 2:2f4b7535ceb3 77
embeddedartists 2:2f4b7535ceb3 78