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

Add delay provider #5

Open
xoviat opened this issue Dec 22, 2020 · 2 comments
Open

Add delay provider #5

xoviat opened this issue Dec 22, 2020 · 2 comments

Comments

@xoviat
Copy link

xoviat commented Dec 22, 2020

This and other projects may require a delay provider (for example: https://github.com/stm32-rs/stm32f4xx-hal/blob/master/src/delay.rs) that provides delayms and delayus functions. lt should be possible to provide this functionality as part of this package. I am new to rust (I thought it could be a better option than c), but I use pdMS_TO_TICKS in C.

@xoviat
Copy link
Author

xoviat commented Dec 22, 2020

I've partially implemented something, but then realized that FreeRTOS does not provide accurate timing below 1ms (configTICK_RATE_HZ for me is set to 1000, which I think means the minimum delay is 1ms). So a better solution would be that for delays less than 1ms, the standard delay library is used, and for delays above 1 ms, the FreeRTOS delay is used? Of course, the FreeRTOS delay is less accurate, but that might not be a problem? What are your thoughts on this?

@xoviat xoviat closed this as completed Dec 26, 2020
@niondir
Copy link
Member

niondir commented Dec 27, 2020

I basically agree.
I think that the FreeRTOS delay functions are perfect for most application timings where high accuracy isn't needed. Indeed it depends on the configTICK_RATE_HZ

An implementation could check if a given delay is above the minimum delay allowed based on configTICK_RATE_HZ and have some documentation about limited granularity.

I'm fine with accepting a PR to implement FreeRTOS based timing functions. There is also some API for "waitUntil" which is worth a look.
For drivers and hardware related timings (e.g. implementing 1-wire) one might still need to use system timers.

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

No branches or pull requests

2 participants