![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
experiment_with_rtos
Fork of rtos_basic by
main.cpp@7:b07c8d0ff3e5, 2014-10-09 (annotated)
- Committer:
- foivosHrist
- Date:
- Thu Oct 09 23:14:12 2014 +0000
- Revision:
- 7:b07c8d0ff3e5
- Parent:
- 3:c92e21f305d8
experiment code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 1:491820ee784d | 1 | #include "mbed.h" |
emilmont | 1:491820ee784d | 2 | #include "rtos.h" |
foivosHrist | 7:b07c8d0ff3e5 | 3 | //#include <string> |
foivosHrist | 7:b07c8d0ff3e5 | 4 | |
emilmont | 1:491820ee784d | 5 | DigitalOut led2(LED2); |
foivosHrist | 7:b07c8d0ff3e5 | 6 | Serial pc(USBTX, USBRX); |
foivosHrist | 7:b07c8d0ff3e5 | 7 | |
foivosHrist | 7:b07c8d0ff3e5 | 8 | //string mes; |
foivosHrist | 7:b07c8d0ff3e5 | 9 | |
foivosHrist | 7:b07c8d0ff3e5 | 10 | struct argStruct{ |
foivosHrist | 7:b07c8d0ff3e5 | 11 | int delay; |
foivosHrist | 7:b07c8d0ff3e5 | 12 | int message; |
foivosHrist | 7:b07c8d0ff3e5 | 13 | }initArgs; |
emilmont | 1:491820ee784d | 14 | |
foivosHrist | 7:b07c8d0ff3e5 | 15 | |
foivosHrist | 7:b07c8d0ff3e5 | 16 | //-------------------------------- |
emilmont | 3:c92e21f305d8 | 17 | void led2_thread(void const *args) { |
foivosHrist | 7:b07c8d0ff3e5 | 18 | |
foivosHrist | 7:b07c8d0ff3e5 | 19 | argStruct* rcvArgs=(argStruct*)args; |
foivosHrist | 7:b07c8d0ff3e5 | 20 | pc.printf("delay=%d message=%d\n",rcvArgs->delay,rcvArgs->message); |
emilmont | 1:491820ee784d | 21 | while (true) { |
emilmont | 1:491820ee784d | 22 | led2 = !led2; |
foivosHrist | 7:b07c8d0ff3e5 | 23 | Thread::wait(rcvArgs->delay); |
emilmont | 1:491820ee784d | 24 | } |
emilmont | 1:491820ee784d | 25 | } |
foivosHrist | 7:b07c8d0ff3e5 | 26 | //---------------------------------- |
emilmont | 1:491820ee784d | 27 | int main() { |
foivosHrist | 7:b07c8d0ff3e5 | 28 | pc.printf("START!\n"); |
foivosHrist | 7:b07c8d0ff3e5 | 29 | initArgs.delay=300; |
foivosHrist | 7:b07c8d0ff3e5 | 30 | initArgs.message=111; |
emilmont | 1:491820ee784d | 31 | |
foivosHrist | 7:b07c8d0ff3e5 | 32 | //led2_thread(&initArgs); //<--this instead of the below line works fine |
foivosHrist | 7:b07c8d0ff3e5 | 33 | Thread thread(led2_thread,&initArgs); |
foivosHrist | 7:b07c8d0ff3e5 | 34 | pc.printf("END!\n"); |
foivosHrist | 7:b07c8d0ff3e5 | 35 | |
emilmont | 1:491820ee784d | 36 | } |