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 int total_ticks = 10;
switches 0:5c4d7b2438d3 10 volatile int current_tick = 0;
switches 0:5c4d7b2438d3 11
switches 0:5c4d7b2438d3 12 DigitalOut LEDs[4] = {
switches 0:5c4d7b2438d3 13 DigitalOut(LED1), DigitalOut(LED2), DigitalOut(LED3), DigitalOut(LED4)
switches 0:5c4d7b2438d3 14 };
switches 0:5c4d7b2438d3 15
switches 0:5c4d7b2438d3 16 void blink(void const *n) {
switches 0:5c4d7b2438d3 17 static int blink_counter = 0;
switches 0:5c4d7b2438d3 18 const int led_id = int(n);
switches 0:5c4d7b2438d3 19 LEDs[led_id] = !LEDs[led_id];
switches 0:5c4d7b2438d3 20 if (++blink_counter == 75 && current_tick <= total_ticks) {
switches 0:5c4d7b2438d3 21 greentea_send_kv("tick", current_tick++);
switches 0:5c4d7b2438d3 22 blink_counter = 0;
switches 0:5c4d7b2438d3 23 }
switches 0:5c4d7b2438d3 24 }
switches 0:5c4d7b2438d3 25
switches 0:5c4d7b2438d3 26 int main(void) {
switches 0:5c4d7b2438d3 27 GREENTEA_SETUP(total_ticks + 5, "timing_drift_auto");
switches 0:5c4d7b2438d3 28
switches 0:5c4d7b2438d3 29 RtosTimer led_1_timer(blink, osTimerPeriodic, (void *)0);
switches 0:5c4d7b2438d3 30 RtosTimer led_2_timer(blink, osTimerPeriodic, (void *)1);
switches 0:5c4d7b2438d3 31 RtosTimer led_3_timer(blink, osTimerPeriodic, (void *)2);
switches 0:5c4d7b2438d3 32 RtosTimer led_4_timer(blink, osTimerPeriodic, (void *)3);
switches 0:5c4d7b2438d3 33
switches 0:5c4d7b2438d3 34 led_1_timer.start(200);
switches 0:5c4d7b2438d3 35 led_2_timer.start(100);
switches 0:5c4d7b2438d3 36 led_3_timer.start(50);
switches 0:5c4d7b2438d3 37 led_4_timer.start(25);
switches 0:5c4d7b2438d3 38
switches 0:5c4d7b2438d3 39 while(current_tick <= total_ticks) {
switches 0:5c4d7b2438d3 40 Thread::wait(10);
switches 0:5c4d7b2438d3 41 }
switches 0:5c4d7b2438d3 42
switches 0:5c4d7b2438d3 43 led_4_timer.stop();
switches 0:5c4d7b2438d3 44 led_3_timer.stop();
switches 0:5c4d7b2438d3 45 led_2_timer.stop();
switches 0:5c4d7b2438d3 46 led_1_timer.stop();
switches 0:5c4d7b2438d3 47
switches 0:5c4d7b2438d3 48 GREENTEA_TESTSUITE_RESULT(1);
switches 0:5c4d7b2438d3 49
switches 0:5c4d7b2438d3 50 Thread::wait(osWaitForever);
switches 0:5c4d7b2438d3 51 }