Test program with networking part in RTOS-thread and SD in RTOS-thread
Dependencies: fat mbed mbed-rtos EthernetInterface SDFileSystem
Fork of Network-RTOS by
Diff: main.cpp
- Revision:
- 1:5a71a8a0463b
- Parent:
- 0:7a6d4b87941e
--- a/main.cpp Sun Jul 22 09:29:28 2012 +0000 +++ b/main.cpp Sun Jul 22 12:51:41 2012 +0000 @@ -1,5 +1,7 @@ #include "mbed.h" #include "EthernetInterface.h" +#include "SDFileSystem.h" +#include "rtos.h" #include "cmsis_os.h" DigitalOut led1(LED1); @@ -44,15 +46,30 @@ osDelay(500); } } - +void sd_thread(void const *argument) { + SDFileSystem sd(p5, p6, p7, p8, "sd"); + FILE *f = fopen("/sd/out.txt", "w"); + for (int i=0; i<30; i++) { + fprintf(f, "%d\n", i); + printf("%d\n\r", i); + } + printf("closing\n"); + fclose(f); + + while (true) { + led2 = !led2; + Thread::wait(1000); + } +} osThreadDef(led2_thread, osPriorityNormal, DEFAULT_STACK_SIZE); osThreadDef(net_thread, osPriorityNormal, DEFAULT_STACK_SIZE); +osThreadDef(sd_thread, osPriorityNormal, (int)(DEFAULT_STACK_SIZE * 2.25)); int main() { osThreadCreate(osThread(led2_thread), NULL); - osThreadCreate(osThread(net_thread), NULL); - + osThreadCreate(osThread(sd_thread), NULL); + while (true) { led1 = !led1; osDelay(500);