Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SEM_ID taskReleaseSem;
- void myTimedFunc(void)
- {
- semGive(taskReleaseSem);
- }
- void myTaskFunc(int tickParameter) // The clock tick passes a constant
- {
- for(;;) // Pick your favorite forever method
- {
- // Wait for the semaphore to be given
- semTake(taskReleaseSem);
- // Your periodic stuff
- }
- }
- void initTimedFunc(void)
- {
- // Create a semaphore to release the timed task
- taskReleaseSem = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY);
- // Set the aux xloxk to the desired rate
- sysAuxClkRateSet(20);
- // Spawn the task that does the work
- taskSpawn(
- "timed", /* name of new task (stored at pStackBase) */
- 100, /* priority of new task */
- 0, /* task option word */
- 4096, /* size (bytes) of stack needed plus name */
- myTaskFunc, /* entry point of new task */
- 0, /* 1st of 10 req'd task args to pass to func */
- 0, 0, 0, 0, 0, 0, 0, 0, 0
- )
- // Now connect the timer function to the aux clock
- sysAuxClkConnect(myTimedFunc,0);
- // And switch it on
- sysAuxClkEnable();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement