SWRU271I October 2010 – January 2020 CC2540 , CC2540T , CC2541 , CC2541-Q1 , CC2640R2F
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:
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.
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.