* @brief This function will receive an event from event object. if the event is unavailable, the thread shall wait for * the event up to a specified time. * * @note If there are threads suspended on this semaphore, the first thread in the list of this semaphore object * will be resumed, and a thread scheduling (rt_schedule) will be executed. * If no threads are susp
| 2096 | * If the return value is any other values, it means that the semaphore release failed. |
| 2097 | */ |
| 2098 | static rt_err_t _rt_event_recv(rt_event_t event, |
| 2099 | rt_uint32_t set, |
| 2100 | rt_uint8_t option, |
| 2101 | rt_int32_t timeout, |
| 2102 | rt_uint32_t *recved, |
| 2103 | int suspend_flag) |
| 2104 | { |
| 2105 | struct rt_thread *thread; |
| 2106 | rt_base_t level; |
| 2107 | rt_base_t status; |
| 2108 | rt_err_t ret; |
| 2109 | |
| 2110 | /* parameter check */ |
| 2111 | RT_ASSERT(event != RT_NULL); |
| 2112 | RT_ASSERT(rt_object_get_type(&event->parent.parent) == RT_Object_Class_Event); |
| 2113 | |
| 2114 | /* current context checking */ |
| 2115 | RT_DEBUG_SCHEDULER_AVAILABLE(RT_TRUE); |
| 2116 | |
| 2117 | if (set == 0) |
| 2118 | return -RT_ERROR; |
| 2119 | |
| 2120 | /* initialize status */ |
| 2121 | status = -RT_ERROR; |
| 2122 | /* get current thread */ |
| 2123 | thread = rt_thread_self(); |
| 2124 | /* reset thread error */ |
| 2125 | thread->error = -RT_EINTR; |
| 2126 | |
| 2127 | RT_OBJECT_HOOK_CALL(rt_object_trytake_hook, (&(event->parent.parent))); |
| 2128 | |
| 2129 | level = rt_spin_lock_irqsave(&(event->spinlock)); |
| 2130 | |
| 2131 | /* check event set */ |
| 2132 | if (option & RT_EVENT_FLAG_AND) |
| 2133 | { |
| 2134 | if ((event->set & set) == set) |
| 2135 | status = RT_EOK; |
| 2136 | } |
| 2137 | else if (option & RT_EVENT_FLAG_OR) |
| 2138 | { |
| 2139 | if (event->set & set) |
| 2140 | status = RT_EOK; |
| 2141 | } |
| 2142 | else |
| 2143 | { |
| 2144 | /* either RT_EVENT_FLAG_AND or RT_EVENT_FLAG_OR should be set */ |
| 2145 | RT_ASSERT(0); |
| 2146 | } |
| 2147 | |
| 2148 | if (status == RT_EOK) |
| 2149 | { |
| 2150 | thread->error = RT_EOK; |
| 2151 | |
| 2152 | /* set received event */ |
| 2153 | if (recved) |
| 2154 | *recved = (event->set & set); |
| 2155 |
no test coverage detected