![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Acquire Sensor data and email
Dependencies: C12832_lcd EthernetInterface LM75B NTPClient SimpleSMTPClient TextLCD USBHost mbed
Fork of USBHost-MSD_HelloWorld by
main.cpp@2:3e3df7a79050, 2013-03-12 (annotated)
- Committer:
- samux
- Date:
- Tue Mar 12 17:35:32 2013 +0000
- Revision:
- 2:3e3df7a79050
- Parent:
- 1:473f339c54c1
- Child:
- 4:f8a5c8aa895a
reduce stack size
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 | 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 | 1:473f339c54c1 | 18 | while(1) { |
samux | 1:473f339c54c1 | 19 | |
samux | 1:473f339c54c1 | 20 | FILE * fp = fopen("/usb/test1.txt", "a"); |
samux | 1:473f339c54c1 | 21 | |
samux | 1:473f339c54c1 | 22 | if (fp != NULL) { |
samux | 1:473f339c54c1 | 23 | fprintf(fp, "Hello fun SD Card World: %d!\r\n", i++); |
samux | 1:473f339c54c1 | 24 | printf("Goodbye World!\r\n"); |
samux | 1:473f339c54c1 | 25 | fclose(fp); |
samux | 1:473f339c54c1 | 26 | } else { |
samux | 1:473f339c54c1 | 27 | printf("FILE == NULL\r\n"); |
samux | 1:473f339c54c1 | 28 | } |
samux | 1:473f339c54c1 | 29 | |
samux | 0:0d68fe822228 | 30 | Thread::wait(500); |
samux | 0:0d68fe822228 | 31 | |
samux | 1:473f339c54c1 | 32 | // if device disconnected, try to connect again |
samux | 1:473f339c54c1 | 33 | if (!msd.connected()) |
samux | 1:473f339c54c1 | 34 | break; |
samux | 0:0d68fe822228 | 35 | } |
samux | 1:473f339c54c1 | 36 | |
samux | 0:0d68fe822228 | 37 | } |
samux | 0:0d68fe822228 | 38 | } |
samux | 0:0d68fe822228 | 39 | |
samux | 0:0d68fe822228 | 40 | |
samux | 0:0d68fe822228 | 41 | int main() { |
samux | 2:3e3df7a79050 | 42 | Thread msdTask(msd_task, NULL, osPriorityNormal, 1024 * 4); |
samux | 0:0d68fe822228 | 43 | while(1) { |
samux | 0:0d68fe822228 | 44 | led=!led; |
samux | 0:0d68fe822228 | 45 | Thread::wait(500); |
samux | 0:0d68fe822228 | 46 | } |
samux | 0:0d68fe822228 | 47 | } |