Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMSIS-Driver USART events expansion #143

Open
MaxFlatline opened this issue Mar 11, 2024 · 5 comments
Open

CMSIS-Driver USART events expansion #143

MaxFlatline opened this issue Mar 11, 2024 · 5 comments
Labels
question Further information is requested

Comments

@MaxFlatline
Copy link

Hello!
I think there is a need to add additional event in driver, "half buffer transfer" event. In NMEA applications it could be extremely helpful, to start parcing while dma continues to receive data. But it seems that currently you get only rx/tx/transfer_complete event.
Thank you!

@JonatanAntoni JonatanAntoni added the question Further information is requested label Mar 11, 2024
@JonatanAntoni
Copy link
Member

Hi @MaxFlatline,

Thanks for getting in touch.

Could you please check if double (multiple) buffering [1] can solve your issue? I.e., instead of asking for a "half buffer transfer" event, try to split the buffer into two buffers of the half size. Once the first buffer is full (transfer complete event), instantly start another transfer for the other buffer. While the second buffer is used for transfer, you can process the first one without interfering.

Cheers,
Jonatan

[1] https://en.wikipedia.org/wiki/Multiple_buffering

@MaxFlatline
Copy link
Author

Hello @JonatanAntoni
Thank youfor your reply. Yes, i can and probably will use it, though it will be less optimal solution, since in my mcu there is an hardware feature of half-complete transfer detection. For now i guess it well be sufficient, but on high speeds it'll certainly cause data corruption on reception

@JonatanAntoni
Copy link
Member

Hi @MaxFlatline,

Well, thanks for adding the important bit that your hardware has hardware half-complete transfer detection. As this seems to be an optional hardware feature we'd need to check how to add optional support for such events.

Can you please provide more details about the hardware you are using? Please be aware that just enhancing the CMSIS-Driver API by another (optional) event doesn't change much. In a second step the implementation for you device would need to be enhanced as well. It depends on the maintainer of the DFP to do so. Well, you could provide your own custom implementation of course.

Thanks,
Jonatan

@MaxFlatline
Copy link
Author

@JonatanAntoni
Of cource, but it seems i'm a bit wrong, half-transfer detection is a feature of DMA, not USART module. I'm using an STM32L072 and it's DMA supports an interrupt on half-transfer event, so if you are using USART with DMA, you are able to use half-complete callback (in HAL)

@MiloradCvjetkovic
Copy link
Contributor

Hi @MaxFlatline,
it looks like this feature is not common across different vendors.
In your particular case, that functionality does not have to be provided by the CMSIS-Driver but you can implement those callbacks (for example HAL_UART_RxHalfCpltCallback) with your custom functionality, for example in that callback you can send event to your thread that can start processing available data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants