串口打印文本
- /**
- ******************************************************************************
- * @file main.c
- * @author Alexander
- * @version V1.0
- * @date 2022-xx-xx
- * @brief 串口中斷接收測試
- ******************************************************************************
- * @attention
- *
- * 實驗平臺:HK32F030M開發(fā)板
- *
- ******************************************************************************
- */
- #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 主函數(shù)
- * @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狀態(tài) \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 參數(shù)為:%d 8-N-1 \n",DEBUG_USART_BAUDRATE);
- printf("開發(fā)板接到指令后控制LED狀態(tài),指令對應如下:\n");
- printf(" 指令 ------ LED狀態(tài) \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, 下載次數(shù): 2)
2024-3-26 13:39 上傳
點擊文件名下載附件
|