报的错误
(rt_object_get_type(&sem->parent.parent) == RT_Object_Class_Semaphore) assertion failed at function:rt_sem_release, line number:439
编译没问题,但是总是会打印这个错误,定位到了一个线程中,发现关闭释放信号量就可以了。故判断是信号量没有初始化问题,
原因是在信号量初始化之前有GPIO初始化和开启了中断,此时还没信号量初始化,就产生了中断,所以报错
没改之前的代码:
int BSP_VIN_Detection_Init(void)
{
LOG_D("adc_calibrattion = %d", adc_calibrattion);
Vin_Cfg();
rt_sem_init(&sem_vin, "sem_vin", 0, RT_IPC_FLAG_PRIO);
if (&sem_vin == RT_NULL)
{
LOG_E("create sem_vin fail");
}
rt_thread_init(&vin_thread,
"vin_thread",
vin_thread_entry,
RT_NULL,
&vin_thread_stack[0],
sizeof(vin_thread_stack),
VIN_THREAD_PRIORITY, VIN_THREAD_TIMESLICE);
if (!&vin_thread)
{
LOG_E("create vin_thread fail");
return -1;
}
rt_thread_startup(&vin_thread);
LOG_D("BSP_VIN_Detection_Init");
return RT_EOK;
}
改之后的代码:
int BSP_VIN_Detection_Init(void)
{
LOG_D("adc_calibrattion = %d", adc_calibrattion);
rt_sem_init(&sem_vin, "sem_vin", 0, RT_IPC_FLAG_PRIO);
if (&sem_vin == RT_NULL)
{
LOG_E("create sem_vin fail");
}
Vin_Cfg();
rt_thread_init(&vin_thread,
"vin_thread",
vin_thread_entry,
RT_NULL,
&vin_thread_stack[0],
sizeof(vin_thread_stack),
VIN_THREAD_PRIORITY, VIN_THREAD_TIMESLICE);
if (!&vin_thread)
{
LOG_E("create vin_thread fail");
return -1;
}
rt_thread_startup(&vin_thread);
LOG_D("BSP_VIN_Detection_Init");
return RT_EOK;
}
记录一下这个问题。