Update HAL_OS_tencentos_tiny.c
This commit is contained in:
@@ -32,7 +32,6 @@ void HAL_SleepMs(_IN_ uint32_t ms)
|
||||
(void)tos_sleep_hmsm(0,0,0, ms);
|
||||
}
|
||||
|
||||
|
||||
void HAL_Printf(_IN_ const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -61,15 +60,14 @@ int HAL_Vsnprintf(_IN_ char *str, _IN_ const int len, _IN_ const char *format, v
|
||||
return vsnprintf(str, len, format, ap);
|
||||
}
|
||||
|
||||
|
||||
void *HAL_Malloc(_IN_ uint32_t size)
|
||||
{
|
||||
return tos_mmheap_alloc(size);
|
||||
return tos_mmheap_alloc(size);
|
||||
}
|
||||
|
||||
void HAL_Free(_IN_ void *ptr)
|
||||
{
|
||||
tos_mmheap_free(ptr);
|
||||
tos_mmheap_free(ptr);
|
||||
}
|
||||
|
||||
void *HAL_MutexCreate(void)
|
||||
@@ -88,7 +86,7 @@ void *HAL_MutexCreate(void)
|
||||
|
||||
void HAL_MutexDestroy(_IN_ void *mutex)
|
||||
{
|
||||
k_err_t ret;
|
||||
k_err_t ret;
|
||||
|
||||
if (K_ERR_NONE != (ret = tos_mutex_destroy((k_mutex_t *)mutex))) {
|
||||
HAL_Printf("osal_mutex_destroy err, err:%d\n\r", ret);
|
||||
@@ -108,24 +106,24 @@ void HAL_MutexLock(_IN_ void *mutex)
|
||||
|
||||
int HAL_MutexTryLock(_IN_ void *mutex)
|
||||
{
|
||||
k_err_t ret;
|
||||
k_err_t ret;
|
||||
|
||||
if (K_ERR_NONE != (ret = tos_mutex_pend_timed((k_mutex_t *)mutex, 0))) {
|
||||
HAL_Printf("osal_mutex_lock err, err:%d\n\r", ret);
|
||||
return (int)ret;
|
||||
}
|
||||
if (K_ERR_NONE != (ret = tos_mutex_pend_timed((k_mutex_t *)mutex, 0))) {
|
||||
HAL_Printf("osal_mutex_lock err, err:%d\n\r", ret);
|
||||
return (int)ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void HAL_MutexUnlock(_IN_ void *mutex)
|
||||
{
|
||||
k_err_t ret;
|
||||
k_err_t ret;
|
||||
|
||||
if (K_ERR_NONE != (ret = tos_mutex_post((k_mutex_t *)mutex))) {
|
||||
HAL_Printf("osal_mutex_unlock err, err:%d\n\r", ret);
|
||||
}
|
||||
if (K_ERR_NONE != (ret = tos_mutex_post((k_mutex_t *)mutex))) {
|
||||
HAL_Printf("osal_mutex_unlock err, err:%d\n\r", ret);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(PLATFORM_HAS_CMSIS) && defined(AT_TCP_ENABLED)
|
||||
@@ -135,53 +133,52 @@ void HAL_MutexUnlock(_IN_ void *mutex)
|
||||
*/
|
||||
void * HAL_ThreadCreate(uint16_t stack_size, int priority, char * taskname,void *(*fn)(void*), void* arg)
|
||||
{
|
||||
osThreadId thread_t = (osThreadId)HAL_Malloc(sizeof(osThreadId));
|
||||
osThreadId thread_t = (osThreadId)HAL_Malloc(sizeof(osThreadId));
|
||||
|
||||
osThreadDef(taskname, (os_pthread)fn, (osPriority)priority, 0, stack_size);
|
||||
thread_t = osThreadCreate(osThread(taskname), arg);
|
||||
if(NULL == thread_t){
|
||||
HAL_Printf("create thread fail\n\r");
|
||||
}
|
||||
osThreadDef(taskname, (os_pthread)fn, (osPriority)priority, 0, stack_size);
|
||||
thread_t = osThreadCreate(osThread(taskname), arg);
|
||||
if(NULL == thread_t){
|
||||
HAL_Printf("create thread fail\n\r");
|
||||
}
|
||||
|
||||
return (void *)thread_t;
|
||||
return (void *)thread_t;
|
||||
}
|
||||
|
||||
int HAL_ThreadDestroy(void* threadId)
|
||||
{
|
||||
return osThreadTerminate(threadId);
|
||||
return osThreadTerminate(threadId);
|
||||
}
|
||||
|
||||
void *HAL_SemaphoreCreate(void)
|
||||
{
|
||||
return (void *)osSemaphoreCreate(NULL, 1);
|
||||
return (void *)osSemaphoreCreate(NULL, 1);
|
||||
}
|
||||
|
||||
void HAL_SemaphoreDestroy(void *sem)
|
||||
{
|
||||
osStatus ret;
|
||||
osStatus ret;
|
||||
|
||||
ret = osSemaphoreDelete ((osSemaphoreId)sem);
|
||||
if(osOK != ret)
|
||||
{
|
||||
HAL_Printf("HAL_SemaphoreDestroy err, err:%d\n\r",ret);
|
||||
}
|
||||
ret = osSemaphoreDelete ((osSemaphoreId)sem);
|
||||
if(osOK != ret)
|
||||
{
|
||||
HAL_Printf("HAL_SemaphoreDestroy err, err:%d\n\r",ret);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_SemaphorePost(void *sem)
|
||||
{
|
||||
osStatus ret;
|
||||
osStatus ret;
|
||||
|
||||
ret = osSemaphoreRelease ((osSemaphoreId) sem);
|
||||
ret = osSemaphoreRelease ((osSemaphoreId) sem);
|
||||
|
||||
if(osOK != ret)
|
||||
{
|
||||
HAL_Printf("HAL_SemaphorePost err, err:%d\n\r",ret);
|
||||
}
|
||||
if(osOK != ret)
|
||||
{
|
||||
HAL_Printf("HAL_SemaphorePost err, err:%d\n\r",ret);
|
||||
}
|
||||
}
|
||||
|
||||
int HAL_SemaphoreWait(void *sem, uint32_t timeout_ms)
|
||||
{
|
||||
return osSemaphoreWait ((osSemaphoreId)sem, timeout_ms);
|
||||
|
||||
return osSemaphoreWait ((osSemaphoreId)sem, timeout_ms);
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user