串口打印文本
- /**
- ******************************************************************************
- * @file main.c
- * @author Alexander
- * @version V1.0
- * @date 2022-xx-xx
- * @brief 串口中断接收测试
- ******************************************************************************
- * @attention
- *
- * 实验平台:HK32F030M开发板
- *
- ******************************************************************************
- */
- #include "hk32f030m.h"
- #include "bsp_usart.h"
- #include "bsp_led.h"
- static void Show_Message(void);
- enum{
- /* ftp */
- FTP_TEST = 10,
-
- };
- struct oam_excute_st
- {
- int (*doit)(char*, char* , int *);
- int (*dumpit)(char*, char* , int *, int );
- };
- extern struct oam_excute_st * oam_execute ;
- int ftp_test (char *buf, char *outbuf, int *len){
- printf("hello,world\n");
- // return 0;
- }
- struct oam_excute_st ftp_oam_table[]=
- {
- [FTP_TEST] = {.doit = ftp_test},
-
- };
- /**
- * @brief 主函数
- * @param 无
- * @retval 无
- */
- int main(void)
- {
- char ch,i;
-
- /* 初始化RGB彩灯 */
- LED_GPIO_Config();
-
- /* 初始化USART 配置模式为 115200 8-N-1 */
- USART_Config();
-
- /* 打印指令输入提示信息 */
- // Show_Message();
- while(1)
- {
- /* 获取字符指令 */
- // ch=getchar();
- // printf("接收到字符:%c\n",ch);
- // printf(" 指令 ------ LED状态 \n");
- ftp_oam_table[FTP_TEST].doit(NULL,NULL,&i);
- }
- }
- /**
- * @brief 打印指令输入提示信息
- * @param 无
- * @retval 无
- */
- static void Show_Message(void)
- {
- printf("\r\n 这是一个通过串口通信指令控制LED实验 \n");
- printf("使用 USART 参数为:%d 8-N-1 \n",DEBUG_USART_BAUDRATE);
- printf("开发板接到指令后控制LED状态,指令对应如下:\n");
- printf(" 指令 ------ LED状态 \n");
- printf(" 1 ------ LED1亮 \n");
- printf(" 2 ------ LED2亮 \n");
- printf(" 3 ------ LED3亮 \n");
- printf(" 4 ------ LED1灭 \n");
- printf(" 5 ------ LED2灭 \n");
- printf(" 6 ------ LED3灭 \n");
- printf(" 7 ------ LED1反转 \n");
- printf(" 8 ------ LED2反转 \n");
- printf(" 9 ------ LED3反转 \n");
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
- void assert_failed(char* file , uint32_t line)
- {
- /* User can add his own implementation to report the file name and line number,
- tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* Infinite loop */
-
- while (1)
- {
- }
- }
- #endif /* USE_FULL_ASSERT */
复制代码
原理图: 无
仿真: 无
代码:
程序.7z
(173.59 KB, 下载次数: 2)
|