in RISC-V_RV32_THEAD_SMART_CDS/csi_kernel/freertosv10.3.1/adapter/csi_freertos.c [655:711]
k_status_t csi_kernel_event_wait(k_event_handle_t ev_handle, uint32_t flags,
k_event_opt_t options, uint8_t clr_on_exit,
uint32_t *actl_flags, int32_t timeout)
{
if (ev_handle == NULL || actl_flags == NULL
|| ((clr_on_exit != 0) && (clr_on_exit != 1))
|| flags == 0u) {
return -EINVAL;
}
if ((xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) && timeout != 0) {
return -EPERM;
}
if (timeout < 0) {
timeout = portMAX_DELAY;
}
if ((flags & 0xff000000UL) != 0) {
return -EPERM;
}
if (options == KEVENT_OPT_CLR_ANY || options == KEVENT_OPT_CLR_ALL) {
return -EOPNOTSUPP;
}
EventBits_t event_val = 0;
if (options == KEVENT_OPT_SET_ANY) {
event_val = xEventGroupWaitBits(ev_handle, flags, clr_on_exit, 0, timeout);
*actl_flags = event_val;
uint32_t i = 0, ebit = 0, fbit = 0;
for (; i < 24; i++) {
ebit = IS_BIT_SET(event_val, i);
fbit = IS_BIT_SET(flags, i);
if (ebit == 1 && fbit == 1) {
return 0;
}
}
return -ETIMEDOUT;
} else if (options == KEVENT_OPT_SET_ALL) {
event_val = xEventGroupWaitBits(ev_handle, flags, clr_on_exit, 1, timeout);
*actl_flags = event_val;
if ((event_val & flags) == flags) {
return 0;
} else {
return -ETIMEDOUT;
}
}
*actl_flags = event_val;
return 0;
}