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

allow to have TICK_HZ value other than ones already in the list #2961

Closed
djdisodo opened this issue May 18, 2024 · 1 comment
Closed

allow to have TICK_HZ value other than ones already in the list #2961

djdisodo opened this issue May 18, 2024 · 1 comment

Comments

@djdisodo
Copy link
Contributor

i'm trying to make driver for embassy_time
https://github.com/djdisodo/avr_tc0_embassy_time

for example on arduino uno, the source clock is 16MHz

and if i use 64 Prescalar that's 16MHz/64 so 250000Hz

(i used 256_000Hz for testing, which should be close enough)

i can just upscale/downscale the ticks every time but it adds a bit of complexity,

also i don't want to create preset to account for different source clock

i have an idea,

it's still nightly feature but by using proc_macro_tracked_env

macro crate link

const TICK_HZ: usize = env_int!(TICK_HZ, 16000000);

you can do something like this, this will default to 16000000 if TICK_HZ environment variable isn't defined

and will use TICK_HZ as value if possible, only recompiles when TICK_HZ value is changed

@Dirbaio
Copy link
Member

Dirbaio commented May 20, 2024

I'd prefer to not add a new dependency just for this. It's possible to do it with no deps, from build.rs. See how ekv does it: https://github.com/embassy-rs/ekv/blob/main/build.rs

If you want to send a PR for that, it'd be great.

Also, we can simply add the needed tick rates too.

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