void onTimer(void *x) { TPRINTF("onTimer\n"); blueLedToggle(); alarmSchedule(&timer, 1000); }
/*---------------------------------------------------------------------*/ PROCESS_THREAD(blink_blue_process, ev, data) { PROCESS_BEGIN(); static struct etimer timer; while (1) { etimer_set(&timer, TIMER_INTERRUPT_HZ * 2); PROCESS_WAIT_UNTIL(etimer_expired(&timer)); blueLedToggle(); } PROCESS_END(); }
//------------------------------------------- // Entry point for the application //------------------------------------------- void appMain(void) { while (1) { static uint_t i; // test 1: counter 0-7 for (i = 0; i < 8; ++i) { ledsSet(i); msleep(PAUSE); } // test 2: all off, then red on/off, then green on/off, finally blue on/off ledsSet(0); msleep(PAUSE); redLedOn(); msleep(PAUSE); redLedOff(); msleep(PAUSE); greenLedOn(); msleep(PAUSE); greenLedOff(); msleep(PAUSE); blueLedOn(); msleep(PAUSE); blueLedOff(); msleep(PAUSE); // test 3: all on, then blue off, green off, red off ledsSet(7); msleep(PAUSE); blueLedOff(); msleep(PAUSE); greenLedOff(); msleep(PAUSE); redLedOff(); msleep(PAUSE); // test 4: repeat last two tests with toggle redLedToggle(); msleep(PAUSE); redLedToggle(); msleep(PAUSE); greenLedToggle(); msleep(PAUSE); greenLedToggle(); msleep(PAUSE); blueLedToggle(); msleep(PAUSE); blueLedToggle(); msleep(PAUSE); ledsSet(7); msleep(PAUSE); blueLedToggle(); msleep(PAUSE); greenLedToggle(); msleep(PAUSE); redLedToggle(); msleep(PAUSE); // test 5: check that isOn functions work ledsSet(0); ASSERT(!redLedGet()); ASSERT(!greenLedGet()); ASSERT(!blueLedGet()); ledsSet(7); ASSERT(redLedGet()); ASSERT(greenLedGet()); ASSERT(blueLedGet()); } // EOF while (1) }
// Timer #2 callback function void onTimer2(void *x) { PRINTF("onTimer2\n"); blueLedToggle(); }