first

Dependencies:   SDFileSystemDMA mbed

Refer to:
https://developer.mbed.org/users/mimi3/code/SDFileSystemDMA

Caution

If your board has SRAM less than or equal to 8KB, the 'buffer' size must be set to 512 Bytes.

NUCLEO-F411RE
About 2.5MBytes/sec
/media/uploads/mimi3/sdfilesystemdma-speed-test-teraterm-output-f411re.png
NUCLEO-L152RE
About 1MBytes/sec
/media/uploads/mimi3/sdfilesystemdma-l152re-cui.png

Revision:
26:1a610f9aec1a
Parent:
25:1e42edbeacca
--- a/main.cpp	Tue Jan 17 12:21:46 2017 +0900
+++ b/main.cpp	Thu Jan 19 21:35:43 2017 +0900
@@ -53,13 +53,13 @@
 #include "spi_device.h"
 #define UART_KEY_PRESS  1
 
-#define SPI_CLOCK_HZ    ( 12 * 1000000 ) 
+#define SPI_CLOCK_HZ    ( 12 * 1000000 )
 
 Timer timer;
 //Serial pc(PA_9,PA_10);
 Serial pc(USBTX,USBRX); /* Baudrate is 9600bps*/
 
-SDFileSystem sd( MOSI, MISO, SCLK, CS, "sd", SPI_CLOCK_HZ);  
+SDFileSystem sd( MOSI, MISO, SCLK, CS, "sd", SPI_CLOCK_HZ);
 
 /* Set buffer size */
 char buffer[512*1]  __attribute__ ((aligned (4))) ;      /*   512 bytes */
@@ -72,10 +72,10 @@
 #define X_MEGA_BYTE     ((1)*1024*1024) /* 1Mbyte */
 #define FILE_NAME   "GPATH"
 
-#if defined(__CC_ARM)     /* ARMCC      */ 
+#if defined(__CC_ARM)     /* ARMCC      */
 #define TOOLCHAIN   "ARM/uARM"
 #define C_VERSION   __ARMCC_VERSION
-#elif defined(__GNUC__)       /* GCC        */ 
+#elif defined(__GNUC__)       /* GCC        */
 #define TOOLCHAIN   "GCC_ARM"
 #elif defined(__ICCARM__)   /* IAR        */
 #define TOOLCHAIN   "IAR"
@@ -96,7 +96,7 @@
 #if !_FS_READONLY
 	//Test write performance by creating a 1MB file
 	pc.printf("[Write]: Testing %d bytes buffer: write performance...", sizeof(buffer));
-	fflush(stdout); 
+	fflush(stdout);
 	for(uint32_t k = 0; k < sizeof(buffer); k++){
 		buffer[k] = k & 0xff;
 	}
@@ -129,7 +129,7 @@
 {
 	//Test read performance by reading the 1MB file created by writeTest()
 	pc.printf("[Read]: Testing %d bytes buffer: read performance...", sizeof(buffer));
-	fflush(stdout); 
+	fflush(stdout);
 	FileHandle* file = sd.open(FILE_NAME, O_RDONLY);
 	if (file != NULL) {
 		timer.start();
@@ -158,7 +158,7 @@
 	int errorCount = 0;
 	//Test read performance by reading the 1MB file created by writeTest()
 	pc.printf("[Read]: Verifying %d bytes buffer ...", sizeof(buffer));
-	fflush(stdout); 
+	fflush(stdout);
 	FileHandle* file = sd.open(FILE_NAME, O_RDONLY);
 	if (file != NULL) {
 		timer.start();
@@ -167,7 +167,7 @@
 			iterations++;
 			for(uint32_t k = 0; k < sizeof(buffer); k++){
 				if ( buffer[k] != (k & 0xff) ){
-					errorCount++;    
+					errorCount++;
 				}
 			}
 		}
@@ -221,13 +221,13 @@
 		pc.printf("\nCompiler                = %s", TOOLCHAIN);
 		pc.printf("\nmbed-lib                = Rev.%d", MBED_LIBRARY_VERSION);
 		pc.printf("\n\nStart SD card accsess test !");
-		pc.printf("\n[r]: Start Read Test. At least execute [w] onece");
+		pc.printf("\n[r]: Start Read Test. At least execute [w] once");
 		pc.printf("\n[w]: Start Write and Read Test");
-		pc.printf("\n[v]: Start Read Verify Test. At least execute [w] onece");
-		pc.printf("\nNote: Writing is very slow, wait tens of seconds."); 
+		pc.printf("\n[v]: Start Read Verify Test. At least execute [w] once");
+		pc.printf("\nNote: Writing is very slow, wait tens of seconds.");
         warning();
-		pc.printf("\n--- Select [r] or [w] or [v]---\n");  
-		fflush(stdout); 
+		pc.printf("\n--- Select [r] or [w] or [v]---\n");
+		fflush(stdout);
 		char ch = wait_key_press();
 		if( ch =='r' ){
 			readTest();
@@ -240,8 +240,8 @@
         else{
             continue;
         }
-		pc.printf("\n--- Press any key ---\n");  
-		fflush(stdout); 
+		pc.printf("\n--- Press any key ---\n");
+		fflush(stdout);
 		wait_key_press();
 	}
 }