Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EALib I2S LM75B SDFileSystem mbed
TestFileSystemSPI.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 "TestFileSystemSPI.h" 00023 #include "SDFileSystem.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 2-3, that is closest to the edge 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 TestFileSystemSPI::runTest() { 00048 // The LPC4088 Experiment Base Board does not have the CardDetect signal 00049 // available so it must be set to NC here to work. 00050 SDFileSystem spifs(p5, p6, p7, p8, "spi"); // mosi, miso, sclk, cs 00051 00052 // This test expects a file with the name message.txt to exist in the 00053 // root folder on the uSD card. The file must be at least 10 bytes in 00054 // size and the first bytes must be eatest2014. 00055 FILE* fp = fopen("/spi/message.txt", "r"); 00056 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("SPI SD Card works!\n"); 00064 fclose(fp); 00065 return true; 00066 } 00067 printf("Invalid data read from /spi/message.txt\n"); 00068 } 00069 printf("Failed to read >= 10 bytes from /spi/message.txt\n"); 00070 } 00071 printf("Failed to open /spi/message.txt\n"); 00072 return false; 00073 } 00074 00075
Generated on Sun Jul 17 2022 08:29:10 by
1.7.2