www.ti.com
OSAL Messages
19
SWRU271H–October 2010–Revised April 2019
Submit Documentation Feedback
Copyright © 2010–2019, Texas Instruments Incorporated
The Operating System Abstraction Layer (OSAL)
3.5 OSAL Messages
OSAL provides a scheme for different subsystems of the software to communicate by sending or receiving
messages. Messages can contain any type of data and can be any size (assuming enough memory is
available).
To send an OSAL message, do the following:
1. Use the osal_msg_allocate() function to allocate the memory to store the messages by supplying a
length parameter that specifies the length of the message.
NOTE: A pointer to a buffer containing the allocated space is returned (you do not need to use
osal_mem_alloc() when using osal_msg_allocate()).
If no memory is available, a NULL pointer is returned.
2. Copy the data into the buffer.
3. Call osal_msg_send() specifying the destination task ID and pointer to the message to be sent.
The following code shows an example from OnBoard.c:
The OSAL sets the SYS_EVENT_MSG flag for the receiving task that a message indicating that an
incoming message is available..This flag results in the event handler being invoked for the receiving task..
The receiving task retrieves the data by calling osal_msg_receive() and processes the message based on
the data contents. TI recommends every OSAL task have a local message processing function (the
message processing function of the SimpleBLEPeripheral application is
simpleBLEPeripheral_ProcessOSALMsg()). The processing function chooses what action to take based
on the type of message received. When the receiving task processes the message, it must deallocate the
memory using the function osal_msg_deallocate() (you do not need to use osal_mem_free() when using
osal_msg_deallocate()). Examples of receiving OSAL messages will be depicted in the event processing
functions of the various layers.