1 综述
/*
*********************************************************************************************************
* PEND ON SEMAPHORE
*
* Description: This function waits for a semaphore.
*
* Arguments : sem is a pointer to the event control block associated with the desired
* semaphore.
*
* wait_time 是一个可选的时间段(in clock ticks)
* 如果是非零,你的任务将等待资源直到设置的等待时间
* 如果是零,你的任务将要等到指定信号量或直到资源变得可用(或发生事件)
*
* Returns : TLS_OS_SUCCESS
* TLS_OS_ERROR
*********************************************************************************************************
*/
//该函数不可用于中断服务程序中
static __inline tls_os_status_t tls_os_sem_acquire(tls_os_sem_t *sem,
u32 wait_time)
{
INT8U error;
tls_os_status_t os_status;
unsigned int time;
if(0 == wait_time)
time = portMAX_DELAY;
else
time = wait_time;
error = xSemaphoreTake( sem, time );
if (error == pdPASS)
os_status = TLS_OS_SUCCESS;
else
os_status = TLS_OS_ERROR;
return os_status;
}
/*
*********************************************************************************************************
* 删除一个信号量
*
* Description: 这个函数删除一个信号量 and readies 所有任务保留信号量.
*
* Arguments : sem is a pointer to the event control block associated with the desired
* semaphore.
*
* Returns : TLS_OS_SUCCESS The call was successful and the semaphore was deleted
* TLS_OS_ERROR
*
*********************************************************************************************************
*/
static __inline tls_os_status_t tls_os_sem_delete(tls_os_sem_t *sem)
{
vSemaphoreDelete(sem);
return TLS_OS_SUCCESS;
}