LPC1114FN28 SD-CARD PROGRAM

Dependencies:   SDFileSystem mbed

Fork of SDFileSystem_HelloWorld by Peter Ampt

Files at this revision

API Documentation at this revision

Comitter:
bant62
Date:
Fri Dec 06 08:36:36 2013 +0000
Parent:
1:63277c702117
Commit message:
LPC1114FN28 SD???????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 24 08:59:14 2013 +0000
+++ b/main.cpp	Fri Dec 06 08:36:36 2013 +0000
@@ -1,32 +1,37 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
- 
+
 /*
-FRDM KL25Z with Seeed SD Card Shield V4
-Connections have to be added between the SD Card Shield
+LPC1114FN28 with SD Card Test
 digital connector pins and the SPI connector pins as follows:
-Signal  Digital SPI
-MOSI    D11     4
-MISO    D12     1
-SCK     D13     3
-/CS     D4
+Signal  PIN
+MOSI    dp2
+MISO    dp1
+SCK     dp6
+/CS     dp4
 */
 
-//SDFileSystem sd(PTD2, PTD3, PTD1, PTA4, "sd"); // MOSI, MISO, SCK, CS
-SDFileSystem sd(D11, D12, D13, D4, "sd"); // MOSI, MISO, SCK, CS
-Serial pc(USBTX, USBRX);
- 
-int main() {
-    pc.printf("Hello World!\n");   
- 
+SDFileSystem sd(dp2, dp1, dp6, dp4, "sd"); // the pinout on the mbed Cool Components workshop board
+Serial uart(dp16, dp15); // UART .. P1_7: TX (pin 16), P1_6: RX (pin 15)
+
+int main()
+{
+    uart.baud(115200);  // Baud rate
+    uart.printf("Hello World!\r\n");
+
     mkdir("/sd/mydir", 0777);
-    
+
     FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
     if(fp == NULL) {
-        pc.printf("Could not open file for write\n");
+        uart.printf("Could not open file for write\r\n");
+        exit(1);
+    }
+    for (int i=0; i<100; i++) {
+        fprintf(fp, "Hello fun SD Card World! :: NO %d\r\n",i);
     }
-    fprintf(fp, "Hello fun SD Card World!");
-    fclose(fp); 
- 
-    pc.printf("Goodbye World!\n");
+    fclose(fp);
+
+    uart.printf("Goodbye World!\r\n");
+    
+    return 0;
 }