Production Test Program (PTP) for the LPC4088 Experiment Base Board
Dependencies: EALib I2S LM75B SDFileSystem mbed
TestFileSystemMCI.cpp
00001 /* 00002 * Copyright 2013 Embedded Artists AB 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /****************************************************************************** 00018 * Includes 00019 *****************************************************************************/ 00020 00021 #include "mbed.h" 00022 #include "TestFileSystemMCI.h" 00023 #include "MCIFileSystem.h" 00024 00025 /****************************************************************************** 00026 * Defines and typedefs 00027 *****************************************************************************/ 00028 00029 00030 /****************************************************************************** 00031 * Public Functions 00032 *****************************************************************************/ 00033 00034 /* 00035 Prerequisites: 00036 00037 - For this test to work jumpers JP1..JP6 on the LPC4088 Experiment Base Board 00038 must all be in positions 1-2, that is closest to the center of the board. 00039 00040 - The uSD card must be formatted as FAT or FAT32, NTFS will not work. 00041 00042 - This test expects a file with the name message.txt to exist in the 00043 root folder on the uSD card. The file must be at least 10 bytes in 00044 size and the first bytes must be eatest2014 00045 */ 00046 00047 bool TestFileSystemMCI::runTest() { 00048 printf("Testing MCI file system. If this test takes a lot of time make sure that\n" 00049 "there is a uSD card inserted and that the jumpers are inserted according\n" 00050 "to the instructions!\n"); 00051 00052 // The LPC4088 Experiment Base Board does not have the CardDetect signal 00053 // available so it must be set to NC here to work. 00054 MCIFileSystem mcifs("mci", NC); 00055 00056 FILE* fp = fopen("/mci/message.txt", "r"); 00057 if (fp != NULL) { 00058 char buf[20]; 00059 int num = fread(buf, 1, sizeof(buf), fp); 00060 if (num >= 10) { 00061 buf[10] = '\0'; 00062 if (strcmp(buf, "eatest2014") == 0) { 00063 printf("MCI SD Card works!\n"); 00064 fclose(fp); 00065 return true; 00066 } 00067 printf("Invalid data read from /mci/message.txt\n"); 00068 } 00069 printf("Failed to read >= 10 bytes from /mci/message.txt\n"); 00070 } 00071 printf("Failed to open /mci/message.txt\n"); 00072 return false; 00073 } 00074 00075
Generated on Sun Jul 17 2022 08:29:10 by 1.7.2