Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. SEM_ID taskReleaseSem;
  2.  
  3. void myTimedFunc(void)
  4. {
  5. semGive(taskReleaseSem);
  6. }
  7.  
  8. void myTaskFunc(int tickParameter) // The clock tick passes a constant
  9. {
  10. for(;;) // Pick your favorite forever method
  11. {
  12. // Wait for the semaphore to be given
  13. semTake(taskReleaseSem);
  14. // Your periodic stuff
  15. }
  16. }
  17.  
  18. void initTimedFunc(void)
  19. {
  20. // Create a semaphore to release the timed task
  21. taskReleaseSem = semBCreate(SEM_Q_PRIORITY,SEM_EMPTY);
  22.  
  23. // Set the aux xloxk to the desired rate
  24. sysAuxClkRateSet(20);
  25.  
  26. // Spawn the task that does the work
  27. taskSpawn(
  28. "timed", /* name of new task (stored at pStackBase) */
  29. 100, /* priority of new task */
  30. 0, /* task option word */
  31. 4096, /* size (bytes) of stack needed plus name */
  32. myTaskFunc, /* entry point of new task */
  33. 0, /* 1st of 10 req'd task args to pass to func */
  34. 0, 0, 0, 0, 0, 0, 0, 0, 0
  35. )
  36.  
  37. // Now connect the timer function to the aux clock
  38. sysAuxClkConnect(myTimedFunc,0);
  39. // And switch it on
  40. sysAuxClkEnable();
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement