* @brief The function will initialize a static event object. * * @note For the static event object, its memory space is allocated by the compiler during compiling, * and shall placed on the read-write data segment or on the uninitialized data segment. * By contrast, the rt_event_create() function will allocate memory space automatically * and initialize th
| 1786 | * @warning This function can ONLY be called from threads. |
| 1787 | */ |
| 1788 | rt_err_t rt_event_init(rt_event_t event, const char *name, rt_uint8_t flag) |
| 1789 | { |
| 1790 | /* parameter check */ |
| 1791 | RT_ASSERT(event != RT_NULL); |
| 1792 | RT_ASSERT((flag == RT_IPC_FLAG_FIFO) || (flag == RT_IPC_FLAG_PRIO)); |
| 1793 | |
| 1794 | /* initialize object */ |
| 1795 | rt_object_init(&(event->parent.parent), RT_Object_Class_Event, name); |
| 1796 | |
| 1797 | /* set parent flag */ |
| 1798 | event->parent.parent.flag = flag; |
| 1799 | |
| 1800 | /* initialize ipc object */ |
| 1801 | _ipc_object_init(&(event->parent)); |
| 1802 | |
| 1803 | /* initialize event */ |
| 1804 | event->set = 0; |
| 1805 | rt_spin_lock_init(&(event->spinlock)); |
| 1806 | |
| 1807 | return RT_EOK; |
| 1808 | } |
| 1809 | RTM_EXPORT(rt_event_init); |
| 1810 | |
| 1811 |