7#ifndef _MODULE_STATE_EVENT_H_
8#define _MODULE_STATE_EVENT_H_
18#include <zephyr/sys/atomic.h>
26#define MODULE_ID_LIST_SECTION_PREFIX module_id_list
28#define MODULE_ID_PTR_VAR(mname) _CONCAT(__module_, mname)
29#define MODULE_ID_LIST_SECTION_NAME STRINGIFY(MODULE_ID_LIST_SECTION_PREFIX)
30#define MODULE_ID_PTR_VAR_EXTERN_DEC(mname) \
31 extern const void * const MODULE_ID_PTR_VAR(mname)
33extern const void *
const __start_module_id_list[];
34extern const void *
const __stop_module_id_list[];
44 return (__stop_module_id_list - __start_module_id_list);
58 return (__start_module_id_list + idx);
70 return ((
const size_t *)module_id - (
const size_t *)__start_module_id_list);
84 return *((
const char **)
id);
95#define MODULE_IDX(mname) ({ \
96 MODULE_ID_PTR_VAR_EXTERN_DEC(mname); \
97 &MODULE_ID_PTR_VAR(mname) - __start_module_id_list; \
104 ATOMIC_DEFINE(
f, CONFIG_CAF_MODULES_FLAGS_COUNT);
130 const atomic_t *target = mf->
f;
132 for (
size_t n = ATOMIC_BITMAP_SIZE(CONFIG_CAF_MODULES_FLAGS_COUNT); n > 0; --n) {
133 if (atomic_get(target++) != 0) {
151 return atomic_test_bit(mf->
f, module_idx);
162 atomic_clear_bit(mf->
f, module_idx);
173 atomic_set_bit(mf->
f, module_idx);
185 atomic_set_bit_to(mf->
f, module_idx, val);
277#define MODULE_ID(mname) ({ \
278 MODULE_ID_PTR_VAR_EXTERN_DEC(mname); \
279 &MODULE_ID_PTR_VAR(mname); \
292#if defined(MODULE) && !defined(MODULE_NAME)
298#define MODULE_NAME STRINGIFY(MODULE)
319 event->state =
state;
Application Event Manager header.
Application Event Manager profiler tracer header.
#define APP_EVENT_TYPE_DECLARE(ename)
Declare an event type.
Definition app_event_manager.h:143
#define APP_EVENT_SUBMIT(event)
Submit an event.
Definition app_event_manager.h:198
#define MODULE_ID_PTR_VAR(mname)
Definition module_state_event.h:28
#define MODULE_NAME
Definition module_state_event.h:298
static void module_flags_set_bit_to(struct module_flags *mf, size_t module_idx, bool val)
Set single module bit to specified value.
Definition module_state_event.h:183
module_state
Definition module_state_event.h:189
@ MODULE_STATE_OFF
Definition module_state_event.h:198
@ MODULE_STATE_STANDBY
Definition module_state_event.h:203
@ MODULE_STATE_COUNT
Definition module_state_event.h:209
@ APP_EM_ENFORCE_ENUM_SIZE
Definition module_state_event.h:212
@ MODULE_STATE_READY
Definition module_state_event.h:193
@ MODULE_STATE_ERROR
Definition module_state_event.h:206
static const char * module_name_get(const void *id)
Get name of the module with given id.
Definition module_state_event.h:80
static size_t module_idx_get(const void *module_id)
Get IDX of module with given id.
Definition module_state_event.h:68
static size_t module_count(void)
Get number of modules.
Definition module_state_event.h:42
static bool module_flags_check_zero(const struct module_flags *mf)
Check if there is 0 in all the flags.
Definition module_state_event.h:128
#define MODULE_ID(mname)
Get module ID.
Definition module_state_event.h:277
#define MODULE_ID_PTR_VAR_EXTERN_DEC(mname)
Definition module_state_event.h:30
static void module_flags_set_bit(struct module_flags *mf, size_t module_idx)
Set single module bit.
Definition module_state_event.h:171
static const void * module_id_get(size_t idx)
Get ID of module with given index.
Definition module_state_event.h:54
static bool module_check_id_valid(size_t module_idx)
Check if given module index is valid.
Definition module_state_event.h:115
static void module_flags_clear_bit(struct module_flags *mf, size_t module_idx)
Clear single module bit.
Definition module_state_event.h:160
static bool check_state(const struct module_state_event *event, const void *module_id, enum module_state state)
Check if the selected module reported the selected state.
Definition module_state_event.h:259
static void module_set_state(enum module_state state)
Submit module state event to inform that state of the module changed.
Definition module_state_event.h:312
static bool module_flags_test_bit(const struct module_flags *mf, size_t module_idx)
Test single module bit.
Definition module_state_event.h:149
#define MODULE_ID_LIST_SECTION_NAME
Definition module_state_event.h:29
atomic_t f[ATOMIC_BITMAP_SIZE(CONFIG_CAF_MODULES_FLAGS_COUNT)]
Definition module_state_event.h:104
Structure that provides a flag for every module available in application.
Definition module_state_event.h:103
struct app_event_header header
Definition module_state_event.h:234
const void * module_id
Definition module_state_event.h:237
enum module_state state
Definition module_state_event.h:240
Module state event.
Definition module_state_event.h:232