CooCox CoOS User's Guide
CooCox CoOS User's Guide
CooCox CoOS User's Guide
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Example Usage:<br />
#include "CCRTOS.h"<br />
OS_TCID sftmr;<br />
void SftTmrCallBack(void)<br />
{<br />
...<br />
}<br />
void TaskN (void *pdata)<br />
{<br />
...<br />
sftmr = CoCreateTmr(TMR_TYPE_PERIODIC,<br />
100,<br />
100,<br />
SftTmrCallBack);<br />
if (sftmr == E_CREATE_FAIL)<br />
{<br />
printf("Failed to create the timer!\n");<br />
}<br />
else<br />
{<br />
printf("Create the timer successfully, Time ID is %d\n", sftmr);<br />
}<br />
...<br />
}<br />
Note:<br />
1) <strong>CooCox</strong> <strong>CoOS</strong> provides two kinds of timers: the periodic timer and the<br />
disposable timer. For the periodic timer, the time first-calling the<br />
callback function is determined by the tmrCnt, and then it is<br />
determined by the tmrReload. For the disposable timer, the calling<br />
time is determined completely by the tmrCnt and it can call only once.<br />
2) Once a timer is created, it is in the stopping state. You need call<br />
CoStartTmr() to startup it.<br />
6.4.2 CoStartTmr()<br />
Function Prototype:<br />
StatusType CoStartTmr<br />
(<br />
OS_TCID tmrID<br />
);<br />
Description:<br />
Start a specified timer to work normally.<br />
63