Message
Message package management provides memory pool allocation and APIs for creating, accessing and releasing pure, common and dynamic messages used for inter-task communication.
Initialization
-
void msg_init()
Message initialization (Message pool)
Note
This function will be called by the kernel
- Parameters:
none – [in]
- Returns:
none
Message memory management
-
void free_msg(rk_msg_t *msg)
Free a message (Any type of message)
- Parameters:
msg – [in] pointer to the message to be freed (MUST-BE not NULL)
- Returns:
none
Pure message
-
rk_msg_t *get_pure_msg()
Take a pure message from the pool.
- Parameters:
none – [in]
- Returns:
pointer to the allocated pure message
-
uint8_t get_pure_msg_free()
Get a available pure message (Message free in the pool)
- Parameters:
none – [in]
- Returns:
number of free pure messages in the pool
Common message
-
rk_msg_t *get_common_msg()
Take a common message from the pool.
- Parameters:
none – [in]
- Returns:
pointer to the allocated common message
-
void set_data_common_msg(rk_msg_t *msg, uint8_t *data, uint8_t size)
Set data for a common message.
- Parameters:
msg – [in] pointer to the common message (MUST-BE not NULL)
data – [in] pointer to the data to be set (MUST-BE not NULL)
size – [in] size of the data to be set (MUST-BE less than or equal to RK_COMMON_MSG_DATA_SIZE)
- Returns:
none
-
uint8_t *get_data_common_msg(rk_msg_t *msg)
Get data from a common message.
- Parameters:
msg – [in] pointer to the common message (MUST-BE not NULL)
- Returns:
pointer to the data in the common message
-
uint8_t get_common_msg_free()
Get a available common message (Message free in the pool)
- Parameters:
none – [in]
- Returns:
number of free common messages in the pool
Dynamic message
-
rk_msg_t *get_dynamic_msg()
Take a dynamic message from the pool.
- Parameters:
none – [in]
- Returns:
pointer to the allocated dynamic message
-
void set_data_dynamic_msg(rk_msg_t *msg, uint8_t *data, uint32_t size)
Set data for a dynamic message.
- Parameters:
msg – [in] pointer to the dynamic message (MUST-BE not NULL)
data – [in] pointer to the data to be set (MUST-BE not NULL)
size – [in] size of the data to be set
- Returns:
none
-
uint8_t *get_data_dynamic_msg(rk_msg_t *msg)
Get data from a dynamic message.
- Parameters:
msg – [in] pointer to the dynamic message (MUST-BE not NULL)
- Returns:
pointer to the data in the dynamic message
-
uint8_t get_dynamic_msg_free()
Get a available dynamic message (Message free in the pool)
- Parameters:
none – [in]
- Returns:
number of free dynamic messages in the pool