![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
wave player pwm & covox
Dependencies: wave_player_pwm_and_covox mbed USBHost
main.cpp@0:0d68fe822228, 2013-03-06 (annotated)
- Committer:
- samux
- Date:
- Wed Mar 06 17:06:56 2013 +0000
- Revision:
- 0:0d68fe822228
- Child:
- 1:473f339c54c1
USBHostMSD Hello World
Who changed what in which revision?
User | Revision | Line number | New 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 | 0:0d68fe822228 | 13 | // try to connect a USB flash disk |
samux | 0:0d68fe822228 | 14 | while(!msd.connect()) |
samux | 0:0d68fe822228 | 15 | Thread::wait(500); |
samux | 0:0d68fe822228 | 16 | |
samux | 0:0d68fe822228 | 17 | FILE * fp = fopen("/usb/test.txt", "a"); |
samux | 0:0d68fe822228 | 18 | |
samux | 0:0d68fe822228 | 19 | if (fp != NULL) { |
samux | 0:0d68fe822228 | 20 | fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++); |
samux | 0:0d68fe822228 | 21 | printf("Goodbye World!\r\n"); |
samux | 0:0d68fe822228 | 22 | fclose(fp); |
samux | 0:0d68fe822228 | 23 | } else { |
samux | 0:0d68fe822228 | 24 | printf("FILE == NULL\r\n"); |
samux | 0:0d68fe822228 | 25 | } |
samux | 0:0d68fe822228 | 26 | |
samux | 0:0d68fe822228 | 27 | // wait until the msd disk is disconnected |
samux | 0:0d68fe822228 | 28 | while(msd.connected()) |
samux | 0:0d68fe822228 | 29 | Thread::wait(500); |
samux | 0:0d68fe822228 | 30 | } |
samux | 0:0d68fe822228 | 31 | } |
samux | 0:0d68fe822228 | 32 | |
samux | 0:0d68fe822228 | 33 | |
samux | 0:0d68fe822228 | 34 | int main() { |
samux | 0:0d68fe822228 | 35 | Thread msdTask(msd_task, NULL, osPriorityNormal, (1024+512) * 4); |
samux | 0:0d68fe822228 | 36 | while(1) { |
samux | 0:0d68fe822228 | 37 | led=!led; |
samux | 0:0d68fe822228 | 38 | Thread::wait(500); |
samux | 0:0d68fe822228 | 39 | } |
samux | 0:0d68fe822228 | 40 | } |