您好,登錄后才能下訂單哦!
這篇文章將為大家詳細(xì)講解有關(guān)RT-Threadrt 中怎么用$Sub$main來(lái)擴(kuò)展main函數(shù),文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
現(xiàn)在的rt thread是3.1.2版,先看一下rt thread是怎么用$Sub$$main來(lái)擴(kuò)展main函數(shù)。
$Sub$$main函數(shù)的源碼定義在\src\components.c里。
#if defined(__CC_ARM) || defined(__CLANG_ARM) extern int $Super$$main(void); /* re-define main function */ int $Sub$$main(void) { rt_hw_interrupt_disable(); rtthread_startup(); return 0; } #elif defined(__ICCARM__) // for IAR... #elif defined(__GNUC__) extern int main(void); // for gcc.. #endif
有兩個(gè)子函數(shù):
1、rt_hw_interrupt_disable,關(guān)全局總中斷,定義在匯編文件\libcpu\arm\cortex-m3\context_rvds.S里。
;/* ; * rt_base_t rt_hw_interrupt_disable(); ; */ rt_hw_interrupt_disable PROC EXPORT rt_hw_interrupt_disable MRS r0, PRIMASK CPSID I BX LR ENDP
就是__set_primask(1),關(guān)中斷,只有FAULT和NMI中斷可以響應(yīng)。
2、rtthread_startup,啟動(dòng)rtt,也在\src\components.c里。
int rtthread_startup(void) { rt_hw_interrupt_disable(); /* board level initialization * NOTE: please initialize heap inside board initialization. */ rt_hw_board_init(); /* show RT-Thread version */ rt_show_version(); /* timer system initialization */ rt_system_timer_init(); /* scheduler system initialization */ rt_system_scheduler_init(); #ifdef RT_USING_SIGNALS /* signal system initialization */ rt_system_signal_init(); #endif /* create init_thread */ rt_application_init(); /* timer thread initialization */ rt_system_timer_thread_init(); /* idle thread initialization */ rt_thread_idle_init(); #ifdef RT_USING_SMP rt_hw_spin_lock(&_cpus_lock); #endif /*RT_USING_SMP*/ /* start scheduler */ rt_system_scheduler_start(); /* never reach here */ return 0; }
關(guān)于RT-Threadrt 中怎么用$Sub$main來(lái)擴(kuò)展main函數(shù)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。