public Test program for usbhostmsd looking at ridiculous resource usage
Dependencies: test_USBHost mbed
Fork of USBHostMSD_HelloWorld by
main.cpp
- Committer:
- sbts
- Date:
- 2015-03-19
- Revision:
- 9:d86a5e08abcd
- Parent:
- 4:f8a5c8aa895a
File content as of revision 9:d86a5e08abcd:
#include "mbed.h" #include "USBHostMSD.h" #include "ramstats.h" Serial pc(USBTX, USBRX); // tx, rx DigitalOut led(LED1); void msd_task(void const *) { USBHostMSD msd("usb"); int i = 0; while(1) { // try to connect a MSD device while(!msd.connect()) { Thread::wait(500); } // in a loop, append a file // if the device is disconnected, we try to connect it again while(1) { // append a file FILE * fp = fopen("/usb/test1.txt", "a"); if (fp != NULL) { fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++); printf("Goodbye World!\r\n"); fclose(fp); } else { printf("FILE == NULL\r\n"); } Thread::wait(500); // if device disconnected, try to connect again if (!msd.connected()) break; break;} break;} DisplayRAMBanks("\r\nmsd thread:\r\n"); } int main() { pc.baud(115200); Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4); DisplayRAMBanks("\r\nmain thread:\r\n"); while(1) { led=!led; Thread::wait(500); } }