如果要更改发送接收数据的串口怎么办?
- /*****usart.c*****/
- UART_HandleTypeDef huart1; //假如这个是串口1的结构体
- UART_HandleTypeDef huart2; //假如这个是串口2的结构体
-
- /***stm32f1xx_it.c***/
-
- void USART1_IRQHandler(void) //串口1中断函数
- {
- uint8_t ch=0;
-
- if(__HAL_UART_GET_FLAG( &huart1, UART_FLAG_RXNE ) != RESET)
- {
- ch=( uint16_t)READ_REG(huart1.Instance->DR);
- WRITE_REG(huart1.Instance->DR,ch);
-
- }
- }
-
- void USART2_IRQHandler(void) //串口2中断函数
- {
- uint8_t ch=0;
-
- if(__HAL_UART_GET_FLAG( &huart2, UART_FLAG_RXNE ) != RESET)
- {
- ch=( uint16_t)READ_REG(huart2.Instance->DR);
- WRITE_REG(huart2.Instance->DR,ch);
-
- }
- }
|