#include<Arduino.h>//#include <HardwareSerial.h>#include<USBSerial.h>//HardwareSerial Serial2(USART2); // 创建一个Serial2对象//Arduino IDE环境下需要启用下面2个宏// #define USBCON 1// #define USBD_USE_CDC 1//----------// #define USB_CDC_HID 1// put function declarations here:intmyFunction(int,int);#defineled1PC13#defineled2PA_5uint32_t TimerUART;//HardwareSerial Serial1(PA10, PA9);//RX,TX将Serialx(x=1-4)串口x的管脚指定到PA10,PA9引脚上//USBSerial SerialCDC; // 创建一个USBSerial对象// the setup function runs once when you press reset or power the boardvoidsetup(){// Serial1.begin(115200); // 初始化串口1作为调试串口// Serial.begin(115200); // Serial = Serial2初始化串口2作为调试信息输出// Serial.begin(115200);
Serial.begin();// initialize digital pin LED_BUILTIN as an output.// Serial1.setRx(PA10); // using pin name PY_n// Serial1.setTx(PA9); // using pin number PYn// Serial.begin(115200);pinMode(led1, OUTPUT);pinMode(led2, OUTPUT);// pinMode(LED_BUILTIN, OUTPUT);
TimerUART =HAL_GetTick();}// the loop function runs over and over again forevervoidloop(){if((HAL_GetTick()- TimerUART)>1000){digitalToggle(led1);digitalToggle(led2);
Serial.println("USART2(PA2 PA3)Arduino STM32F401RC \n");// delay(500); // wait for a second
Serial.printf("USART1(PA9 PA10)STM32F401 SysClockFreq:%d \r\n",HAL_RCC_GetSysClockFreq());
Serial.print("from SerialUSB data\n");
TimerUART =HAL_GetTick();}}// put function definitions here:intmyFunction(int x,int y){return x + y;}