LPC1114FN28 SD-CARD PROGRAM
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
main.cpp@1:63277c702117, 2013-10-24 (annotated)
- Committer:
- pampt
- Date:
- Thu Oct 24 08:59:14 2013 +0000
- Revision:
- 1:63277c702117
- Parent:
- 0:bdbd3d6fc5d5
- Child:
- 2:1c74c8b71d0e
Seeed Studio SD card V4.0 shield with Freescale KL25Z platform.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 0:bdbd3d6fc5d5 | 1 | #include "mbed.h" |
mbed_official | 0:bdbd3d6fc5d5 | 2 | #include "SDFileSystem.h" |
mbed_official | 0:bdbd3d6fc5d5 | 3 | |
pampt | 1:63277c702117 | 4 | /* |
pampt | 1:63277c702117 | 5 | FRDM KL25Z with Seeed SD Card Shield V4 |
pampt | 1:63277c702117 | 6 | Connections have to be added between the SD Card Shield |
pampt | 1:63277c702117 | 7 | digital connector pins and the SPI connector pins as follows: |
pampt | 1:63277c702117 | 8 | Signal Digital SPI |
pampt | 1:63277c702117 | 9 | MOSI D11 4 |
pampt | 1:63277c702117 | 10 | MISO D12 1 |
pampt | 1:63277c702117 | 11 | SCK D13 3 |
pampt | 1:63277c702117 | 12 | /CS D4 |
pampt | 1:63277c702117 | 13 | */ |
pampt | 1:63277c702117 | 14 | |
pampt | 1:63277c702117 | 15 | //SDFileSystem sd(PTD2, PTD3, PTD1, PTA4, "sd"); // MOSI, MISO, SCK, CS |
pampt | 1:63277c702117 | 16 | SDFileSystem sd(D11, D12, D13, D4, "sd"); // MOSI, MISO, SCK, CS |
pampt | 1:63277c702117 | 17 | Serial pc(USBTX, USBRX); |
mbed_official | 0:bdbd3d6fc5d5 | 18 | |
mbed_official | 0:bdbd3d6fc5d5 | 19 | int main() { |
pampt | 1:63277c702117 | 20 | pc.printf("Hello World!\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 21 | |
mbed_official | 0:bdbd3d6fc5d5 | 22 | mkdir("/sd/mydir", 0777); |
mbed_official | 0:bdbd3d6fc5d5 | 23 | |
mbed_official | 0:bdbd3d6fc5d5 | 24 | FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); |
mbed_official | 0:bdbd3d6fc5d5 | 25 | if(fp == NULL) { |
pampt | 1:63277c702117 | 26 | pc.printf("Could not open file for write\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 27 | } |
mbed_official | 0:bdbd3d6fc5d5 | 28 | fprintf(fp, "Hello fun SD Card World!"); |
mbed_official | 0:bdbd3d6fc5d5 | 29 | fclose(fp); |
mbed_official | 0:bdbd3d6fc5d5 | 30 | |
pampt | 1:63277c702117 | 31 | pc.printf("Goodbye World!\n"); |
mbed_official | 0:bdbd3d6fc5d5 | 32 | } |