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


#ifndef _HV_VOS_MUTEX_H
#define _HV_VOS_MUTEX_H

#include "hv_vos_Types.h"

VOS_EXTERN_C_BEGIN

/** @defgroup VOS_MUTEX VOS_MUTEX
 *  VOS mutex functions
 *  @{
 */


/** @brief mutex forward declaration */
typedef struct _HV_VOS_MUTEX_S HV_VOS_MUTEX_S;

/** @brief Create mutex
 *
 * @return mutex pointer, return NULL if create fail
*/
HV_VOS_MUTEX_S *Hv_Vos_MutexInit();

/** @brief Destroy mutex
 *
 * @param self mutex pointer
 * @return result
*/
void Hv_Vos_MutexCleanup(HV_VOS_MUTEX_S *self);


/** @brief Lock mutex
 *
 * @param self mutex pointer
*/
void Hv_Vos_MutexLock(HV_VOS_MUTEX_S *self);


/** @brief Unlock mutex
 *
 * @param self mutex pointer
*/
void Hv_Vos_MutexUnlock(HV_VOS_MUTEX_S *self);

/** @brief try lock mutex for a period
 *
 * @param self mutex pointer
 * @param timeoutMs lock waiting timeout milliseconds
 * @return return HV_TRUE for success, HV_FALSE for timeout
 */
BOOL Hv_Vos_MutexTimedLock(HV_VOS_MUTEX_S *self, UINT32 timeoutMs);

/** @} */ //end of group VOS_MUTEX


VOS_EXTERN_C_END


#endif



