Simple RTOS example with a thread writing to an SD card, requiring custom stack size
Dependencies: fat mbed SDFileSystem
Revision 0:754abc1f45da, committed 2012-03-07
- Comitter:
- emilmont
- Date:
- Wed Mar 07 10:08:58 2012 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r 754abc1f45da SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Wed Mar 07 10:08:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/SDFileSystem/#b1ddfc9a9b25
diff -r 000000000000 -r 754abc1f45da fat.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fat.lib Wed Mar 07 10:08:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/fat/#208803a150b2
diff -r 000000000000 -r 754abc1f45da main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 07 10:08:58 2012 +0000 @@ -0,0 +1,31 @@ +#include "mbed.h" +#include "rtos.h" +#include "SDFileSystem.h" + +DigitalOut led1(LED1); +DigitalOut led2(LED2); + +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); + } +} + +int main() { + Thread t(sd_thread, NULL, osPriorityNormal, (DEFAULT_STACK_SIZE * 2.25)); + + while (true) { + led1 = !led1; + Thread::wait(1000); + } +}
diff -r 000000000000 -r 754abc1f45da mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Mar 07 10:08:58 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4c0c40fd0593