⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 STM32 USART1 2 3三串口收发
💻 C
字号:
#include "stm32f10x_lib.h"
#include "uet_gpio.h"
#include "stdio.h"

extern void SetupClock(void);
extern void SetupGPIO(void);
extern void SetupUSART(void);
extern int GetKey (void);
extern int GetKey_USART2 (void);
extern int GetKey_USART3 (void);
extern int SendChar_USART1 (int ch);
extern int SendChar_USART2 (int ch);
extern int SendChar_USART3 (int ch);


main()
{
  /*---Clock Configuration---*/
   SetupClock();

  /*---GPIO Configuration---*/
   SetupGPIO();	
   
   /* ---USART Configuration--*/
    SetupUSART();	   
   
   printf(" www.u-easytech.com\t\t\n");
   printf("\nPlease test the usart one by one!\t\t\t\n\n");
   printf("\n Connect USART1\t\t");
   printf("\n Please send the command:0x01\n\n");
   //USART_SendData(USART2, 'T');
   SendChar_USART2('N');
   //GetKey_USART2();
   while(1)
 {	   
   while(GetKey()!=0x01)
   {printf("\n Please send the 0x01 again:0x01\n\n");}
    printf("\nUSART1 is OK..........!\t\t\n\n\n");
    printf("\nPlease connect USART3\t\t\n\n\n");
  
    while(GetKey_USART3()!=0x03)
   { SendChar_USART3('F'); SendChar_USART3('a'); SendChar_USART3('i');
     SendChar_USART3('l');
     SendChar_USART3('d');
     SendChar_USART3('0');
     SendChar_USART3('3'); SendChar_USART3('\n');}
     SendChar_USART3('P');
     
     //GetKey_USART2();
       // while(GetKey_USART2()!=0x02)
    while(GetKey_USART2()!=0x02)
   {  SendChar_USART2('F'); SendChar_USART2('a'); SendChar_USART2('i');
      SendChar_USART2('l');
      SendChar_USART2('d');
      SendChar_USART2('0');
      SendChar_USART2('2');SendChar_USART3('\n'); }
      SendChar_USART2('P');
   }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -