5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

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