/*测试函数接口操作timer0*/
s32 hardtimer_test_case01(void)
{
   u32 i=0; 
   s32 ret = 0;
   my_timer.func =(timer_func) for_timer_test;
   my_timer.mode = TIMER_PERIOD_COUNT;
   my_timer.timeout = 32768;
   my_timer.timerId = i;
   my_timer.para = i;
   osl_sem_init(SEM_EMPTY,&sem);
   ret = bsp_hardtimer_alloc(&my_timer);
   if (OK != ret)
   	return ERROR;
   ret = bsp_hardtimer_enable(my_timer.timerId);
   if (OK != ret)
   	return ERROR;
   osl_sem_down(&sem);
   ret = bsp_hardtimer_free(i);
   if (OK != ret)
   {
	osl_sem_up(&sem);
	osl_sema_delete(&sem);
	return ERROR;
    }
   osl_sem_up(&sem);
   osl_sema_delete(&sem);
   return OK;
}
/*测试非唤醒源软timer申请和加入链表,在回调函数外删除软timer
   超时时间较长*/
s32 st_softtimer_test_case13(void)
{
	s32 ret= 0;
	
	my_softtimer.func = for_softtimer_test_1;
	my_softtimer.para = 123;
	my_softtimer.timeout = 100;
	my_softtimer.wake_type=SOFTTIMER_NOWAKE;
	osl_sem_init(0,&sem1);
	
	 if (bsp_softtimer_create(&my_softtimer))
	   {
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n");
	    }
	 bsp_softtimer_add(&my_softtimer);
	ret = bsp_softtimer_delete(&my_softtimer);
	if (ret ==OK)
	{
	   ret = bsp_softtimer_free(&my_softtimer);
	   if (ret !=OK)
	   {
	   	bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"softtimer_test_6  free error\n");
		return ERROR;
	   }  
	   
	}
	else if(NOT_ACTIVE == ret)
	{
		osl_sem_down(&sem1);
		osl_sema_delete(&sem1);
	}
	return ret;	
}
s32 adp_test_case02(void)
{
	s32 ret = 0;
	unsigned int restTime;
	osl_sem_init(SEM_EMPTY,&sem);
	ret = DRV_TIMER_START(TIMER_ACPU_CPUVIEW_ID ,func,0,10000,0,TIMER_UNIT_NONE);
	if(ret!=0)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"DRV_TIMER_START fail\n");
		return ERROR;
	}
	ret = DRV_TIMER_GET_REST_TIME(TIMER_ACPU_CPUVIEW_ID,TIMER_UNIT_NONE,&restTime);
	if(ret!=0)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"DRV_TIMER_GET_REST_TIME fail\n");
		return ERROR;
	}
	bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"rest time = %d \n",restTime);
	osl_sem_down(&sem);
	ret = DRV_TIMER_STOP(TIMER_ACPU_CPUVIEW_ID);
	if(ret!=0)
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"DRV_TIMER_START fail\n");
		return ERROR;
	}
	osl_sema_delete(&sem);
	return OK;
}
Exemplo n.º 4
0
/* 通道去初始化 */
s32 bsp_icc_test_uninit(void)
{
	u32 i = 0;
	u32 channel_idx = 0;
	struct icc_channel *channel = NULL;
	struct icc_test_sub_channel *sub_channel = NULL;

	for(i = 0; i < ICC_VALIDE_CHN_NUM + 1; i++)
	{
		channel_idx = g_icc_init_info[i].real_channel_id;
		channel = g_icc_ctrl.channels[channel_idx];
		sub_channel =  &(g_icc_test.channels[i].sub_channels[0]);
		
		icc_safe_free(channel->rector);
		channel->func_size = g_icc_test.channels[channel_idx].func_size_bak;
		channel->rector = g_icc_test.channels[i].vec_bak;
		channel->fifo_recv->size = channel->fifo_send->size = g_icc_test.channels[i].fifo_size_bak;

		/* 分配的时候,子通道0的为buffer的起始地址 */
		icc_safe_free(sub_channel->wr_buf);
	}

	osl_sem_up(&g_icc_test.recv_task_sem);
	g_icc_test.recv_task_flag = 0;
	osl_sema_delete(&g_icc_test.recv_task_sem);

	return ICC_OK;
}
/*测试非唤醒源软timer申请和加入链表*/
s32 st_softtimer_test_case11(void)
{
	
	my_softtimer.func = for_softtimer_test_1;	
	my_softtimer.wake_type=SOFTTIMER_NOWAKE;
	my_softtimer.para = 1;
	my_softtimer.timeout = 100;
	osl_sem_init(0,&sem1);
	osl_sem_init(0,&sem5);
	osl_sem_init(0,&sem6);
	if (bsp_softtimer_create(&my_softtimer))
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n");
		return ERROR;
	}
	bsp_softtimer_add(&my_softtimer);
	my_sec_softtimer.func = for_softtimer_test_5;
	my_sec_softtimer.para = 2;
	my_sec_softtimer.timeout = 200;
	if (bsp_softtimer_create(&my_sec_softtimer))
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n");
		return ERROR;
	}
	bsp_softtimer_add(&my_sec_softtimer);
	my_thir_softtimer.func = for_softtimer_test_6;
	my_thir_softtimer.para = 3;
	my_thir_softtimer.timeout = 300;
	if (bsp_softtimer_create(&my_thir_softtimer))
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error \n");
		return ERROR;
	}
	bsp_softtimer_add(&my_thir_softtimer);
	osl_sem_down(&sem1);
	osl_sem_down(&sem5);
	osl_sem_down(&sem6);
	osl_sema_delete(&sem1);
	osl_sema_delete(&sem5);
	osl_sema_delete(&sem6);
	return OK;
}
/*测试唤醒源软timer申请和加入链表重复10次,每次都在回调函数修改超时时间*/
s32 st_softtimer_test_case03(void)
{
	
	my_softtimer.func = for_softtimer_test_3;	
	my_softtimer.para = 2;
	my_softtimer.timeout = 10;
	my_softtimer.wake_type=SOFTTIMER_WAKE;
	osl_sem_init(0,&sem3);
	if (bsp_softtimer_create(&my_softtimer))
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_SOFTTIMER,"create error\n");
		return ERROR;
	}
	bsp_softtimer_add(&my_softtimer);
	osl_sem_down(&sem3);
	osl_sema_delete(&sem3);
	return OK;
}
 s32 bsp_ipc_sem_delete(u32 u32SignalNum)
 {
	IPC_CHECK_PARA(u32SignalNum,IPC_SEM_BUTTOM);
	if(false == ipc_ctrl.sem_exist[u32SignalNum] )
	{
		bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"semphore not exists,may be deleted already.\n");
		return MDRV_ERROR;
	}
	else
	{
		if (osl_sema_delete(&(ipc_ctrl.sem_ipc_task[u32SignalNum])))
		{
			bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_IPC,"Delete semphore failed.\n");
			return MDRV_ERROR;
		}
		ipc_ctrl.sem_exist[u32SignalNum] = false;
		return MDRV_OK;
	}
 }
