wave player pwm & covox

Dependencies:   wave_player_pwm_and_covox mbed USBHost

Committer:
samux
Date:
Wed Mar 13 10:30:25 2013 +0000
Revision:
4:f8a5c8aa895a
Parent:
2:3e3df7a79050
Child:
9:d0a3b4c7b261
add comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 0:0d68fe822228 1 #include "mbed.h"
samux 0:0d68fe822228 2 #include "USBHostMSD.h"
samux 0:0d68fe822228 3
samux 0:0d68fe822228 4 DigitalOut led(LED1);
samux 0:0d68fe822228 5
samux 0:0d68fe822228 6 void msd_task(void const *) {
samux 0:0d68fe822228 7
samux 0:0d68fe822228 8 USBHostMSD msd("usb");
samux 0:0d68fe822228 9 int i = 0;
samux 0:0d68fe822228 10
samux 0:0d68fe822228 11 while(1) {
samux 0:0d68fe822228 12
samux 1:473f339c54c1 13 // try to connect a MSD device
samux 1:473f339c54c1 14 while(!msd.connect()) {
samux 1:473f339c54c1 15 Thread::wait(500);
samux 1:473f339c54c1 16 }
samux 1:473f339c54c1 17
samux 4:f8a5c8aa895a 18 // in a loop, append a file
samux 4:f8a5c8aa895a 19 // if the device is disconnected, we try to connect it again
samux 1:473f339c54c1 20 while(1) {
samux 1:473f339c54c1 21
samux 4:f8a5c8aa895a 22 // append a file
samux 1:473f339c54c1 23 FILE * fp = fopen("/usb/test1.txt", "a");
samux 1:473f339c54c1 24
samux 1:473f339c54c1 25 if (fp != NULL) {
samux 1:473f339c54c1 26 fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++);
samux 1:473f339c54c1 27 printf("Goodbye World!\r\n");
samux 1:473f339c54c1 28 fclose(fp);
samux 1:473f339c54c1 29 } else {
samux 1:473f339c54c1 30 printf("FILE == NULL\r\n");
samux 1:473f339c54c1 31 }
samux 1:473f339c54c1 32
samux 0:0d68fe822228 33 Thread::wait(500);
samux 0:0d68fe822228 34
samux 1:473f339c54c1 35 // if device disconnected, try to connect again
samux 1:473f339c54c1 36 if (!msd.connected())
samux 1:473f339c54c1 37 break;
samux 0:0d68fe822228 38 }
samux 1:473f339c54c1 39
samux 0:0d68fe822228 40 }
samux 0:0d68fe822228 41 }
samux 0:0d68fe822228 42
samux 0:0d68fe822228 43
samux 0:0d68fe822228 44 int main() {
samux 2:3e3df7a79050 45 Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4);
samux 0:0d68fe822228 46 while(1) {
samux 0:0d68fe822228 47 led=!led;
samux 0:0d68fe822228 48 Thread::wait(500);
samux 0:0d68fe822228 49 }
samux 0:0d68fe822228 50 }