Ye Cheng
/
cmsis_rtos_demo_thread
cmsis rtos demo
Revision 1:cbda4d713dc8, committed 2013-01-06
- Comitter:
- cnhzcy14
- Date:
- Sun Jan 06 15:03:57 2013 +0000
- Parent:
- 0:618ffeb1dfc5
- Commit message:
- comments
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 618ffeb1dfc5 -r cbda4d713dc8 main.cpp --- a/main.cpp Sun Jan 06 12:39:37 2013 +0000 +++ b/main.cpp Sun Jan 06 15:03:57 2013 +0000 @@ -1,7 +1,19 @@ +/****************************************************************************** +* DESCRIPTION: +* A "hello world" CMSIS RTOS program which demonstrates another safe way +* to pass arguments to threads during thread creation. In this case, +* a structure is used to pass multiple arguments. +* AUTHOR: Blaise Barney +* MODIFICATOR: (Simon) CHENG Ye +* LAST REVISED: 06/JAN/2013 +******************************************************************************/ + #include "mbed.h" #include "cmsis_os.h" #define NUM_THREADS 8 + +Serial debug(USBTX, USBRX); // For mbed debug by serial port. char *messages[NUM_THREADS]; struct thread_data @@ -10,9 +22,7 @@ int sum; char *message; }; - struct thread_data thread_data_array[NUM_THREADS]; -Serial debug(USBTX, USBRX); void PrintHello(void const *threadarg) { @@ -31,7 +41,6 @@ osThreadTerminate(id); } - void t0(void const *argument) {PrintHello(argument);} osThreadDef(t0, osPriorityNormal, DEFAULT_STACK_SIZE); @@ -56,7 +65,8 @@ void t7(void const *argument) {PrintHello(argument);} osThreadDef(t7, osPriorityNormal, DEFAULT_STACK_SIZE); -int main() { +int main() +{ debug.baud(57600); int t, sum; @@ -69,8 +79,9 @@ messages[5] = "Russian: Zdravstvytye, mir!"; messages[6] = "Japan: Sekai e konnichiwa!"; messages[7] = "Latin: Orbis, te saluto!"; - - for(t=0;t<NUM_THREADS;t++) { + + for(t=0;t<NUM_THREADS;t++) + { sum = sum + t; thread_data_array[t].thread_id = t; thread_data_array[t].sum = sum;