rtx_evflags.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*
  2. * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the License); you may
  7. * not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  14. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. * -----------------------------------------------------------------------------
  19. *
  20. * Project: CMSIS-RTOS RTX
  21. * Title: Event Flags functions
  22. *
  23. * -----------------------------------------------------------------------------
  24. */
  25. #include "rtx_lib.h"
  26. // OS Runtime Object Memory Usage
  27. #if ((defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0)))
  28. osRtxObjectMemUsage_t osRtxEventFlagsMemUsage \
  29. __attribute__((section(".data.os.evflags.obj"))) =
  30. { 0U, 0U, 0U };
  31. #endif
  32. // ==== Helper functions ====
  33. /// Set Event Flags.
  34. /// \param[in] ef event flags object.
  35. /// \param[in] flags specifies the flags to set.
  36. /// \return event flags after setting.
  37. static uint32_t EventFlagsSet (os_event_flags_t *ef, uint32_t flags) {
  38. #if (EXCLUSIVE_ACCESS == 0)
  39. uint32_t primask = __get_PRIMASK();
  40. #endif
  41. uint32_t event_flags;
  42. #if (EXCLUSIVE_ACCESS == 0)
  43. __disable_irq();
  44. ef->event_flags |= flags;
  45. event_flags = ef->event_flags;
  46. if (primask == 0U) {
  47. __enable_irq();
  48. }
  49. #else
  50. event_flags = atomic_set32(&ef->event_flags, flags);
  51. #endif
  52. return event_flags;
  53. }
  54. /// Clear Event Flags.
  55. /// \param[in] ef event flags object.
  56. /// \param[in] flags specifies the flags to clear.
  57. /// \return event flags before clearing.
  58. static uint32_t EventFlagsClear (os_event_flags_t *ef, uint32_t flags) {
  59. #if (EXCLUSIVE_ACCESS == 0)
  60. uint32_t primask = __get_PRIMASK();
  61. #endif
  62. uint32_t event_flags;
  63. #if (EXCLUSIVE_ACCESS == 0)
  64. __disable_irq();
  65. event_flags = ef->event_flags;
  66. ef->event_flags &= ~flags;
  67. if (primask == 0U) {
  68. __enable_irq();
  69. }
  70. #else
  71. event_flags = atomic_clr32(&ef->event_flags, flags);
  72. #endif
  73. return event_flags;
  74. }
  75. /// Check Event Flags.
  76. /// \param[in] ef event flags object.
  77. /// \param[in] flags specifies the flags to check.
  78. /// \param[in] options specifies flags options (osFlagsXxxx).
  79. /// \return event flags before clearing or 0 if specified flags have not been set.
  80. static uint32_t EventFlagsCheck (os_event_flags_t *ef, uint32_t flags, uint32_t options) {
  81. #if (EXCLUSIVE_ACCESS == 0)
  82. uint32_t primask;
  83. #endif
  84. uint32_t event_flags;
  85. if ((options & osFlagsNoClear) == 0U) {
  86. #if (EXCLUSIVE_ACCESS == 0)
  87. primask = __get_PRIMASK();
  88. __disable_irq();
  89. event_flags = ef->event_flags;
  90. if ((((options & osFlagsWaitAll) != 0U) && ((event_flags & flags) != flags)) ||
  91. (((options & osFlagsWaitAll) == 0U) && ((event_flags & flags) == 0U))) {
  92. event_flags = 0U;
  93. } else {
  94. ef->event_flags &= ~flags;
  95. }
  96. if (primask == 0U) {
  97. __enable_irq();
  98. }
  99. #else
  100. if ((options & osFlagsWaitAll) != 0U) {
  101. event_flags = atomic_chk32_all(&ef->event_flags, flags);
  102. } else {
  103. event_flags = atomic_chk32_any(&ef->event_flags, flags);
  104. }
  105. #endif
  106. } else {
  107. event_flags = ef->event_flags;
  108. if ((((options & osFlagsWaitAll) != 0U) && ((event_flags & flags) != flags)) ||
  109. (((options & osFlagsWaitAll) == 0U) && ((event_flags & flags) == 0U))) {
  110. event_flags = 0U;
  111. }
  112. }
  113. return event_flags;
  114. }
  115. // ==== Post ISR processing ====
  116. /// Event Flags post ISR processing.
  117. /// \param[in] ef event flags object.
  118. static void osRtxEventFlagsPostProcess (os_event_flags_t *ef) {
  119. os_thread_t *thread;
  120. os_thread_t *thread_next;
  121. uint32_t event_flags;
  122. // Check if Threads are waiting for Event Flags
  123. thread = ef->thread_list;
  124. while (thread != NULL) {
  125. thread_next = thread->thread_next;
  126. event_flags = EventFlagsCheck(ef, thread->wait_flags, thread->flags_options);
  127. if (event_flags != 0U) {
  128. osRtxThreadListRemove(thread);
  129. osRtxThreadWaitExit(thread, event_flags, FALSE);
  130. EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, thread->flags_options, event_flags);
  131. }
  132. thread = thread_next;
  133. }
  134. }
  135. // ==== Service Calls ====
  136. /// Create and Initialize an Event Flags object.
  137. /// \note API identical to osEventFlagsNew
  138. static osEventFlagsId_t svcRtxEventFlagsNew (const osEventFlagsAttr_t *attr) {
  139. os_event_flags_t *ef;
  140. uint8_t flags;
  141. const char *name;
  142. // Process attributes
  143. if (attr != NULL) {
  144. name = attr->name;
  145. //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 6]
  146. ef = attr->cb_mem;
  147. if (ef != NULL) {
  148. //lint -e(923) -e(9078) "cast from pointer to unsigned int" [MISRA Note 7]
  149. if ((((uint32_t)ef & 3U) != 0U) || (attr->cb_size < sizeof(os_event_flags_t))) {
  150. EvrRtxEventFlagsError(NULL, osRtxErrorInvalidControlBlock);
  151. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  152. return NULL;
  153. }
  154. } else {
  155. if (attr->cb_size != 0U) {
  156. EvrRtxEventFlagsError(NULL, osRtxErrorInvalidControlBlock);
  157. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  158. return NULL;
  159. }
  160. }
  161. } else {
  162. name = NULL;
  163. ef = NULL;
  164. }
  165. // Allocate object memory if not provided
  166. if (ef == NULL) {
  167. if (osRtxInfo.mpi.event_flags != NULL) {
  168. //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5]
  169. ef = osRtxMemoryPoolAlloc(osRtxInfo.mpi.event_flags);
  170. } else {
  171. //lint -e{9079} "conversion from pointer to void to pointer to other type" [MISRA Note 5]
  172. ef = osRtxMemoryAlloc(osRtxInfo.mem.common, sizeof(os_event_flags_t), 1U);
  173. }
  174. #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))
  175. if (ef != NULL) {
  176. uint32_t used;
  177. osRtxEventFlagsMemUsage.cnt_alloc++;
  178. used = osRtxEventFlagsMemUsage.cnt_alloc - osRtxEventFlagsMemUsage.cnt_free;
  179. if (osRtxEventFlagsMemUsage.max_used < used) {
  180. osRtxEventFlagsMemUsage.max_used = used;
  181. }
  182. }
  183. #endif
  184. flags = osRtxFlagSystemObject;
  185. } else {
  186. flags = 0U;
  187. }
  188. if (ef != NULL) {
  189. // Initialize control block
  190. ef->id = osRtxIdEventFlags;
  191. ef->flags = flags;
  192. ef->name = name;
  193. ef->thread_list = NULL;
  194. ef->event_flags = 0U;
  195. // Register post ISR processing function
  196. osRtxInfo.post_process.event_flags = osRtxEventFlagsPostProcess;
  197. EvrRtxEventFlagsCreated(ef, ef->name);
  198. } else {
  199. EvrRtxEventFlagsError(NULL, (int32_t)osErrorNoMemory);
  200. }
  201. return ef;
  202. }
  203. /// Get name of an Event Flags object.
  204. /// \note API identical to osEventFlagsGetName
  205. static const char *svcRtxEventFlagsGetName (osEventFlagsId_t ef_id) {
  206. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  207. // Check parameters
  208. if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) {
  209. EvrRtxEventFlagsGetName(ef, NULL);
  210. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  211. return NULL;
  212. }
  213. EvrRtxEventFlagsGetName(ef, ef->name);
  214. return ef->name;
  215. }
  216. /// Set the specified Event Flags.
  217. /// \note API identical to osEventFlagsSet
  218. static uint32_t svcRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
  219. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  220. os_thread_t *thread;
  221. os_thread_t *thread_next;
  222. uint32_t event_flags;
  223. uint32_t event_flags0;
  224. // Check parameters
  225. if ((ef == NULL) || (ef->id != osRtxIdEventFlags) ||
  226. ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
  227. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  228. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  229. return ((uint32_t)osErrorParameter);
  230. }
  231. // Set Event Flags
  232. event_flags = EventFlagsSet(ef, flags);
  233. // Check if Threads are waiting for Event Flags
  234. thread = ef->thread_list;
  235. while (thread != NULL) {
  236. thread_next = thread->thread_next;
  237. event_flags0 = EventFlagsCheck(ef, thread->wait_flags, thread->flags_options);
  238. if (event_flags0 != 0U) {
  239. if ((thread->flags_options & osFlagsNoClear) == 0U) {
  240. event_flags = event_flags0 & ~thread->wait_flags;
  241. } else {
  242. event_flags = event_flags0;
  243. }
  244. osRtxThreadListRemove(thread);
  245. osRtxThreadWaitExit(thread, event_flags0, FALSE);
  246. EvrRtxEventFlagsWaitCompleted(ef, thread->wait_flags, thread->flags_options, event_flags0);
  247. }
  248. thread = thread_next;
  249. }
  250. osRtxThreadDispatch(NULL);
  251. EvrRtxEventFlagsSetDone(ef, event_flags);
  252. return event_flags;
  253. }
  254. /// Clear the specified Event Flags.
  255. /// \note API identical to osEventFlagsClear
  256. static uint32_t svcRtxEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) {
  257. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  258. uint32_t event_flags;
  259. // Check parameters
  260. if ((ef == NULL) || (ef->id != osRtxIdEventFlags) ||
  261. ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
  262. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  263. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  264. return ((uint32_t)osErrorParameter);
  265. }
  266. // Clear Event Flags
  267. event_flags = EventFlagsClear(ef, flags);
  268. EvrRtxEventFlagsClearDone(ef, event_flags);
  269. return event_flags;
  270. }
  271. /// Get the current Event Flags.
  272. /// \note API identical to osEventFlagsGet
  273. static uint32_t svcRtxEventFlagsGet (osEventFlagsId_t ef_id) {
  274. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  275. // Check parameters
  276. if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) {
  277. EvrRtxEventFlagsGet(ef, 0U);
  278. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  279. return 0U;
  280. }
  281. EvrRtxEventFlagsGet(ef, ef->event_flags);
  282. return ef->event_flags;
  283. }
  284. /// Wait for one or more Event Flags to become signaled.
  285. /// \note API identical to osEventFlagsWait
  286. static uint32_t svcRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) {
  287. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  288. os_thread_t *running_thread;
  289. uint32_t event_flags;
  290. // Check running thread
  291. running_thread = osRtxThreadGetRunning();
  292. if (running_thread == NULL) {
  293. EvrRtxEventFlagsError(ef, osRtxErrorKernelNotRunning);
  294. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  295. return ((uint32_t)osError);
  296. }
  297. // Check parameters
  298. if ((ef == NULL) || (ef->id != osRtxIdEventFlags) ||
  299. ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
  300. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  301. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  302. return ((uint32_t)osErrorParameter);
  303. }
  304. // Check Event Flags
  305. event_flags = EventFlagsCheck(ef, flags, options);
  306. if (event_flags != 0U) {
  307. EvrRtxEventFlagsWaitCompleted(ef, flags, options, event_flags);
  308. } else {
  309. // Check if timeout is specified
  310. if (timeout != 0U) {
  311. EvrRtxEventFlagsWaitPending(ef, flags, options, timeout);
  312. // Store waiting flags and options
  313. running_thread->wait_flags = flags;
  314. running_thread->flags_options = (uint8_t)options;
  315. // Suspend current Thread
  316. if (osRtxThreadWaitEnter(osRtxThreadWaitingEventFlags, timeout)) {
  317. osRtxThreadListPut(osRtxObject(ef), running_thread);
  318. } else {
  319. EvrRtxEventFlagsWaitTimeout(ef);
  320. }
  321. event_flags = (uint32_t)osErrorTimeout;
  322. } else {
  323. EvrRtxEventFlagsWaitNotCompleted(ef, flags, options);
  324. event_flags = (uint32_t)osErrorResource;
  325. }
  326. }
  327. return event_flags;
  328. }
  329. /// Delete an Event Flags object.
  330. /// \note API identical to osEventFlagsDelete
  331. static osStatus_t svcRtxEventFlagsDelete (osEventFlagsId_t ef_id) {
  332. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  333. os_thread_t *thread;
  334. // Check parameters
  335. if ((ef == NULL) || (ef->id != osRtxIdEventFlags)) {
  336. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  337. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  338. return osErrorParameter;
  339. }
  340. // Unblock waiting threads
  341. if (ef->thread_list != NULL) {
  342. do {
  343. thread = osRtxThreadListGet(osRtxObject(ef));
  344. osRtxThreadWaitExit(thread, (uint32_t)osErrorResource, FALSE);
  345. } while (ef->thread_list != NULL);
  346. osRtxThreadDispatch(NULL);
  347. }
  348. // Mark object as invalid
  349. ef->id = osRtxIdInvalid;
  350. // Free object memory
  351. if ((ef->flags & osRtxFlagSystemObject) != 0U) {
  352. if (osRtxInfo.mpi.event_flags != NULL) {
  353. (void)osRtxMemoryPoolFree(osRtxInfo.mpi.event_flags, ef);
  354. } else {
  355. (void)osRtxMemoryFree(osRtxInfo.mem.common, ef);
  356. }
  357. #if (defined(OS_OBJ_MEM_USAGE) && (OS_OBJ_MEM_USAGE != 0))
  358. osRtxEventFlagsMemUsage.cnt_free++;
  359. #endif
  360. }
  361. EvrRtxEventFlagsDestroyed(ef);
  362. return osOK;
  363. }
  364. // Service Calls definitions
  365. //lint ++flb "Library Begin" [MISRA Note 11]
  366. SVC0_1(EventFlagsNew, osEventFlagsId_t, const osEventFlagsAttr_t *)
  367. SVC0_1(EventFlagsGetName, const char *, osEventFlagsId_t)
  368. SVC0_2(EventFlagsSet, uint32_t, osEventFlagsId_t, uint32_t)
  369. SVC0_2(EventFlagsClear, uint32_t, osEventFlagsId_t, uint32_t)
  370. SVC0_1(EventFlagsGet, uint32_t, osEventFlagsId_t)
  371. SVC0_4(EventFlagsWait, uint32_t, osEventFlagsId_t, uint32_t, uint32_t, uint32_t)
  372. SVC0_1(EventFlagsDelete, osStatus_t, osEventFlagsId_t)
  373. //lint --flb "Library End"
  374. // ==== ISR Calls ====
  375. /// Set the specified Event Flags.
  376. /// \note API identical to osEventFlagsSet
  377. __STATIC_INLINE
  378. uint32_t isrRtxEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
  379. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  380. uint32_t event_flags;
  381. // Check parameters
  382. if ((ef == NULL) || (ef->id != osRtxIdEventFlags) ||
  383. ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
  384. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  385. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  386. return ((uint32_t)osErrorParameter);
  387. }
  388. // Set Event Flags
  389. event_flags = EventFlagsSet(ef, flags);
  390. // Register post ISR processing
  391. osRtxPostProcess(osRtxObject(ef));
  392. EvrRtxEventFlagsSetDone(ef, event_flags);
  393. return event_flags;
  394. }
  395. /// Wait for one or more Event Flags to become signaled.
  396. /// \note API identical to osEventFlagsWait
  397. __STATIC_INLINE
  398. uint32_t isrRtxEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) {
  399. os_event_flags_t *ef = osRtxEventFlagsId(ef_id);
  400. uint32_t event_flags;
  401. // Check parameters
  402. if ((ef == NULL) || (ef->id != osRtxIdEventFlags) || (timeout != 0U) ||
  403. ((flags & ~(((uint32_t)1U << osRtxEventFlagsLimit) - 1U)) != 0U)) {
  404. EvrRtxEventFlagsError(ef, (int32_t)osErrorParameter);
  405. //lint -e{904} "Return statement before end of function" [MISRA Note 1]
  406. return ((uint32_t)osErrorParameter);
  407. }
  408. // Check Event Flags
  409. event_flags = EventFlagsCheck(ef, flags, options);
  410. if (event_flags != 0U) {
  411. EvrRtxEventFlagsWaitCompleted(ef, flags, options, event_flags);
  412. } else {
  413. EvrRtxEventFlagsWaitNotCompleted(ef, flags, options);
  414. event_flags = (uint32_t)osErrorResource;
  415. }
  416. return event_flags;
  417. }
  418. // ==== Public API ====
  419. /// Create and Initialize an Event Flags object.
  420. osEventFlagsId_t osEventFlagsNew (const osEventFlagsAttr_t *attr) {
  421. osEventFlagsId_t ef_id;
  422. EvrRtxEventFlagsNew(attr);
  423. if (IsIrqMode() || IsIrqMasked()) {
  424. EvrRtxEventFlagsError(NULL, (int32_t)osErrorISR);
  425. ef_id = NULL;
  426. } else {
  427. ef_id = __svcEventFlagsNew(attr);
  428. }
  429. return ef_id;
  430. }
  431. /// Get name of an Event Flags object.
  432. const char *osEventFlagsGetName (osEventFlagsId_t ef_id) {
  433. const char *name;
  434. if (IsIrqMode() || IsIrqMasked()) {
  435. EvrRtxEventFlagsGetName(ef_id, NULL);
  436. name = NULL;
  437. } else {
  438. name = __svcEventFlagsGetName(ef_id);
  439. }
  440. return name;
  441. }
  442. /// Set the specified Event Flags.
  443. uint32_t osEventFlagsSet (osEventFlagsId_t ef_id, uint32_t flags) {
  444. uint32_t event_flags;
  445. EvrRtxEventFlagsSet(ef_id, flags);
  446. if (IsIrqMode() || IsIrqMasked()) {
  447. event_flags = isrRtxEventFlagsSet(ef_id, flags);
  448. } else {
  449. event_flags = __svcEventFlagsSet(ef_id, flags);
  450. }
  451. return event_flags;
  452. }
  453. /// Clear the specified Event Flags.
  454. uint32_t osEventFlagsClear (osEventFlagsId_t ef_id, uint32_t flags) {
  455. uint32_t event_flags;
  456. EvrRtxEventFlagsClear(ef_id, flags);
  457. if (IsIrqMode() || IsIrqMasked()) {
  458. event_flags = svcRtxEventFlagsClear(ef_id, flags);
  459. } else {
  460. event_flags = __svcEventFlagsClear(ef_id, flags);
  461. }
  462. return event_flags;
  463. }
  464. /// Get the current Event Flags.
  465. uint32_t osEventFlagsGet (osEventFlagsId_t ef_id) {
  466. uint32_t event_flags;
  467. if (IsIrqMode() || IsIrqMasked()) {
  468. event_flags = svcRtxEventFlagsGet(ef_id);
  469. } else {
  470. event_flags = __svcEventFlagsGet(ef_id);
  471. }
  472. return event_flags;
  473. }
  474. /// Wait for one or more Event Flags to become signaled.
  475. uint32_t osEventFlagsWait (osEventFlagsId_t ef_id, uint32_t flags, uint32_t options, uint32_t timeout) {
  476. uint32_t event_flags;
  477. EvrRtxEventFlagsWait(ef_id, flags, options, timeout);
  478. if (IsIrqMode() || IsIrqMasked()) {
  479. event_flags = isrRtxEventFlagsWait(ef_id, flags, options, timeout);
  480. } else {
  481. event_flags = __svcEventFlagsWait(ef_id, flags, options, timeout);
  482. }
  483. return event_flags;
  484. }
  485. /// Delete an Event Flags object.
  486. osStatus_t osEventFlagsDelete (osEventFlagsId_t ef_id) {
  487. osStatus_t status;
  488. EvrRtxEventFlagsDelete(ef_id);
  489. if (IsIrqMode() || IsIrqMasked()) {
  490. EvrRtxEventFlagsError(ef_id, (int32_t)osErrorISR);
  491. status = osErrorISR;
  492. } else {
  493. status = __svcEventFlagsDelete(ef_id);
  494. }
  495. return status;
  496. }