sd & rtos & serial test
Dependencies: SDFileSystem mbed-rtos mbed
main.cpp@1:0714787a8824, 2013-01-28 (annotated)
- Committer:
- tetuomin
- Date:
- Mon Jan 28 08:28:11 2013 +0000
- Revision:
- 1:0714787a8824
- Parent:
- 0:8aef073b3e23
thread added for sd
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
tetuomin | 0:8aef073b3e23 | 1 | #include "mbed.h" |
tetuomin | 0:8aef073b3e23 | 2 | #include "rtos.h" |
tetuomin | 0:8aef073b3e23 | 3 | #include "SDFileSystem.h" |
tetuomin | 0:8aef073b3e23 | 4 | |
tetuomin | 0:8aef073b3e23 | 5 | #define FILE_LOC "/sd/test.txt" |
tetuomin | 0:8aef073b3e23 | 6 | |
tetuomin | 0:8aef073b3e23 | 7 | Serial pc(USBTX, USBRX); |
tetuomin | 0:8aef073b3e23 | 8 | Serial gps(p28, p27); |
tetuomin | 0:8aef073b3e23 | 9 | Serial test(p9,p10); |
tetuomin | 0:8aef073b3e23 | 10 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
tetuomin | 0:8aef073b3e23 | 11 | DigitalOut myled(LED1); |
tetuomin | 1:0714787a8824 | 12 | DigitalOut sdled(LED2); |
tetuomin | 1:0714787a8824 | 13 | |
tetuomin | 1:0714787a8824 | 14 | void sd_thread(void const *argument) { |
tetuomin | 1:0714787a8824 | 15 | while(1){ |
tetuomin | 1:0714787a8824 | 16 | sdled = !sdled; |
tetuomin | 1:0714787a8824 | 17 | FILE *fp = NULL; |
tetuomin | 1:0714787a8824 | 18 | fp = fopen(FILE_LOC, "w"); |
tetuomin | 1:0714787a8824 | 19 | if( fp != NULL ) fclose(fp); |
tetuomin | 1:0714787a8824 | 20 | Thread::wait(1000); |
tetuomin | 1:0714787a8824 | 21 | } |
tetuomin | 1:0714787a8824 | 22 | } |
tetuomin | 0:8aef073b3e23 | 23 | |
tetuomin | 0:8aef073b3e23 | 24 | int main() { |
tetuomin | 0:8aef073b3e23 | 25 | |
tetuomin | 1:0714787a8824 | 26 | Thread sdTask(sd_thread, NULL, osPriorityNormal, DEFAULT_STACK_SIZE * 2.25); |
tetuomin | 0:8aef073b3e23 | 27 | while(1) { |
tetuomin | 0:8aef073b3e23 | 28 | myled = !myled; |
tetuomin | 0:8aef073b3e23 | 29 | Thread::wait(1000); |
tetuomin | 0:8aef073b3e23 | 30 | } |
tetuomin | 0:8aef073b3e23 | 31 | } |