完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
看keil和studio有一丝不同,所以标注的是KEIL,keil使用armc,rtthread-studio使用GNUC
一、首先进入COMPONENTS.c文件中的函数 int $Sub$$main(void) { rtthread_startup(); 返回0; } 二、rtthread_startup();详解 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; } #endif 详解1、 rt_hw_interrupt_disable();关闭中断 rt_hw_interrupt_disable PROC EXPORT rt_hw_interrupt_disable MRS r0, PRIMASK CPSID I BX LR ENDP ;/* ; * void rt_hw_interrupt_enable(rt_base_t level); ; */ rt_hw_interrupt_enable PROC EXPORT rt_hw_interrupt_enable MSR PRIMASK, r0 BX LR ENDP 位置:context_rvds.S 2、位置drive_common.c RT_WEAK void rt_hw_board_init() { #ifdef SCB_EnableICache /* Enable I-Cache---------------------------------------------------------*/ SCB_EnableICache(); #endif #ifdef SCB_EnableDCache /* Enable D-Cache---------------------------------------------------------*/ SCB_EnableDCache(); #endif /* HAL_Init() function is called at the beginning of the program */ HAL_Init();//hal库初始化 /* enable interrupt */ __set_PRIMASK(0); /* System clock initialization */ SystemClock_Config();//时钟初始化 /* disable interrupt */ __set_PRIMASK(1); rt_hw_systick_init(); /* Heap initialization */ #if defined(RT_USING_HEAP) rt_system_heap_init((void *)HEAP_BEGIN, (void *)HEAP_END); #endif /* Pin driver initialization is open by default */ #ifdef RT_USING_PIN rt_hw_pin_init();//后期再聊的知识点 #endif /* USART driver initialization is open by default */ #ifdef RT_USING_SERIAL rt_hw_usart_init();//串口初始化 #endif /* Set the shell console output device */ #ifdef RT_USING_CONSOLE rt_console_set_device(RT_CONSOLE_DEVICE_NAME);//控制台初始化 #endif /* Board underlying hardware initialization */ #ifdef RT_USING_COMPONENTS_INIT rt_components_board_init();//划重点,第二章说 #endif } 3、rt_show_version(); 程序开始启动的时候显示串口的版本等 4、system_timer_init(); 5、rt_system_scheduler_init();内核的东西不说 6、rt_application_init void rt_application_init(void) { rt_thread_t tid; #ifdef RT_USING_HEAP tid = rt_thread_create("main", main_thread_entry, RT_NULL, RT_MAIN_THREAD_STACK_SIZE, RT_MAIN_THREAD_PRIORITY, 20); RT_ASSERT(tid != RT_NULL); #else rt_err_t result; tid = &main_thread; /* #define RT_MAIN_THREAD_STACK_SIZE 2048 #define RT_MAIN_THREAD_PRIORITY 10*/ result = rt_thread_init(tid, "main", main_thread_entry, RT_NULL, main_stack, sizeof(main_stack), RT_MAIN_THREAD_PRIORITY, 20); RT_ASSERT(result == RT_EOK); /* if not define RT_USING_HEAP, using to eliminate the warning */ (void)result; #endif rt_thread_startup(tid); } void main_thread_entry(void *parameter) { extern int main(void); extern int $Super$$main(void); #ifdef RT_USING_COMPONENTS_INIT /* RT-Thread components initialization */ rt_components_init(); #endif #ifdef RT_USING_SMP rt_hw_secondary_cpu_up(); #endif /* invoke system main function */ #if defined(__CC_ARM) || defined(__CLANG_ARM) $Super$$main(); /* for ARMCC. */ #elif defined(__ICCARM__) || defined(__GNUC__) main(); #endif } 画重点: rt_components_init();这人函数是rtthread最好用的函数。 |
|
|
|
只有小组成员才能发言,加入小组>>
3269 浏览 9 评论
2947 浏览 16 评论
3446 浏览 1 评论
8967 浏览 16 评论
4041 浏览 18 评论
1084浏览 3评论
562浏览 2评论
const uint16_t Tab[10]={0}; const uint16_t *p; p = Tab;//报错是怎么回事?
556浏览 2评论
用NUC131单片机UART3作为打印口,但printf没有输出东西是什么原因?
2294浏览 2评论
NUC980DK61YC启动随机性出现Err-DDR是为什么?
1849浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-13 04:58 , Processed in 1.014826 second(s), Total 79, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号