yes Spada / Mbed 2 deprecated shieldtest

Dependencies:   mbed SDFileSystem

Committer:
spadaaa
Date:
Tue Mar 10 14:30:30 2020 +0000
Revision:
5:c797b67db008
Parent:
3:5edc67dee8b7
not working ): (disk, or could not put SD card in to SPI idle state)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 3:5edc67dee8b7 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
screamer 3:5edc67dee8b7 2 *
screamer 3:5edc67dee8b7 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
screamer 3:5edc67dee8b7 4 * and associated documentation files (the "Software"), to deal in the Software without
screamer 3:5edc67dee8b7 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
screamer 3:5edc67dee8b7 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
screamer 3:5edc67dee8b7 7 * Software is furnished to do so, subject to the following conditions:
screamer 3:5edc67dee8b7 8 *
screamer 3:5edc67dee8b7 9 * The above copyright notice and this permission notice shall be included in all copies or
screamer 3:5edc67dee8b7 10 * substantial portions of the Software.
screamer 3:5edc67dee8b7 11 *
screamer 3:5edc67dee8b7 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
screamer 3:5edc67dee8b7 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
screamer 3:5edc67dee8b7 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
screamer 3:5edc67dee8b7 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
screamer 3:5edc67dee8b7 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
screamer 3:5edc67dee8b7 17 */
screamer 3:5edc67dee8b7 18
screamer 0:525c842a3c89 19 #include "mbed.h"
screamer 0:525c842a3c89 20 #include "SDFileSystem.h"
screamer 0:525c842a3c89 21
screamer 2:f2f5e2324ad4 22 Serial pc(USBTX, USBRX);
spadaaa 5:c797b67db008 23 //SDFileSystem sd(D11, D12, D13, D9, "sd"); // MOSI, MISO, SCK, CS
spadaaa 5:c797b67db008 24 SDFileSystem sd(PB_15,PB_14,PB_13,PB_12, "sd");
spadaaa 5:c797b67db008 25
screamer 0:525c842a3c89 26 FILE *fp;
screamer 0:525c842a3c89 27
screamer 0:525c842a3c89 28 int main() {
screamer 1:93d41c73ac7d 29 wait(2);
screamer 1:93d41c73ac7d 30 pc.printf("Initializing\r\n");
screamer 0:525c842a3c89 31
screamer 0:525c842a3c89 32 fp = fopen("/sd/hello.txt", "r");
screamer 0:525c842a3c89 33 if (fp != NULL) {
screamer 0:525c842a3c89 34 fclose(fp);
screamer 0:525c842a3c89 35 remove("/sd/hello.txt");
screamer 1:93d41c73ac7d 36 pc.printf("Remove an existing file with the same name\r\n");
screamer 0:525c842a3c89 37 }
screamer 0:525c842a3c89 38
screamer 0:525c842a3c89 39 fp = fopen("/sd/hello.txt", "w");
screamer 0:525c842a3c89 40 if (fp == NULL) {
screamer 1:93d41c73ac7d 41 pc.printf("Unable to write the file\r\n");
screamer 0:525c842a3c89 42 } else {
screamer 0:525c842a3c89 43 fprintf(fp, "mbed SDCard application!");
screamer 0:525c842a3c89 44 fclose(fp);
screamer 1:93d41c73ac7d 45 pc.printf("File successfully written!\r\n");
screamer 0:525c842a3c89 46 }
screamer 0:525c842a3c89 47 }