Downloads data from a raw SD card from a SEDS flight

Dependencies:   SDFileSystem mbed

Committer:
richardemeadows
Date:
Fri Jun 13 14:50:47 2014 +0000
Revision:
0:20fa3d43f1e7
Initial Commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
richardemeadows 0:20fa3d43f1e7 1 #include "mbed.h"
richardemeadows 0:20fa3d43f1e7 2 #include "SDFileSystem.h"
richardemeadows 0:20fa3d43f1e7 3
richardemeadows 0:20fa3d43f1e7 4 SDFileSystem sd(p5, p6, p7, p8, "sd"); // MOSI, MISO, SCLK, SSEL
richardemeadows 0:20fa3d43f1e7 5 DigitalOut myled(LED1);
richardemeadows 0:20fa3d43f1e7 6
richardemeadows 0:20fa3d43f1e7 7 int main() {
richardemeadows 0:20fa3d43f1e7 8 printf("Starting download...\r\n");
richardemeadows 0:20fa3d43f1e7 9
richardemeadows 0:20fa3d43f1e7 10 sd.disk_initialize();
richardemeadows 0:20fa3d43f1e7 11
richardemeadows 0:20fa3d43f1e7 12 uint8_t buffer[0x200];
richardemeadows 0:20fa3d43f1e7 13 sd.disk_read(buffer, 0);
richardemeadows 0:20fa3d43f1e7 14
richardemeadows 0:20fa3d43f1e7 15 int block_count = ((uint32_t*)buffer)[0];
richardemeadows 0:20fa3d43f1e7 16 printf("%d blocks to download...\r\n\r\n", block_count);
richardemeadows 0:20fa3d43f1e7 17
richardemeadows 0:20fa3d43f1e7 18 char command;
richardemeadows 0:20fa3d43f1e7 19 printf("\r\nPress 'd' to download, 'c' to clear:\r\n");
richardemeadows 0:20fa3d43f1e7 20 scanf("%c", &command);
richardemeadows 0:20fa3d43f1e7 21
richardemeadows 0:20fa3d43f1e7 22 if (command == 'd') {
richardemeadows 0:20fa3d43f1e7 23 for (int i = 1; i < block_count; i++) {
richardemeadows 0:20fa3d43f1e7 24 sd.disk_read(buffer, i);
richardemeadows 0:20fa3d43f1e7 25 printf("%s\r", (char*)buffer);
richardemeadows 0:20fa3d43f1e7 26 }
richardemeadows 0:20fa3d43f1e7 27 } else if (command == 'c') {
richardemeadows 0:20fa3d43f1e7 28 printf("\r\nClearing first sector...\r\n");
richardemeadows 0:20fa3d43f1e7 29 ((uint32_t*)buffer)[0] = 0;
richardemeadows 0:20fa3d43f1e7 30 sd.disk_write(buffer, 0);
richardemeadows 0:20fa3d43f1e7 31 }
richardemeadows 0:20fa3d43f1e7 32 }