cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F407 HAL_UARTEx_ReceiveToIdle() function missing

DBara.1
Associate II

Hello. I am working on a project where i need to get different lenghts of data using UART and preferebly with least possible amount of iterrupts, so ive settled to using HAL_UARTEx_ReceiveToIdle() function (when testing the project on F103), but when i moved the project onto F407, i cant seem to find this function.. Was it for some reason removed or renamed, or is my enviroment messing with me?..

12 REPLIES 12

@Piranha​ : Circular DMA never stops reception when using HAL_UART_Receive_DMA.

Not sure, sorry. Perhaps the files in the repository location were replaced manually. Perhaps IOC isn't using the latest library version. Those are things I would check. Could also generate the project for CubeIDE and see if results are different. Good luck.
If you feel a post has answered your question, please click "Accept as Solution".

Yes, but that one doesn't use IDLE or RTO interrupts. But it looks like there are HAL_UARTEx_ReceiveToIdle_DMA(), which can do both - continuous reception with DMA in circular mode and report IDLE interrupts. Therefore my previous comment now is a bit misleading. WOW, it took them only 14 years to get UART working... If they keep this mind-blowing pace, they can even get Ethernet working by the end of this century! And why are the "Ex" functions located in "non-Ex" files?

But wait...

https://github.com/STMicroelectronics/STM32CubeF4/blob/3d6be4bd406f275728e0a321cc371c62a3100533/Projects/STM32F429ZI-Nucleo/Examples/UART/UART_ReceptionToIdle_CircularDMA/Src/main.c#L335

A software FIFO buffer is still not managed in a driver and must be managed in application code. Even now, when, because of using IDLE interrupt, the buffer management is not so trivial anymore. Also the example does unnecessary data copying... byte-by-byte! And this junk is presented as a solution and a high level abstraction layer? I'll show an abstraction layer:

res_t DRV_USART_RxDataGet(struct drv_usart_s *hDRV, void **ppbData);
void DRV_USART_RxDataAck(struct drv_usart_s *hDRV, size_t nbData);
 
res_t res;
void *pbData;
 
for (;;) {
	ulTaskNotifyTake(pdTRUE, portMAX_DELAY);
	while ((res = DRV_USART_RxDataGet(hDRV, &pbData)) > 0) {
		Application_DataProcess(pbData, res);
		DRV_USART_RxDataAck(hDRV, res);
	}
}

Continuous reception, IDLE interrupt, software FIFO, zero-copy and it can be implemented with or without DMA. The API usage is trivial and the driver internal code is not that complex either.