diff --git a/include/zephyr/kernel.h b/include/zephyr/kernel.h index a19ed49af2..78dde677f6 100644 --- a/include/zephyr/kernel.h +++ b/include/zephyr/kernel.h @@ -2142,6 +2142,16 @@ __syscall void k_event_set(struct k_event *event, uint32_t events); __syscall void k_event_set_masked(struct k_event *event, uint32_t events, uint32_t events_mask); +/** + * @brief Clear the events in an event object + * + * This routine clears (resets) the specified events stored in an event object. + * + * @param event Address of the event object + * @param events Set of events to clear in @a event + */ +__syscall void k_event_clear(struct k_event *event, uint32_t events); + /** * @brief Wait for any of the specified events * diff --git a/kernel/events.c b/kernel/events.c index 914364e4c5..5a23390286 100644 --- a/kernel/events.c +++ b/kernel/events.c @@ -188,6 +188,20 @@ void z_vrfy_k_event_set_masked(struct k_event *event, uint32_t events, #include #endif +void z_impl_k_event_clear(struct k_event *event, uint32_t events) +{ + k_event_post_internal(event, 0, events); +} + +#ifdef CONFIG_USERSPACE +void z_vrfy_k_event_clear(struct k_event *event, uint32_t events) +{ + Z_OOPS(Z_SYSCALL_OBJ(event, K_OBJ_EVENT)); + z_impl_k_event_clear(event, events); +} +#include +#endif + static uint32_t k_event_wait_internal(struct k_event *event, uint32_t events, unsigned int options, k_timeout_t timeout) {