接着在main.c文件中写一个外设初始化的函数chip_init,将CUBE生成的外设初始化函数中该函数内,用rtthread初始化列表的形式进行外设初始化: 然后重定向rt_kprintf函数到串口1: #ifdef RT_USING_CONSOLE void rt_hw_console_output(const char *str) { HAL_UART_Transmit(&huart1, (uint8_t *)str, rt_strle...
1、添加rt_hw_console_output(const char *str)控制台/串口输出函数的实现 (在usart.c文件中,基于CubeMx生成的工程-HAL库) 2、使用rtt实现的rt_kprintf接口输出调试信息验证 3、添加RTE_USING_FINSH宏定义,开启使用finsh组件 4、实现finsh组件接受指令的函数rt_hw_console_getchar(void) 5、编译,找不到finsh_a...
串口初始化工作我们已使用cubemx完成,rtconfig.h 中使能 RT_USING_CONSOLE,在此前我们可以在usr_main中使用HAL_UART_Transmit();测试串口输出 Core/Src/usart.c中添加对接函数rt_hw_console_output,打印出了启动信息 //对接的 rt_hw_console_output() 函数,实现控制台字符输出voidrt_hw_console_output(constchar...
void rt_hw_console_output(const char *str); 1. 示例代码:如下是基于STM32F103 HAL库的串口驱动对接的 rt_hw_console_output() 函数,实现控制台字符输出,示例仅做参考。 void rt_hw_console_output(const char *str) 1. { 1. rt_size_t i = 0, size = 0; 1. 1. char a = '\r'; 1. 1....
/* 移植控制台,实现控制台输出, 对接 rt_hw_console_output */voidrt_hw_console_output(constchar*str){rt_size_t i=0,size=0;chara='\r';__HAL_UNLOCK(&HUART);size=rt_strlen(str);for(i=0;i<size;i++){if(*(str+i)=='\n'){HAL_UART_Transmit(&HUART,(uint8_t*)&a,1,1);}HAL...
如果我们使用的是HAL库,rt_hw_console_output函数就需要做不一样的修改,使用HAL库的串口发送函数接口,具体见代码清单:rt_kprintf-3高亮部分。 代码清单:rt_kprintf-3重映射串口控制台到rt_kprintf函数¶ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ...
RT-thread(2)RT-Thread 控制台与重载void rt_hw_console_output()函数 https://www.cnblogs.com/excellentHellen/articles/16963025.html RT-thread(3)RT-Thread的定时器 简单例程(基于HAL库,在keil中使用程序框架) https://www.cnblogs.com/excellentHellen/articles/16963097.html ...
实现rt_hw_console_output 实现finsh 组件输出一个字符,即在该函数中实现 uart 输出字符:1/* 实现 2:输出一个字符,系统函数,函数名不可更改 */ 2voidrt_hw_console_output(constchar*str); 示例代码:如下是基于STM32F103 HAL 串口驱动对接的 rt_hw_console_output() 函数,实现控制台字符输出,示例仅做参考。
示例代码:如下是基于STM32F103 HAL 串口驱动对接的 rt_hw_console_output() 函数,实现控制台字符输出,...
b. 增加了两条接收串口和发送数据的函数rt_hw_console_output/rt_hw_console_getchar . c. 增加了两条命令:分别是启动led闪烁线程和关闭led闪烁线程 MSH_CMD_EXPORT(led_start,ledon) ; MSH_CMD_EXPORT(led_exit,ledexit) ; d. 串口出事话必须要在启动mian前就初始化: ...