can't use HAL_UARTEx_ReceiveToIdle_DMA() with IDLE event
Hello,
I am trying to use the HAL_UARTEx_ReceiveToIdle_DMA function() but the IDLE function don't work.
I call the function here :
/* Extern variables */
extern UART_HandleTypeDef huart4;
extern osEventFlagsId_t comEventHandle;
extern osMessageQueueId_t sensorQueueHandle;
extern osEventFlagsId_t regEventHandle;
extern DMA_HandleTypeDef hdma_uart4_rx;
static void modbus_receive_DMA(void) {
buf_rec = 0; // reset the counter of received bytes in the buffer
/* Reset pin for receiving data */
HAL_GPIO_WritePin(RS485_SIEMENS_RE_GPIO_Port, RS485_SIEMENS_RE_Pin, GPIO_PIN_RESET);
if (HAL_UARTEx_ReceiveToIdle_DMA(&huart4, nmbs.msg.buf, sizeof(nmbs.msg.buf)) != HAL_OK) {
log_debug("HAL_UARTEx_ReceiveToIdle_DMA error");
}
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
if (huart == &huart4) {
modbus_receive_DMA();
}
}
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size) {
if (huart == &huart4) {
switch (HAL_UARTEx_GetRxEventType(huart)) {
case HAL_UART_RXEVENT_IDLE: // when Idle event occurred prior reception has
// been completed (nb of received data is lower
// than expected one).
packet_sended = 0; // clear flag of transmit
buf_rec = Size; // set size of received data
nmbs_error res_poll = nmbs_server_poll(&nmbs);
if (NMBS_ERROR_NONE != res_poll) {
// This will probably never happen, since we don't return < 0 in our
// platform funcs
}
// If there was no packet transmission, then we immediately switch to
// receive mode. Otherwise, this function will trigger an interrupt at the
// end of DMA packet transmission
if (!packet_sended)
modbus_receive_DMA();
break;
}
}
}




I have tryed to replace sizeof(nmbs.msg.buf) by 1 or 2 or 3 and it works but not in IDLE mode. So the function HAL_UARTEx_RxEventCallback works but not in the right way. I have seen on the forum lot of topics with the same problem but I am not able to fix it with my micro..
Do you have any idea ?
