用官網(wǎng)提供的EVT文件中的rtthread樣版工程創(chuàng)建線程后,線程一直處于就緒態(tài),不能運行打印出。
#include?"ch32l103.h" #include?#include?#include?"drivers/pin.h" #include?#include?#define?DBG_TAG?"main" rt_thread_t?th1_ptr?=?NULL; struct?rt_thread?th2?; rt_uint8_t?th2_stack[512]?=?{0}; void?th1_entry(void?*parameter) { ????int?i?=?0; ????for(i?=?0;?i?<?5?;?i++){ ????????rt_kprintf("th1?running...\n"); ????????rt_thread_mdelay(1000); ????} } void?th2_entry(void?*parameter) { ????int?i?=?0; ????for(i?=?0;?i?<?5?;?i++) ????{ ????????rt_kprintf("th2?running...\n"); ????????rt_thread_mdelay(1000); ????} } void?scheduler_hook(struct?rt_thread?*from,?struct?rt_thread?*to) { ????rt_kprintf("from:%s?--->?to:%s\n",from->name,to->name); } int?main(void) { ????int?ret?=?0; ????//??rt_scheduler_sethook(scheduler_hook); ????th1_ptr?=?rt_thread_create("th1_demo",th1_entry,NULL,1024,20,5); ????if(th1_ptr?==?RT_NULL){ ????????LOG_E("rt_thread_create?failed...\n"); ????????return?-RT_ENOMEM; ????} ????LOG_D("rt_thread_create?successed?...\n"); ????rt_thread_startup(th1_ptr); ????ret?=?rt_thread_init(&th2,?"th2_demo",?th2_entry,?NULL,?th2_stack,?\ ????????????sizeof(th2_stack),?19,?5); ????if(ret?<?0){ ????????LOG_E("rt_thread_init?failed...\n"); ????????return?ret; ????} ????LOG_D("rt_thread_init?successed?...\n"); ????rt_thread_startup(&th2); }
熱門產(chǎn)品 :
CH585: 集成高速USB和NFC的藍牙MCU