2022-03-23 01:26 PM
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?..
2022-03-24 02:29 AM
@Piranha : Circular DMA never stops reception when using HAL_UART_Receive_DMA.
2022-03-24 06:18 AM
2022-03-24 02:29 PM
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...
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.