#define BuffSize 255
uint8_t aTxBuffer[BuffSize];
uint8_t aRxBuffer[BuffSize];
uint8_t value='F';
uint16_t len,i,rx_size;
/* USER CODE END 0 */
/* USER CODE BEGIN 2 */
//開啟中斷
if(HAL_UART_Receive_IT(&huart1,(uint8_t *)&value,1) != HAL_OK){
HAL_UART_Transmit(&huart1, (uint8_t *)&"ERROR\r\n",7,10);
while(1);
}
/* USER CODE END 2 */
/* USER CODE BEGIN 4*/
//回調部分
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
{
HAL_UART_Receive_IT(&huart1,(uint8_t *)&value,1);
aRxBuffer[rx_size]=value;
if(rx_size>=BuffSize){
rx_size=0;
}else{
rx_size++;
}
}
/* USER CODE END 4 */
沒有留言:
張貼留言