Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Event APIs

Data Structures

struct  k_event
 Event Structure. More...
 

Macros

#define K_EVENT_DEFINE(name)
 Statically define and initialize an event object.
 

Functions

void k_event_init (struct k_event *event)
 Initialize an event object.
 
uint32_t k_event_post (struct k_event *event, uint32_t events)
 Post one or more events to an event object.
 
uint32_t k_event_set (struct k_event *event, uint32_t events)
 Set the events in an event object.
 
uint32_t k_event_set_masked (struct k_event *event, uint32_t events, uint32_t events_mask)
 Set or clear the events in an event object.
 
uint32_t k_event_clear (struct k_event *event, uint32_t events)
 Clear the events in an event object.
 
uint32_t k_event_wait (struct k_event *event, uint32_t events, bool reset, k_timeout_t timeout)
 Wait for any of the specified events.
 
uint32_t k_event_wait_all (struct k_event *event, uint32_t events, bool reset, k_timeout_t timeout)
 Wait for all of the specified events.
 
static uint32_t k_event_test (struct k_event *event, uint32_t events_mask)
 Test the events currently tracked in the event object.
 

Detailed Description

Macro Definition Documentation

◆ K_EVENT_DEFINE

#define K_EVENT_DEFINE (   name)

#include <zephyr/kernel.h>

Value:
Z_EVENT_INITIALIZER(name);
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition: iterable_sections.h:216
Event Structure.
Definition: kernel.h:2221

Statically define and initialize an event object.

The event can be accessed outside the module where it is defined using:

extern struct k_event <name>;
Parameters
nameName of the event object.

Function Documentation

◆ k_event_clear()

uint32_t k_event_clear ( struct k_event event,
uint32_t  events 
)

#include <zephyr/kernel.h>

Clear the events in an event object.

This routine clears (resets) the specified events stored in an event object.

Parameters
eventAddress of the event object
eventsSet of events to clear in event
Return values
Previousvalue of the events in event

◆ k_event_init()

void k_event_init ( struct k_event event)

#include <zephyr/kernel.h>

Initialize an event object.

This routine initializes an event object, prior to its first use.

Parameters
eventAddress of the event object.

◆ k_event_post()

uint32_t k_event_post ( struct k_event event,
uint32_t  events 
)

#include <zephyr/kernel.h>

Post one or more events to an event object.

This routine posts one or more events to an event object. All tasks waiting on the event object event whose waiting conditions become met by this posting immediately unpend.

Posting differs from setting in that posted events are merged together with the current set of events tracked by the event object.

Parameters
eventAddress of the event object
eventsSet of events to post to event
Return values
Previousvalue of the events in event

◆ k_event_set()

uint32_t k_event_set ( struct k_event event,
uint32_t  events 
)

#include <zephyr/kernel.h>

Set the events in an event object.

This routine sets the events stored in event object to the specified value. All tasks waiting on the event object event whose waiting conditions become met by this immediately unpend.

Setting differs from posting in that set events replace the current set of events tracked by the event object.

Parameters
eventAddress of the event object
eventsSet of events to set in event
Return values
Previousvalue of the events in event

◆ k_event_set_masked()

uint32_t k_event_set_masked ( struct k_event event,
uint32_t  events,
uint32_t  events_mask 
)

#include <zephyr/kernel.h>

Set or clear the events in an event object.

This routine sets the events stored in event object to the specified value. All tasks waiting on the event object event whose waiting conditions become met by this immediately unpend. Unlike k_event_set, this routine allows specific event bits to be set and cleared as determined by the mask.

Parameters
eventAddress of the event object
eventsSet of events to set/clear in event
events_maskMask to be applied to events
Return values
Previousvalue of the events in events_mask

◆ k_event_test()

static uint32_t k_event_test ( struct k_event event,
uint32_t  events_mask 
)
inlinestatic

#include <zephyr/kernel.h>

Test the events currently tracked in the event object.

Parameters
eventAddress of the event object
events_maskSet of desired events to test
Return values
Currentvalue of events in events_mask

◆ k_event_wait()

uint32_t k_event_wait ( struct k_event event,
uint32_t  events,
bool  reset,
k_timeout_t  timeout 
)

#include <zephyr/kernel.h>

Wait for any of the specified events.

This routine waits on event object event until any of the specified events have been delivered to the event object, or the maximum wait time timeout has expired. A thread may wait on up to 32 distinctly numbered events that are expressed as bits in a single 32-bit word.

Note
The caller must be careful when resetting if there are multiple threads waiting for the event object event.
Parameters
eventAddress of the event object
eventsSet of desired events on which to wait
resetIf true, clear the set of events tracked by the event object before waiting. If false, do not clear the events.
timeoutWaiting period for the desired set of events or one of the special values K_NO_WAIT and K_FOREVER.
Return values
setof matching events upon success
0if matching events were not received within the specified time

◆ k_event_wait_all()

uint32_t k_event_wait_all ( struct k_event event,
uint32_t  events,
bool  reset,
k_timeout_t  timeout 
)

#include <zephyr/kernel.h>

Wait for all of the specified events.

This routine waits on event object event until all of the specified events have been delivered to the event object, or the maximum wait time timeout has expired. A thread may wait on up to 32 distinctly numbered events that are expressed as bits in a single 32-bit word.

Note
The caller must be careful when resetting if there are multiple threads waiting for the event object event.
Parameters
eventAddress of the event object
eventsSet of desired events on which to wait
resetIf true, clear the set of events tracked by the event object before waiting. If false, do not clear the events.
timeoutWaiting period for the desired set of events or one of the special values K_NO_WAIT and K_FOREVER.
Return values
setof matching events upon success
0if matching events were not received within the specified time