5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
TESTS/mbedmicro-rtos-mbed/basic/main.cpp@0:098463de4c5d, 2017-01-25 (annotated)
- Committer:
- group-onsemi
- Date:
- Wed Jan 25 20:34:15 2017 +0000
- Revision:
- 0:098463de4c5d
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-onsemi | 0:098463de4c5d | 1 | #include "mbed.h" |
group-onsemi | 0:098463de4c5d | 2 | #include "greentea-client/test_env.h" |
group-onsemi | 0:098463de4c5d | 3 | #include "rtos.h" |
group-onsemi | 0:098463de4c5d | 4 | |
group-onsemi | 0:098463de4c5d | 5 | #if defined(MBED_RTOS_SINGLE_THREAD) |
group-onsemi | 0:098463de4c5d | 6 | #error [NOT_SUPPORTED] test not supported |
group-onsemi | 0:098463de4c5d | 7 | #endif |
group-onsemi | 0:098463de4c5d | 8 | |
group-onsemi | 0:098463de4c5d | 9 | /* |
group-onsemi | 0:098463de4c5d | 10 | * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and |
group-onsemi | 0:098463de4c5d | 11 | * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes |
group-onsemi | 0:098463de4c5d | 12 | * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize. |
group-onsemi | 0:098463de4c5d | 13 | */ |
group-onsemi | 0:098463de4c5d | 14 | #if defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_GCC) |
group-onsemi | 0:098463de4c5d | 15 | #define STACK_SIZE DEFAULT_STACK_SIZE/2 |
group-onsemi | 0:098463de4c5d | 16 | #elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 17 | #define STACK_SIZE 512 |
group-onsemi | 0:098463de4c5d | 18 | #elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 19 | #define STACK_SIZE 768 |
group-onsemi | 0:098463de4c5d | 20 | #elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 21 | #define STACK_SIZE 1536 |
group-onsemi | 0:098463de4c5d | 22 | #elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832) |
group-onsemi | 0:098463de4c5d | 23 | #define STACK_SIZE 768 |
group-onsemi | 0:098463de4c5d | 24 | #elif defined(TARGET_XDOT_L151CC) |
group-onsemi | 0:098463de4c5d | 25 | #define STACK_SIZE 1024 |
group-onsemi | 0:098463de4c5d | 26 | #else |
group-onsemi | 0:098463de4c5d | 27 | #define STACK_SIZE DEFAULT_STACK_SIZE |
group-onsemi | 0:098463de4c5d | 28 | #endif |
group-onsemi | 0:098463de4c5d | 29 | |
group-onsemi | 0:098463de4c5d | 30 | #define SIGNAL_PRINT_TICK 0x01 |
group-onsemi | 0:098463de4c5d | 31 | |
group-onsemi | 0:098463de4c5d | 32 | DigitalOut led1(LED1); |
group-onsemi | 0:098463de4c5d | 33 | |
group-onsemi | 0:098463de4c5d | 34 | const int total_ticks = 10; |
group-onsemi | 0:098463de4c5d | 35 | |
group-onsemi | 0:098463de4c5d | 36 | void print_tick_thread() { |
group-onsemi | 0:098463de4c5d | 37 | for (int i = 0; i <= total_ticks; i++) { |
group-onsemi | 0:098463de4c5d | 38 | Thread::signal_wait(SIGNAL_PRINT_TICK); |
group-onsemi | 0:098463de4c5d | 39 | greentea_send_kv("tick", i); |
group-onsemi | 0:098463de4c5d | 40 | led1 = !led1; |
group-onsemi | 0:098463de4c5d | 41 | } |
group-onsemi | 0:098463de4c5d | 42 | } |
group-onsemi | 0:098463de4c5d | 43 | |
group-onsemi | 0:098463de4c5d | 44 | int main() { |
group-onsemi | 0:098463de4c5d | 45 | GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto"); |
group-onsemi | 0:098463de4c5d | 46 | |
group-onsemi | 0:098463de4c5d | 47 | Thread tick_thread(osPriorityNormal, STACK_SIZE); |
group-onsemi | 0:098463de4c5d | 48 | tick_thread.start(print_tick_thread); |
group-onsemi | 0:098463de4c5d | 49 | |
group-onsemi | 0:098463de4c5d | 50 | for (int i = 0; i <= total_ticks; i++) { |
group-onsemi | 0:098463de4c5d | 51 | Thread::wait(1000); |
group-onsemi | 0:098463de4c5d | 52 | tick_thread.signal_set(SIGNAL_PRINT_TICK); |
group-onsemi | 0:098463de4c5d | 53 | } |
group-onsemi | 0:098463de4c5d | 54 | |
group-onsemi | 0:098463de4c5d | 55 | tick_thread.join(); |
group-onsemi | 0:098463de4c5d | 56 | GREENTEA_TESTSUITE_RESULT(1); |
group-onsemi | 0:098463de4c5d | 57 | } |