记录自己的STM32的HAL库的学习之路,不定期更新…
一、Pinout
二、Clock Configuration
三、Configuration
四、Generate Code
代码
int main(void)
{
/* USER CODE BEGIN 1 */
uint8_t rxBuffer[5];
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
if(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_RXNE))
{
HAL_UART_Receive(&huart1,rxBuffer,5,1000);
HAL_UART_Transmit(&huart1,rxBuffer,5,1000);
}
}
/* USER CODE END 3 */
}