mbed-rtos test programs for DISCO_F746NG. #Test for thread, mutex, semaphore, signals, queues, mail, ISR

Dependencies:   mbed-rtos mbed-src

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "test_env.h"
00003 #include "rtos.h"
00004 
00005 /********************
00006  * Switch test case
00007  ********************/
00008 #define TEST_84_BASIC
00009 //#define TEST_85_MUTEX
00010 //#define TEST_86_SEMAPHORE
00011 //#define TEST_87_SIGNALS
00012 //#define TEST_88_QUEUE
00013 //#define TEST_89_MAIL
00014 //#define TEST_90_TIMER
00015 //#define TEST_91_ISR
00016 
00017 #if defined(TEST_84_BASIC)
00018 
00019 /*
00020  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00021  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00022  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00023  */
00024 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
00025 #define STACK_SIZE DEFAULT_STACK_SIZE/2
00026 #elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)
00027 #define STACK_SIZE DEFAULT_STACK_SIZE/2
00028 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
00029 #define STACK_SIZE DEFAULT_STACK_SIZE/2
00030 #else
00031 #define STACK_SIZE DEFAULT_STACK_SIZE
00032 #endif
00033 
00034 void print_char(char c = '*') {
00035     printf("%c", c);
00036     fflush(stdout);
00037 }
00038 
00039 DigitalOut led1(LED1);
00040 DigitalOut led2(LED2);
00041 
00042 void led2_thread(void const *argument) {
00043     while (true) {
00044         led2 = !led2;
00045         Thread::wait(1000);
00046         print_char();
00047     }
00048 }
00049 
00050 int main() {
00051     MBED_HOSTTEST_TIMEOUT(15);
00052     MBED_HOSTTEST_SELECT(wait_us_auto);
00053     MBED_HOSTTEST_DESCRIPTION(Basic thread);
00054     MBED_HOSTTEST_START("RTOS_1");
00055 
00056     Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE);
00057 
00058     while (true) {
00059         led1 = !led1;
00060         Thread::wait(500);
00061     }
00062 }
00063 
00064 #elif defined(TEST_85_MUTEX)
00065 
00066 #define THREAD_DELAY     50
00067 #define SIGNALS_TO_EMIT  100
00068 
00069 /*
00070  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00071  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00072  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00073  */
00074 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
00075     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00076 #elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)
00077     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00078 #elif defined(TARGET_STM32F334R8) && defined(TOOLCHAIN_IAR)
00079     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00080 #elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR)
00081     #define STACK_SIZE DEFAULT_STACK_SIZE/4 
00082 #elif defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_IAR)
00083     #define STACK_SIZE DEFAULT_STACK_SIZE/2 
00084 #elif defined(TARGET_STM32F072RB) && defined(TOOLCHAIN_IAR)
00085     #define STACK_SIZE DEFAULT_STACK_SIZE/2 
00086 #elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR)
00087     #define STACK_SIZE DEFAULT_STACK_SIZE/2     
00088 #else
00089     #define STACK_SIZE DEFAULT_STACK_SIZE
00090 #endif
00091 
00092 void print_char(char c = '*') {
00093     printf("%c", c);
00094     fflush(stdout);
00095 }
00096 
00097 Mutex stdio_mutex;
00098 DigitalOut led(LED1);
00099 
00100 volatile int change_counter = 0;
00101 volatile bool changing_counter = false;
00102 volatile bool mutex_defect = false;
00103 
00104 bool manipulate_protected_zone(const int thread_delay) {
00105     bool result = true;
00106 
00107     stdio_mutex.lock(); // LOCK
00108     if (changing_counter == true) {
00109         // 'e' stands for error. If changing_counter is true access is not exclusively
00110         print_char('e');
00111         result = false;
00112         mutex_defect = true;
00113     }
00114     changing_counter = true;
00115 
00116     // Some action on protected
00117     led = !led;
00118     change_counter++;
00119     print_char('.');
00120     Thread::wait(thread_delay);
00121 
00122     changing_counter = false;
00123     stdio_mutex.unlock();   // UNLOCK
00124     return result;
00125 }
00126 
00127 void test_thread(void const *args) {
00128     const int thread_delay = int(args);
00129     while (true) {
00130         manipulate_protected_zone(thread_delay);
00131     }
00132 }
00133 
00134 int main() {
00135     MBED_HOSTTEST_TIMEOUT(20);
00136     MBED_HOSTTEST_SELECT(default);
00137     MBED_HOSTTEST_DESCRIPTION(Mutex resource lock);
00138     MBED_HOSTTEST_START("RTOS_2");
00139 
00140     const int t1_delay = THREAD_DELAY * 1;
00141     const int t2_delay = THREAD_DELAY * 2;
00142     const int t3_delay = THREAD_DELAY * 3;
00143     Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
00144     Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
00145 
00146     while (true) {
00147         // Thread 1 action
00148         Thread::wait(t1_delay);
00149         manipulate_protected_zone(t1_delay);
00150         if (change_counter >= SIGNALS_TO_EMIT or mutex_defect == true) {
00151             t2.terminate();
00152             t3.terminate();
00153             break;
00154         }
00155     }
00156 
00157     fflush(stdout);
00158     MBED_HOSTTEST_RESULT(!mutex_defect);
00159     return 0;
00160 }
00161 
00162 #elif defined(TEST_86_SEMAPHORE)
00163 
00164 #define THREAD_DELAY     75
00165 #define SEMAPHORE_SLOTS  2
00166 #define SEM_CHANGES      100
00167 
00168 /*
00169  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00170  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00171  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00172  */
00173 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
00174     #define STACK_SIZE DEFAULT_STACK_SIZE/16
00175 #elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)
00176     #define STACK_SIZE DEFAULT_STACK_SIZE/8
00177 #elif defined(TARGET_STM32F334R8) && (defined(TOOLCHAIN_GCC) || defined(TOOLCHAIN_IAR))
00178     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00179 #elif defined(TARGET_STM32F103RB) && defined(TOOLCHAIN_IAR)
00180     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00181 #elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR)
00182     #define STACK_SIZE DEFAULT_STACK_SIZE/4 
00183 #elif defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_IAR)
00184     #define STACK_SIZE DEFAULT_STACK_SIZE/2 
00185 #elif defined(TARGET_STM32F072RB) && defined(TOOLCHAIN_IAR)
00186     #define STACK_SIZE DEFAULT_STACK_SIZE/2 
00187 #elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR)
00188     #define STACK_SIZE DEFAULT_STACK_SIZE/2     
00189 #else
00190     #define STACK_SIZE DEFAULT_STACK_SIZE
00191 #endif
00192 
00193 void print_char(char c = '*') {
00194     printf("%c", c);
00195     fflush(stdout);
00196 }
00197 
00198 #define ORIGINAL 1
00199 #undef ORIGINAL
00200 
00201 #if ORIGINAL
00202 Semaphore two_slots(SEMAPHORE_SLOTS);
00203 #else
00204 Semaphore *two_slots;
00205 #endif
00206 
00207 volatile int change_counter = 0;
00208 volatile int sem_counter = 0;
00209 volatile bool sem_defect = false;
00210 
00211 void test_thread(void const *delay) {
00212     const int thread_delay = int(delay);
00213     while (true) {
00214 #if ORIGINAL
00215         two_slots.wait();
00216 #else
00217         two_slots->wait();
00218 #endif
00219         sem_counter++;
00220         const bool sem_lock_failed = sem_counter > SEMAPHORE_SLOTS;
00221         const char msg = sem_lock_failed ? 'e' : sem_counter + '0';
00222         print_char(msg);
00223         if (sem_lock_failed) {
00224             sem_defect = true;
00225         }
00226         Thread::wait(thread_delay);
00227         print_char('.');
00228         sem_counter--;
00229         change_counter++;
00230 #if ORIGINAL
00231         two_slots.release();
00232 #else
00233         two_slots->release();
00234 #endif
00235     }
00236 }
00237 
00238 int main (void) {
00239 
00240 #ifndef ORIGINAL
00241     two_slots = new Semaphore(SEMAPHORE_SLOTS);
00242 #endif
00243 
00244     MBED_HOSTTEST_TIMEOUT(20);
00245     MBED_HOSTTEST_SELECT(default_auto);
00246     MBED_HOSTTEST_DESCRIPTION(Semaphore resource lock);
00247     MBED_HOSTTEST_START("RTOS_3");
00248 
00249     const int t1_delay = THREAD_DELAY * 1;
00250     const int t2_delay = THREAD_DELAY * 2;
00251     const int t3_delay = THREAD_DELAY * 3;
00252     Thread t1(test_thread, (void *)t1_delay, osPriorityNormal, STACK_SIZE);
00253     Thread t2(test_thread, (void *)t2_delay, osPriorityNormal, STACK_SIZE);
00254     Thread t3(test_thread, (void *)t3_delay, osPriorityNormal, STACK_SIZE);
00255 
00256     while (true) {
00257         if (change_counter >= SEM_CHANGES or sem_defect == true) {
00258             t1.terminate();
00259             t2.terminate();
00260             t3.terminate();
00261             break;
00262         }
00263     }
00264 
00265     fflush(stdout);
00266     MBED_HOSTTEST_RESULT(!sem_defect);
00267     return 0;
00268 }
00269 
00270 #elif defined(TEST_87_SIGNALS)
00271 
00272 #define SIGNALS_TO_EMIT     100
00273 #define SIGNAL_HANDLE_DELEY 25
00274 #define SIGNAL_SET_VALUE    0x01
00275 
00276 /*
00277  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00278  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00279  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00280  */
00281 #if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
00282     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00283 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
00284     #define STACK_SIZE DEFAULT_STACK_SIZE/2
00285 #else
00286     #define STACK_SIZE DEFAULT_STACK_SIZE
00287 #endif
00288 
00289 DigitalOut led(LED1);
00290 volatile int signal_counter = 0;
00291 
00292 void led_thread(void const *argument) {
00293     while (true) {
00294         // Signal flags that are reported as event are automatically cleared.
00295         Thread::signal_wait(SIGNAL_SET_VALUE);
00296         led = !led;
00297         signal_counter++;
00298     }
00299 }
00300 
00301 int main (void) {
00302     MBED_HOSTTEST_TIMEOUT(20);
00303     MBED_HOSTTEST_SELECT(default_auto);
00304     MBED_HOSTTEST_DESCRIPTION(Signals messaging);
00305     MBED_HOSTTEST_START("RTOS_4");
00306 
00307     Thread thread(led_thread, NULL, osPriorityNormal, STACK_SIZE);
00308     bool result = true;
00309 
00310     while (true) {
00311         Thread::wait(2 * SIGNAL_HANDLE_DELEY);
00312         thread.signal_set(SIGNAL_SET_VALUE);
00313         if (signal_counter == SIGNALS_TO_EMIT) {
00314             printf("Handled %d signals\r\n", signal_counter);
00315             break;
00316         }
00317     }
00318     MBED_HOSTTEST_RESULT(result);
00319     return 0;
00320 }
00321 
00322 #elif defined(TEST_88_QUEUE)
00323 
00324 typedef struct {
00325     float    voltage;   /* AD result of measured voltage */
00326     float    current;   /* AD result of measured current */
00327     uint32_t counter;   /* A counter value               */
00328 } message_t;
00329 
00330 #define CREATE_VOLTAGE(COUNTER) (COUNTER * 0.1) * 33
00331 #define CREATE_CURRENT(COUNTER) (COUNTER * 0.1) * 11
00332 #define QUEUE_SIZE       16
00333 #define QUEUE_PUT_DELAY  100
00334 
00335 /*
00336  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00337  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00338  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00339  */
00340 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
00341     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00342 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_GCC)
00343     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00344 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
00345     #define STACK_SIZE DEFAULT_STACK_SIZE/2
00346 #else
00347     #define STACK_SIZE DEFAULT_STACK_SIZE
00348 #endif
00349 
00350 MemoryPool<message_t, QUEUE_SIZE> mpool;
00351 Queue<message_t, QUEUE_SIZE> queue;
00352 
00353 /* Send Thread */
00354 void send_thread (void const *argument) {
00355     static uint32_t i = 10;
00356     while (true) {
00357         i++; // Fake data update
00358         message_t *message = mpool.alloc();
00359         message->voltage = CREATE_VOLTAGE(i);
00360         message->current = CREATE_CURRENT(i);
00361         message->counter = i;
00362         queue.put(message);
00363         Thread::wait(QUEUE_PUT_DELAY);
00364     }
00365 }
00366 
00367 int main (void) {
00368     MBED_HOSTTEST_TIMEOUT(20);
00369     MBED_HOSTTEST_SELECT(default_auto);
00370     MBED_HOSTTEST_DESCRIPTION(Queue messaging);
00371     MBED_HOSTTEST_START("RTOS_5");
00372 
00373     Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
00374     bool result = true;
00375     int result_counter = 0;
00376 
00377     while (true) {
00378         osEvent evt = queue.get();
00379         if (evt.status == osEventMessage) {
00380             message_t *message = (message_t*)evt.value.p;
00381             const float expected_voltage = CREATE_VOLTAGE(message->counter);
00382             const float expected_current = CREATE_CURRENT(message->counter);
00383             // Check using macros if received values correspond to values sent via queue
00384             bool expected_values = (expected_voltage == message->voltage) &&
00385                                    (expected_current == message->current);
00386             result = result && expected_values;
00387             const char *result_msg = expected_values ? "OK" : "FAIL";
00388             printf("%3d %.2fV %.2fA ... [%s]\r\n", message->counter,
00389                                                    message->voltage,
00390                                                    message->current,
00391                                                    result_msg);
00392             mpool.free(message);
00393             if (result == false || ++result_counter == QUEUE_SIZE) {
00394                 break;
00395             }
00396         }
00397     }
00398     MBED_HOSTTEST_RESULT(result);
00399     return 0;
00400 }
00401 
00402 #elif defined(TEST_89_MAIL)
00403 
00404 typedef struct {
00405     float    voltage;   /* AD result of measured voltage */
00406     float    current;   /* AD result of measured current */
00407     uint32_t counter;   /* A counter value               */
00408 } mail_t;
00409 
00410 #define CREATE_VOLTAGE(COUNTER) (COUNTER * 0.1) * 33
00411 #define CREATE_CURRENT(COUNTER) (COUNTER * 0.1) * 11
00412 #define QUEUE_SIZE       16
00413 #define QUEUE_PUT_DELAY  100
00414 
00415 /*
00416  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00417  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00418  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00419  */
00420 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
00421     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00422 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_GCC)
00423     #define STACK_SIZE DEFAULT_STACK_SIZE/2
00424 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
00425     #define STACK_SIZE DEFAULT_STACK_SIZE/2
00426 #else
00427     #define STACK_SIZE DEFAULT_STACK_SIZE
00428 #endif
00429 
00430 Mail<mail_t, QUEUE_SIZE> mail_box;
00431 
00432 void send_thread (void const *argument) {
00433     static uint32_t i = 10;
00434     while (true) {
00435         i++; // fake data update
00436         mail_t *mail = mail_box.alloc();
00437         mail->voltage = CREATE_VOLTAGE(i);
00438         mail->current = CREATE_CURRENT(i);
00439         mail->counter = i;
00440         mail_box.put(mail);
00441         Thread::wait(QUEUE_PUT_DELAY);
00442     }
00443 }
00444 
00445 int main (void) {
00446     MBED_HOSTTEST_TIMEOUT(20);
00447     MBED_HOSTTEST_SELECT(default_auto);
00448     MBED_HOSTTEST_DESCRIPTION(Mail messaging);
00449     MBED_HOSTTEST_START("RTOS_6");
00450 
00451     Thread thread(send_thread, NULL, osPriorityNormal, STACK_SIZE);
00452     bool result = true;
00453     int result_counter = 0;
00454 
00455     while (true) {
00456         osEvent evt = mail_box.get();
00457         if (evt.status == osEventMail) {
00458             mail_t *mail = (mail_t*)evt.value.p;
00459             const float expected_voltage = CREATE_VOLTAGE(mail->counter);
00460             const float expected_current = CREATE_CURRENT(mail->counter);
00461             // Check using macros if received values correspond to values sent via queue
00462             bool expected_values = (expected_voltage == mail->voltage) &&
00463                                    (expected_current == mail->current);
00464             result = result && expected_values;
00465             const char *result_msg = expected_values ? "OK" : "FAIL";
00466             printf("%3d %.2fV %.2fA ... [%s]\r\n", mail->counter,
00467                                                    mail->voltage,
00468                                                    mail->current,
00469                                                    result_msg);
00470             mail_box.free(mail);
00471             if (result == false || ++result_counter == QUEUE_SIZE) {
00472                 break;
00473             }
00474         }
00475     }
00476     MBED_HOSTTEST_RESULT(result);
00477     return 0;
00478 }
00479 
00480 #elif defined(TEST_90_TIMER)
00481 
00482 DigitalOut LEDs[4] = {
00483     DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4)
00484 };
00485 
00486 void print_char(char c = '*')
00487 {
00488     printf("%c", c);
00489     fflush(stdout);
00490 }
00491 
00492 void blink(void const *n) {
00493     static int counter = 0;
00494     const int led_id = int(n);
00495     LEDs[led_id] = !LEDs[led_id];
00496     if (++counter == 75) {
00497         print_char();
00498         counter = 0;
00499     }
00500 }
00501 
00502 int main(void) {
00503     MBED_HOSTTEST_TIMEOUT(15);
00504     MBED_HOSTTEST_SELECT(wait_us_auto);
00505     MBED_HOSTTEST_DESCRIPTION(Timer);
00506     MBED_HOSTTEST_START("RTOS_7");
00507 
00508     RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
00509     RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
00510     RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
00511     RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);
00512 
00513     led_1_timer.start(200);
00514     led_2_timer.start(100);
00515     led_3_timer.start(50);
00516     led_4_timer.start(25);
00517 
00518     Thread::wait(osWaitForever);
00519 }
00520 
00521 #elif defined(TEST_91_ISR)
00522 
00523 #define QUEUE_SIZE              5
00524 #define THREAD_DELAY            250
00525 #define QUEUE_PUT_ISR_VALUE     128
00526 #define QUEUE_PUT_THREAD_VALUE  127
00527 
00528 /*
00529  * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
00530  * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
00531  * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
00532  */
00533 #if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
00534     #define STACK_SIZE DEFAULT_STACK_SIZE/4
00535 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
00536     #define STACK_SIZE DEFAULT_STACK_SIZE/2
00537 #else
00538     #define STACK_SIZE DEFAULT_STACK_SIZE
00539 #endif
00540 
00541 Queue<uint32_t, QUEUE_SIZE> queue;
00542 
00543 DigitalOut myled(LED1);
00544 
00545 void queue_isr() {
00546 
00547     queue.put((uint32_t*)QUEUE_PUT_ISR_VALUE);
00548     myled = !myled;
00549 }
00550 
00551 void queue_thread(void const *argument) {
00552     while (true) {
00553         queue.put((uint32_t*)QUEUE_PUT_THREAD_VALUE);
00554         Thread::wait(THREAD_DELAY);
00555     }
00556 }
00557 
00558 int main (void) {
00559     MBED_HOSTTEST_TIMEOUT(20);
00560     MBED_HOSTTEST_SELECT(default_auto);
00561     MBED_HOSTTEST_DESCRIPTION(ISR (Queue));
00562     MBED_HOSTTEST_START("RTOS_8");
00563 
00564     Thread thread(queue_thread, NULL, osPriorityNormal, STACK_SIZE);
00565     Ticker ticker;
00566     ticker.attach(queue_isr, 1.0);
00567     int isr_puts_counter = 0;
00568     bool result = true;
00569 
00570     while (true) {
00571         osEvent evt = queue.get();
00572         if (evt.status != osEventMessage) {
00573             printf("QUEUE_GET: Status(0x%02X) ... [FAIL]\r\n", evt.status);
00574             result = false;
00575             break;
00576         } else {
00577             printf("QUEUE_GET: Value(%u) ... [OK]\r\n", evt.value.v);
00578             if (evt.value.v == QUEUE_PUT_ISR_VALUE) {
00579                 isr_puts_counter++;
00580             }
00581             if (isr_puts_counter >= QUEUE_SIZE) {
00582                 break;
00583             }
00584         }
00585     }
00586 
00587     MBED_HOSTTEST_RESULT(result);
00588     return 0;
00589 }
00590 
00591 #endif