Created
November 25, 2018 15:07
-
-
Save bgloh/5780f86dbdd4b3e913d1b08a5c5c50a0 to your computer and use it in GitHub Desktop.
how to create one time clock, Event handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create one-shot clocks for internal periodic events. | |
Util_constructClock(&myPeriodicClock0,my_clockHandler0,MYCLOCK0_PERIOD,0,false, MY_EVENT0); | |
Clock_Handle h_myClock0 = Clock_handle(&myPeriodicClock0); | |
Clock_start(h_myClock0); | |
// To use Event module add the following to the .cfg | |
var evt = xdc.useModule('ti.sysbios.knl.Event'); | |
// Creation of Event instance | |
evt = Event_create(NULL,NULL); | |
// | |
task() | |
{ | |
UInt events; | |
while (TRUE) { | |
/* Wait for ANY of the ISR events to be posted * | |
events = Event_pend(myEvent, Event_Id_NONE, | |
Event_Id_00 + Event_Id_01 + Event_Id_02, | |
BIOS_WAIT_FOREVER); | |
/* Process all the events that have occurred */ | |
if (events & Event_Id_00) { | |
processISR0(); | |
} | |
if (events & Event_Id_01) { | |
processISR1(); | |
} | |
if (events & Event_Id_02) { | |
processISR2(); | |
} | |
} | |
} | |
//The following C code blocks on an event. It wakes the task only when both events 0 | |
and 6 have occurred. It sets the andMask to enable both Event_Id_00 and Event_Id_06. It sets the | |
orMask to Event_Id_NONE. | |
Event_pend(myEvent, (Event_Id_00 + Event_Id_06), Event_Id_NONE, | |
BIOS_WAIT_FOREVER); | |
// Internal event handling in task | |
task(){ | |
while(1) | |
{ | |
// Internal event handling | |
/* if (Myevent == MY_EVENT0) | |
{ | |
Myevent &= ~MY_EVENT0; | |
SensorTagIO_blinkLed(IOID_RED_LED, 1); | |
} | |
else if (Myevent == MY_EVENT1) | |
{ | |
Myevent &= ~MY_EVENT1; | |
SensorTagIO_blinkLed(IOID_1, 5); | |
} | |
Task_sleep(100); */ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference : "SYS/BIOS (TI-RTOS Kernel) User's Guide (Rev. T)"