add support for dynaminc sem and dynamic mutex

This commit is contained in:
mculover666
2021-03-11 09:46:24 +08:00
parent 54022c2481
commit da61aa0a49
8 changed files with 182 additions and 7 deletions

View File

@@ -124,6 +124,10 @@ typedef enum k_err_en {
K_ERR_TIMER_INVALID_OPT,
K_ERR_TIMER_STOPPED,
K_ERR_TIMER_RUNNING,
K_ERR_SEM_OUT_OF_MEMORY = 2200u,
K_ERR_MUTEX_OUT_OF_MEMORY = 2300u,
} k_err_t;
#endif /* _TOS_ERR_H_ */

View File

@@ -47,6 +47,19 @@ typedef struct k_mutex_st {
*/
__API__ k_err_t tos_mutex_create(k_mutex_t *mutex);
/**
* @brief Create a dynamic mutex.
* create a dynamic mutex.
*
* @attention None
*
* @param[in] mutex pointer to the pointer of the mutex.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.
*/
__API__ k_err_t tos_mutex_create_dyn(k_mutex_t **mutex);
/**
* @brief Destroy a mutex.
* destroy a mutex.

View File

@@ -61,6 +61,35 @@ __API__ k_err_t tos_sem_create_max(k_sem_t *sem, k_sem_cnt_t init_count, k_sem_c
*/
__API__ k_err_t tos_sem_create(k_sem_t *sem, k_sem_cnt_t init_count);
/**
* @brief Create a dynamic semaphore with a limitation of maximum count.
* create a dynamic semaphore with a limitation of maximum count.
*
* @attention None
*
* @param[in] sem pointer to the pointer of the semaphore.
* @param[in] init_count initial count of the semaphore.
* @param[in] max_count maximum count of the semaphore.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.
*/
__API__ k_err_t tos_sem_create_max_dyn(k_sem_t **sem, k_sem_cnt_t init_count, k_sem_cnt_t max_count);
/**
* @brief Create a dynamic semaphore.
* create a dynamic semaphore.
*
* @attention None
*
* @param[in] sem pointer to the pointer of the semaphore.
* @param[in] init_count initial count of the semaphore.
*
* @return errcode
* @retval #K_ERR_NONE return successfully.
*/
__API__ k_err_t tos_sem_create_dyn(k_sem_t **sem, k_sem_cnt_t init_count);
/**
* @brief Destroy a semaphore.
* destroy a semaphore.