Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

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