dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 #include "mbed.h"
nexpaq 1:55a6170b404f 2 #include "greentea-client/test_env.h"
nexpaq 1:55a6170b404f 3 #include "rtos.h"
nexpaq 1:55a6170b404f 4
nexpaq 1:55a6170b404f 5 #if defined(MBED_RTOS_SINGLE_THREAD)
nexpaq 1:55a6170b404f 6 #error [NOT_SUPPORTED] test not supported
nexpaq 1:55a6170b404f 7 #endif
nexpaq 1:55a6170b404f 8
nexpaq 1:55a6170b404f 9 /*
nexpaq 1:55a6170b404f 10 * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and
nexpaq 1:55a6170b404f 11 * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
nexpaq 1:55a6170b404f 12 * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
nexpaq 1:55a6170b404f 13 */
nexpaq 1:55a6170b404f 14 #if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
nexpaq 1:55a6170b404f 15 #define STACK_SIZE DEFAULT_STACK_SIZE/2
nexpaq 1:55a6170b404f 16 #elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)
nexpaq 1:55a6170b404f 17 #define STACK_SIZE DEFAULT_STACK_SIZE/2
nexpaq 1:55a6170b404f 18 #elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
nexpaq 1:55a6170b404f 19 #define STACK_SIZE DEFAULT_STACK_SIZE/2
nexpaq 1:55a6170b404f 20 #elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
nexpaq 1:55a6170b404f 21 #define STACK_SIZE 512
nexpaq 1:55a6170b404f 22 #elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
nexpaq 1:55a6170b404f 23 #define STACK_SIZE 768
nexpaq 1:55a6170b404f 24 #elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO)
nexpaq 1:55a6170b404f 25 #define STACK_SIZE 1536
nexpaq 1:55a6170b404f 26 #elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
nexpaq 1:55a6170b404f 27 #define STACK_SIZE 768
nexpaq 1:55a6170b404f 28 #else
nexpaq 1:55a6170b404f 29 #define STACK_SIZE DEFAULT_STACK_SIZE
nexpaq 1:55a6170b404f 30 #endif
nexpaq 1:55a6170b404f 31
nexpaq 1:55a6170b404f 32 #define SIGNAL_PRINT_TICK 0x01
nexpaq 1:55a6170b404f 33
nexpaq 1:55a6170b404f 34 DigitalOut led1(LED1);
nexpaq 1:55a6170b404f 35
nexpaq 1:55a6170b404f 36 const int total_ticks = 10;
nexpaq 1:55a6170b404f 37
nexpaq 1:55a6170b404f 38 void print_tick_thread() {
nexpaq 1:55a6170b404f 39 for (int i = 0; i <= total_ticks; i++) {
nexpaq 1:55a6170b404f 40 Thread::signal_wait(SIGNAL_PRINT_TICK);
nexpaq 1:55a6170b404f 41 greentea_send_kv("tick", i);
nexpaq 1:55a6170b404f 42 led1 = !led1;
nexpaq 1:55a6170b404f 43 }
nexpaq 1:55a6170b404f 44 }
nexpaq 1:55a6170b404f 45
nexpaq 1:55a6170b404f 46 int main() {
nexpaq 1:55a6170b404f 47 GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto");
nexpaq 1:55a6170b404f 48
nexpaq 1:55a6170b404f 49 Thread tick_thread(osPriorityNormal, STACK_SIZE);
nexpaq 1:55a6170b404f 50 tick_thread.start(print_tick_thread);
nexpaq 1:55a6170b404f 51
nexpaq 1:55a6170b404f 52 for (int i = 0; i <= total_ticks; i++) {
nexpaq 1:55a6170b404f 53 Thread::wait(1000);
nexpaq 1:55a6170b404f 54 tick_thread.signal_set(SIGNAL_PRINT_TICK);
nexpaq 1:55a6170b404f 55 }
nexpaq 1:55a6170b404f 56
nexpaq 1:55a6170b404f 57 tick_thread.join();
nexpaq 1:55a6170b404f 58 GREENTEA_TESTSUITE_RESULT(1);
nexpaq 1:55a6170b404f 59 }