real honest
Dependencies: ELEC350-Practicals-FZ429
Fork of Task680solution-mbed-os-FZ429ZI by
Revision 5:49bcc61caa2c, committed 2018-01-07
- Comitter:
- rubbehducky
- Date:
- Sun Jan 07 19:45:04 2018 +0000
- Parent:
- 4:958cfd74ef1c
- Commit message:
- dodododo
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Wed Dec 06 11:20:21 2017 +0000
+++ b/main.cpp Sun Jan 07 19:45:04 2018 +0000
@@ -8,12 +8,11 @@
//SD Card Object
SDBlockDevice sd(PB_5, D12, D13, D10); // mosi, miso, sclk, cs
- uint8_t block[512] = "Hello World!\n";
+// Data type
+
+
int main()
{
- //POWER ON SELF TEST
- post();
-
printf("Initialise\n");
//FileSystemLike(*sd);
@@ -37,35 +36,50 @@
errorCode(FATAL);
}
+ /*
+
+
//Put some text in the file...
+ //This
+ if ( 0 == sd.program(block, 0, 512)) {
fprintf(fp, "Welcome to ELEC350\n");
+ }
+
+
+ */
+
+ if (onBoardSwitch == 1) {
+ press = true;
+ }
+
+ if (press == true) {
+
+ //Close File
+ fclose(fp);
+
+ //Close down SD card (flush buffers)
+ sd.deinit();
+
+ //Let user know
+ puts("You can now remove the SD Card\n");
+
+ for (unsigned int n=0; n<2; n++) {
+ onBoardLED = 1;
+ wait(0.2);
+ onBoardLED = 0;
+ wait(0.2);
+ }
+
+ //Flag to record the event
+ ejected = true;
+ }
//Close the file
fclose(fp);
- // ************
- // Open to READ
- // ************
- printf("Read a file\n");
- fp = fopen("/sd/test.txt","r");
- if (fp == NULL) {
- error("Could not open file for read\n");
- errorCode(FATAL);
- }
-
- //Read back all strings
- char s1[64];
- while (fscanf(fp, "%s", s1) == 1) {
- printf("READ BACK: %s\n", s1);
- }
- //To read a whole line, use: fgets(s1, sizeof(s1), fp);
-
-
- //Close File
- fclose(fp);
-
//Close down
sd.deinit();
+
printf("All done...\n");
errorCode(OK);
@@ -79,16 +93,8 @@
}
/*
- printf("sd size: %llu\n", sd.size());
- printf("sd read size: %llu\n", sd.get_read_size());
- printf("sd program size: %llu\n", sd.get_program_size());
printf("sd erase size: %llu\n", sd.get_erase_size());
- // set the frequency
- if ( 0 != sd.frequency(5000000)) {
- printf("Error setting frequency \n");
- }
-
if ( 0 != sd.erase(0, sd.get_erase_size())) {
printf("Error Erasing block \n");
}
@@ -101,8 +107,4 @@
printf("%s", block);
}
}
-
- // call the SDBlockDevice instance de-initialisation method.
-
- sd.deinit();
*/
\ No newline at end of file
