/** * @file mainfunction.h * @brief Main function api * * @copyright Copyright (c) 2022 Semidrive Semiconductor. * All rights reserved. */ #ifndef __MAIN_FUNCTION #define __MAIN_FUNCTION #include #include #ifdef CONFIG_MAINFUNCTION_NODE_MAX #define MAINFUNCTION_NODE_MAX CONFIG_MAINFUNCTION_NODE_MAX #else #define MAINFUNCTION_NODE_MAX 4 #endif /** @brief callback function. */ typedef void (*module_callback_t)(void *userdata); /** @brief MainFunction module configurations struct. */ typedef struct module_mainfunction { bool valid; /**< This object is valid or not. */ uint32_t period_ms; /**< The period(ms) of calling module's callback function. */ uint32_t count; /**< Current count of ms. */ module_callback_t callback; /**< The callback function of user's module. */ void *userdata; /**< User's param of callback function. */ } module_mainfunction_t; /** @brief MainFunction return status. */ typedef enum mainfunction_ret_status { STATUS_MAINFUNCTION_SUCCESS, /**< Success state.*/ STATUS_MAINFUNCTION_NOSPACE, /**< Attached node is up to max. No space can be used by new module. */ STATUS_MAINFUNCTION_UNATTACHED, /**< The module is not attached before. */ STATUS_MAINFUNCTION_FAIL, /**