OsHndlT OsNewMessageTimer( OsTicksT delay, OsHndlT queue, OsMsgDataT data );
Function OsNewMessageTimer() may be called by the client application to create a new one-shot message timer. The first argument is the delay time, in ticks, after which the timer should fire. The second argument is a handle to the message queue to which a message should be sent when the timer expires. The third argument is the message data to be sent to the message queue.
The function returns a handle to the new message timer if it was created successfully. Unless the application needs the option to destroy the timer, there is no need to save this handle. If a new timer cannot be created, for example due to the exhaustion of timer resources, the function returns OsHndl_NONE.
The example below shows task transmitTask being created and bound to a task function and then a message queue retryQueue being created that sends event 4 to the task when a message is present in it. At some point in the task function, a message timer is created to send a message to retryQueue after TIME_OUT ticks. The data of the message is the address of some data structure packet. This allows the task to find its way back to a piece of data if and when the message is retrieved from the queue. The handle of the timer is saved in a field of the data structure so that the timer can be destroyed if required, in this example perhaps if the packet is acknowledged.
transmitTask = OsNewTask( OsPrior_HIGH );
OsTaskBindFunction( transmitTask, TransmitPacket );
retryQueue = OsNewMessageQueue( transmitTask, OS_EVENT_4 );
...
packet.retryTimer =
OsNewMessageTimer( TIME_OUT, retryQueue, (OsMsgDataT)&packet );