4、部分代码 1.串口初始化
bool InitSerial(uint32_t BaudRate) { UartHandle1.Instance = USART1; UartHandle1.Init.BaudRate = BaudRate; UartHandle1.Init.WordLength = UART_WORDLENGTH_8B; UartHandle1.Init.StopBits = UART_STOPBITS_1; UartHandle1.Init.Parity = UART_PARITY_NONE; UartHandle1.Init.HwFlowCtl = UART_HWCONTROL_NONE; UartHandle1.Init.Mode = UART_MODE_TX_RX; /******************************************************************************/ /*****************************************************************************/ if (HAL_UART_Init(&UartHandle1) != HAL_OK) { /* Initialization Error */ Print("USART1 Init failed."); } __HAL_UART_ENABLE_IT(&UartHandle1, UART_IT_RXNE); return true; }
|