uint8_t rDataBuffer[1]; // RX Data buffer
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
uint8_t rDataCount = 0; // count Data bytes
uint8_t rDataFlag = 0; // waitting complete RX date having been send
/* Prevent unused argument(s) compilation warning */
UNUSED(huart);
/* NOTE: This function should not be modified, when the callback is needed,
the HAL_UART_RxCpltCallback could be implemented in the user file
*/
//while(HAL_UART_Receive_IT(huart, rDataBuffer, 1) != HAL_OK); // Wait completly receive 1 byte data, and put data in rDataBuffer
printf("%c", rDataBuffer[0]);
HAL_UART_Receive_IT(huart, rDataBuffer, 1);
}
作者: john 时间: 2022-1-5 17:10
补充下,使用的是TWR-400的模块作者: john 时间: 2022-1-11 15:54
初始化:
//enable uart interrupt
if (HAL_OK == HAL_UART_Receive_IT(&huart1,(uint8_t *)rDataBuffer,REC_LENGTH)){