* @brief This function will set some extra attributions of an event object. * * @note Currently this function only supports the RT_IPC_CMD_RESET command to reset the event. * * @param event is a pointer to an event object. * * @param cmd is a command word used to configure some attributions of the event. * * @param arg is the argument of the function to execute the command.
| 2266 | * If the return value is any other values, it means that this function failed to execute. |
| 2267 | */ |
| 2268 | rt_err_t rt_event_control(rt_event_t event, int cmd, void *arg) |
| 2269 | { |
| 2270 | rt_base_t level; |
| 2271 | |
| 2272 | RT_UNUSED(arg); |
| 2273 | |
| 2274 | /* parameter check */ |
| 2275 | RT_ASSERT(event != RT_NULL); |
| 2276 | RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event); |
| 2277 | |
| 2278 | if (cmd == RT_IPC_CMD_RESET) |
| 2279 | { |
| 2280 | level = rt_spin_lock_irqsave(&(event->spinlock)); |
| 2281 | |
| 2282 | /* resume all waiting thread */ |
| 2283 | rt_susp_list_resume_all(&event->parent.suspend_thread, RT_ERROR); |
| 2284 | |
| 2285 | /* initialize event set */ |
| 2286 | event->set = 0; |
| 2287 | |
| 2288 | rt_spin_unlock_irqrestore(&(event->spinlock), level); |
| 2289 | |
| 2290 | rt_schedule(); |
| 2291 | |
| 2292 | return RT_EOK; |
| 2293 | } |
| 2294 | |
| 2295 | return -RT_ERROR; |
| 2296 | } |
| 2297 | RTM_EXPORT(rt_event_control); |
| 2298 | |
| 2299 | /**@}*/ |