stm32 HAL UART DMA 发送
MCU STM32H743IIT6
const uint8_t TEXT_TO_SEND[]={"ALIENTEK Apollo STM32H7 DMA "}; const uint8_t TEXT_TO_SEND2[]={"hello world!"}; extern UART_HandleTypeDef huart1;
int main(void)
{
/* USER CODE BEGIN 1 */
/* 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_DMA_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
HAL_Delay(1000);
HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_0);
static int i = 0;
if(i++ % 2)
HAL_UART_Transmit_DMA(&huart1,TEXT_TO_SEND,sizeof(TEXT_TO_SEND));
else
HAL_UART_Transmit_DMA(&huart1,TEXT_TO_SEND2,sizeof(TEXT_TO_SEND2));
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}