MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_mb_control

Function rt_mb_control

src/ipc.c:3011–3043  ·  view source on GitHub ↗

* @brief This function will set some extra attributions of a mailbox object. * * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the mailbox. * * @param mb is a pointer to a mailbox object. * * @param cmd is a command used to configure some attributions of the mailbox. * * @param arg is the argument of the function to execute the command.

Source from the content-addressed store, hash-verified

3009 * If the return value is any other values, it means that this function failed to execute.
3010 */
3011rt_err_t rt_mb_control(rt_mailbox_t mb, int cmd, void *arg)
3012{
3013 rt_base_t level;
3014
3015 RT_UNUSED(arg);
3016
3017 /* parameter check */
3018 RT_ASSERT(mb != RT_NULL);
3019 RT_ASSERT(rt_object_get_type(&mb->parent.parent) == RT_Object_Class_MailBox);
3020
3021 if (cmd == RT_IPC_CMD_RESET)
3022 {
3023 level = rt_spin_lock_irqsave(&(mb->spinlock));
3024
3025 /* resume all waiting thread */
3026 rt_susp_list_resume_all(&(mb->parent.suspend_thread), RT_ERROR);
3027 /* also resume all mailbox private suspended thread */
3028 rt_susp_list_resume_all(&(mb->suspend_sender_thread), RT_ERROR);
3029
3030 /* re-init mailbox */
3031 mb->entry = 0;
3032 mb->in_offset = 0;
3033 mb->out_offset = 0;
3034
3035 rt_spin_unlock_irqrestore(&(mb->spinlock), level);
3036
3037 rt_schedule();
3038
3039 return RT_EOK;
3040 }
3041
3042 return -RT_ERROR;
3043}
3044RTM_EXPORT(rt_mb_control);
3045
3046/**@}*/

Callers 1

hal_is_mailbox_emptyFunction · 0.85

Calls 5

rt_object_get_typeFunction · 0.85
rt_susp_list_resume_allFunction · 0.85
rt_spin_lock_irqsaveFunction · 0.70
rt_scheduleFunction · 0.70

Tested by

no test coverage detected