how HAL_UARTEx_RxEventCallback is executed?
Hello! Im receiving data by UART with DMA and now I wonder, how is HAL_UARTEx_RxEventCallback is ejecuted?
Because I'm receiving and saving chunks of data in a buffer, then adding a header and a tail in this buffer to send it by USB, but I realized that I'm overwritting the next chunk of data data, even when debugging.
Are callback events ocurring simultaneously in background?
How can I set a buffer that only keep the current chunk of data? Maybe a static buffer?
This is my code if you want to check, this is my UserDataTreatment called in the callback function
void UserDataTreatment(UART_HandleTypeDef *huart, uint8_t* pData, uint16_t Size){
uint8_t Tail[] = ",END#";
uint8_t Head[] = "@HEAD=ACEL1";
if(huart->Instance == USART1){
uint8_t* pBuff = pData;
uint32_t i;
uint8_t DataArray[USB_BUFFER_SIZE];
for (i = 0; i < HEAD_LENGTH; i++){
DataArray[i] = Head[i];
}
for (i = HEAD_LENGTH; i < HEAD_LENGTH+Size; i++){
DataArray[i] = *pBuff;
pBuff++;
}
for (i = 0; i < TAIL_LENGTH; i++){
DataArray[HEAD_LENGTH+Size+i] = Tail[i];
}
CDC_Transmit_FS(DataArray, HEAD_LENGTH+Size+TAIL_LENGTH);
}
}