|
测试了一下钩子,下面这个函数做为钩子函数挂上,不加rt_thread_delay(),很正常,加上以后栈马上溢出。
void led_thread_switch(struct rt_thread* from, struct rt_thread* to)
{
if (strcmp(from->name, "led1") == 0)
{
GPIO_SetBits(GPIOC, GPIO_Pin_1);
rt_thread_delay(10);
GPIO_ResetBits(GPIOC, GPIO_Pin_2);
}
if (strcmp(from->name, "led2") == 0)
{
GPIO_ResetBits(GPIOC, GPIO_Pin_1);
rt_thread_delay(10);
GPIO_SetBits(GPIOC, GPIO_Pin_2);
}
}
因为钩子是在线程切换时被调用,rt_thread_delay() 是让出处理器,这样处理当然没有道理,但我就是想试一下,果然出错了。
为什么会这样呢? |
阿莫论坛20周年了!感谢大家的支持与爱护!!
知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)
|