/*
 * @file hv_vos_Semaphore.h
 * @brief Header file of Semaphore.
 *
 * @verbatim
 * ==============================================================================
 *                        ##### How to use #####
 * ==============================================================================
 * (+) Use ()
 *
 * @endverbatim
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-03-01
 */


#ifndef _HV_VOS_SEMAPHORE_H
#define _HV_VOS_SEMAPHORE_H

#include "hv_vos_Types.h"

VOS_EXTERN_C_BEGIN

/** @defgroup VOS_SEMAPHORE VOS_SEMAPHORE
 *  VOS semaphore functions
 *  @{
 */


/** @brief semaphore forward declaration */
typedef struct _HV_VOS_SEMAPHORE_S HV_VOS_SEMAPHORE_S;

/** @brief Create semaphore
 *
 * @return semaphore pointer, return NULL if create fail
*/
HV_VOS_SEMAPHORE_S *Hv_Vos_InitSemaphore(int maxCount, int initialCount);

/** @brief Destroy semaphore
 *
 * @param self semaphore pointer
 * @return result
*/
void Hv_Vos_CleanupSemaphore(HV_VOS_SEMAPHORE_S *self);

/** @brief acquire semaphore
 *
 * @param self semaphore pointer
*/
BOOL Hv_Vos_AcquireSemaphore(HV_VOS_SEMAPHORE_S *self);


/** @brief acquire semaphore
 *
 * @param self semaphore pointer
 * @param timeoutMs wait milliseconds
*/
BOOL Hv_Vos_TimedAcquireSemaphore(HV_VOS_SEMAPHORE_S *self,UINT32 timeoutMs);


/** @brief release semaphore
 *
 * @param self semaphore pointer
*/
BOOL Hv_Vos_ReleaseSemaphore(HV_VOS_SEMAPHORE_S *self);


/** @brief release semaphore in ISR
 *
 * @param self semaphore pointer
*/
BOOL Hv_Vos_ReleaseSemaphoreFromISR(HV_VOS_SEMAPHORE_S *self);


/** @} */ //end of group VOS_SEMAPHORE

VOS_EXTERN_C_END


#endif



