usb
Dependencies: mbed FatFileSystemCpp
Diff: main.cpp
- Revision:
- 4:091ef1bde6d6
- Parent:
- 0:e294af8d0e07
--- a/main.cpp Mon Jul 30 13:49:56 2012 +0000 +++ b/main.cpp Thu Feb 18 16:59:35 2021 +0000 @@ -5,6 +5,9 @@ #define FSNAME "msc" MSCFileSystem msc(FSNAME); +uint8_t myblock[1024]; + + int main() { DIR *d; @@ -12,18 +15,18 @@ //struct stat st; //char path[PATH_MAX]; - printf("\n\n================================\n"); - printf("USB Mass storage demo program for mbed LPC1768\n"); - printf("================================\n\n"); + printf("\r\n================================\r\n"); + printf("USB Mass storage demo program for mbed LPC1768\r\n"); + printf("================================\r\n"); d = opendir("/" FSNAME); - printf("\nList of files on the flash drive:\n"); + printf("\r\nList of files on the flash drive:\r\n"); if ( d != NULL ) { while ( (p = readdir(d)) != NULL ) { - printf(" - %s\n", p->d_name); + printf(" - %s\r\n", p->d_name); /* no <stat.h> on mbed, it seems :/ sprintf(path, "/"FSNAME"/%s", p->d_name); if ( stat(path, &st) == 0 ) @@ -43,16 +46,27 @@ { error("Could not open directory!"); } - printf("\nTesting file write:\n"); + printf("\r\nTesting file write:\r\n"); FILE *fp = fopen( "/" FSNAME "/msctest.txt", "w"); if ( fp == NULL ) { - error("Could not open file for write\n"); + error("Could not open file for write\r\n"); } + + printf("\r\nWriting 1MB:\r\n"); + for (int mb=0;mb<10;mb++){ + for (int k=0;k<1024;k++){ + fwrite(&myblock, sizeof(myblock), 1, fp); + + } + printf("Written %dMB:\r\n",mb); + } + printf("\r\nFinished:\r\n"); + fprintf(fp, "Hello mass storage!"); fclose(fp); - printf("\n - OK\n"); - + printf("\n - OK\r\n"); +/* printf("\nTesting file read:\n"); fp = fopen( "/" FSNAME "/msctest.txt", "r"); if ( fp == NULL ) @@ -66,4 +80,6 @@ } fclose(fp); printf("\n - OK, read string: '%s'\n\n", buf); + + */ }