5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
TESTS/mbedmicro-rtos-mbed/signals/main.cpp@1:f30bdcd2b33b, 2017-02-27 (annotated)
- Committer:
- jacobjohnson
- Date:
- Mon Feb 27 17:45:05 2017 +0000
- Revision:
- 1:f30bdcd2b33b
- Parent:
- 0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c. This will need to be changed later, and accessed from the main level, but for now this allows the adc to read a value from 0 to 3.7V, instead of just up to 1V.;
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 | #define SIGNAL_SET_VALUE 0x01 |
group-onsemi | 0:098463de4c5d | 10 | const int SIGNALS_TO_EMIT = 100; |
group-onsemi | 0:098463de4c5d | 11 | const int SIGNAL_HANDLE_DELEY = 25; |
group-onsemi | 0:098463de4c5d | 12 | |
group-onsemi | 0:098463de4c5d | 13 | /* |
group-onsemi | 0:098463de4c5d | 14 | * The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and |
group-onsemi | 0:098463de4c5d | 15 | * the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes |
group-onsemi | 0:098463de4c5d | 16 | * and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize. |
group-onsemi | 0:098463de4c5d | 17 | */ |
group-onsemi | 0:098463de4c5d | 18 | #if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 19 | #define STACK_SIZE 512 |
group-onsemi | 0:098463de4c5d | 20 | #elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 21 | #define STACK_SIZE 768 |
group-onsemi | 0:098463de4c5d | 22 | #elif (defined(TARGET_EFM32GG_STK3700)) && !defined(TOOLCHAIN_ARM_MICRO) |
group-onsemi | 0:098463de4c5d | 23 | #define STACK_SIZE 1536 |
group-onsemi | 0:098463de4c5d | 24 | #elif defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832) |
group-onsemi | 0:098463de4c5d | 25 | #define STACK_SIZE 768 |
group-onsemi | 0:098463de4c5d | 26 | #elif defined(TARGET_XDOT_L151CC) |
group-onsemi | 0:098463de4c5d | 27 | #define STACK_SIZE 1024 |
group-onsemi | 0:098463de4c5d | 28 | #else |
group-onsemi | 0:098463de4c5d | 29 | #define STACK_SIZE DEFAULT_STACK_SIZE |
group-onsemi | 0:098463de4c5d | 30 | #endif |
group-onsemi | 0:098463de4c5d | 31 | |
group-onsemi | 0:098463de4c5d | 32 | DigitalOut led(LED1); |
group-onsemi | 0:098463de4c5d | 33 | int signal_counter = 0; |
group-onsemi | 0:098463de4c5d | 34 | |
group-onsemi | 0:098463de4c5d | 35 | void led_thread() { |
group-onsemi | 0:098463de4c5d | 36 | while (true) { |
group-onsemi | 0:098463de4c5d | 37 | // Signal flags that are reported as event are automatically cleared. |
group-onsemi | 0:098463de4c5d | 38 | Thread::signal_wait(SIGNAL_SET_VALUE); |
group-onsemi | 0:098463de4c5d | 39 | led = !led; |
group-onsemi | 0:098463de4c5d | 40 | signal_counter++; |
group-onsemi | 0:098463de4c5d | 41 | } |
group-onsemi | 0:098463de4c5d | 42 | } |
group-onsemi | 0:098463de4c5d | 43 | |
group-onsemi | 0:098463de4c5d | 44 | int main (void) { |
group-onsemi | 0:098463de4c5d | 45 | GREENTEA_SETUP(20, "default_auto"); |
group-onsemi | 0:098463de4c5d | 46 | |
group-onsemi | 0:098463de4c5d | 47 | Thread thread(osPriorityNormal, STACK_SIZE); |
group-onsemi | 0:098463de4c5d | 48 | thread.start(led_thread); |
group-onsemi | 0:098463de4c5d | 49 | bool result = false; |
group-onsemi | 0:098463de4c5d | 50 | |
group-onsemi | 0:098463de4c5d | 51 | printf("Handling %d signals...\r\n", SIGNALS_TO_EMIT); |
group-onsemi | 0:098463de4c5d | 52 | |
group-onsemi | 0:098463de4c5d | 53 | while (true) { |
group-onsemi | 0:098463de4c5d | 54 | Thread::wait(2 * SIGNAL_HANDLE_DELEY); |
group-onsemi | 0:098463de4c5d | 55 | thread.signal_set(SIGNAL_SET_VALUE); |
group-onsemi | 0:098463de4c5d | 56 | if (signal_counter == SIGNALS_TO_EMIT) { |
group-onsemi | 0:098463de4c5d | 57 | printf("Handled %d signals\r\n", signal_counter); |
group-onsemi | 0:098463de4c5d | 58 | result = true; |
group-onsemi | 0:098463de4c5d | 59 | break; |
group-onsemi | 0:098463de4c5d | 60 | } |
group-onsemi | 0:098463de4c5d | 61 | } |
group-onsemi | 0:098463de4c5d | 62 | GREENTEA_TESTSUITE_RESULT(result); |
group-onsemi | 0:098463de4c5d | 63 | return 0; |
group-onsemi | 0:098463de4c5d | 64 | } |