s32 k3_adp_test_case02(void)
{
    s32 ret = 0;
    osl_sem_init(SEM_EMPTY,&sem);
    ret = DRV_TIMER_START(TIMER_ACPU_OSA_ID,func,0,1000,0,TIMER_UNIT_MS);
    if(ret!=0)
    {
        bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"DRV_TIMER_START fail\n");
        return ERROR;
    }
    osl_sem_down(&sem);
    ret = DRV_TIMER_STOP(TIMER_ACPU_OSA_ID);
    if(ret!=0)
    {
        bsp_trace(BSP_LOG_LEVEL_ERROR,BSP_MODU_HARDTIMER,"DRV_TIMER_START fail\n");
        return ERROR;
    }
    osl_sema_delete(&sem);
    return OK;
}
Exemplo n.º 9
0
/*****************************************************************************
* 函 数 名     :  cshell_io_uninit
*
* 功能描述  : cshell去初始化
*
* 输入参数  :  SHELL_IO_CHAN *ptr_shell :shell指针
* 输出参数  :  无
*
* 返 回 值     :  无
*
* 修改记录  :
*****************************************************************************/
static int cshell_io_uninit(SHELL_IO_CHAN *ptr_shell)
{
    if (ptr_shell)
    {

        if (ptr_shell->shell_send_tid)
        {
            kthread_stop(ptr_shell->shell_send_tid);
            ptr_shell->shell_send_tid = 0;
        }
        if (ptr_shell->cshell_recv_sem)
        {
            //semDelete(ptr_shell->cshell_recv_sem);
			osl_sema_delete(&(ptr_shell->cshell_recv_sem));
            ptr_shell->cshell_recv_sem = NULL;
        }

        ptr_shell->ptr_drv_funcs = NULL;
    }
	return OK;
}