mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
feat(esp_hw_support): support sleep retention destroy callback
This commit is contained in:
@@ -52,7 +52,13 @@ typedef struct {
|
||||
} sleep_retention_create_callback_t;
|
||||
|
||||
typedef struct {
|
||||
sleep_retention_create_callback_t create; /*!< A function handle is used to register the implementation of creating a sleep retention linked list and is executed when the corresponding module is created */
|
||||
sleep_retention_callback_t handle;
|
||||
void *arg;
|
||||
} sleep_retention_destroy_callback_t;
|
||||
|
||||
typedef struct {
|
||||
sleep_retention_create_callback_t create; /*!< A function handle is used to register the implementation of creating a sleep retention linked list and is executed when the corresponding module is created */
|
||||
sleep_retention_destroy_callback_t destroy; /*!< The callback function handle is invoked after the sleep retention linked list is destroyed */
|
||||
} sleep_retention_module_callbacks_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -60,7 +60,10 @@ static inline void sleep_retention_module_object_ctor(struct sleep_retention_mod
|
||||
|
||||
static inline void sleep_retention_module_object_dtor(struct sleep_retention_module_object * const self)
|
||||
{
|
||||
self->cbs = (sleep_retention_module_callbacks_t) { .create = { .handle = NULL, .arg = NULL } };
|
||||
self->cbs = (sleep_retention_module_callbacks_t) {
|
||||
.create = { .handle = NULL, .arg = NULL },
|
||||
.destroy = { .handle = NULL, .arg = NULL }
|
||||
};
|
||||
}
|
||||
|
||||
static inline void set_dependencies(struct sleep_retention_module_object * const self, sleep_retention_module_bitmap_t depends)
|
||||
@@ -1075,7 +1078,12 @@ static esp_err_t passive_module_free(sleep_retention_module_t module)
|
||||
if (!references_exist(instance(module))) {
|
||||
if (!module_is_retained(module)) {
|
||||
sleep_retention_entries_destroy(module);
|
||||
err = module_action_wrapper(module, (BIT(31) | action(2)), passive_module_free);
|
||||
if (instance(module)->cbs.destroy.handle) {
|
||||
err = instance(module)->cbs.destroy.handle(instance(module)->cbs.destroy.arg);
|
||||
}
|
||||
if (err == ESP_OK) {
|
||||
err = module_action_wrapper(module, (BIT(31) | action(2)), passive_module_free);
|
||||
}
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
@@ -1096,7 +1104,12 @@ esp_err_t sleep_retention_module_free(sleep_retention_module_t module)
|
||||
if (!module_is_passive(instance(module))) {
|
||||
if (module_is_inited(module) && module_is_created(module) && !module_is_retained(module)) {
|
||||
sleep_retention_entries_destroy(module);
|
||||
err = module_action_wrapper(module, action(2), passive_module_free);
|
||||
if (instance(module)->cbs.destroy.handle) {
|
||||
err = instance(module)->cbs.destroy.handle(instance(module)->cbs.destroy.arg);
|
||||
}
|
||||
if (err == ESP_OK) {
|
||||
err = module_action_wrapper(module, action(2), passive_module_free);
|
||||
}
|
||||
} else {
|
||||
err = ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user