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

DynamicPin IO is very slow #326

Open
snakehand opened this issue Sep 13, 2021 · 1 comment
Open

DynamicPin IO is very slow #326

snakehand opened this issue Sep 13, 2021 · 1 comment

Comments

@snakehand
Copy link

I am trying to do some I2C bitbanging ( not really for 824 since it has enough ports ), I then need dynamic pins so that I can both read and write to the pins. The problem is that every set_high() & set_low() ends up calling into Register::new() which is a rather expensive function to call as it is 30+ instructions long with many writes to memory, This severely hampers the speed at which I can switch the gpio pins. I am thinking that the Register block will be the same every time it is newed() and can be cached somehow ?

@hannobraun
Copy link
Member

Hi @snakehand, thank your for opening this issue.

Are you compiling with --release? I always assumed that the compiler would optimize this out, but looking at the code again, I'm not sure that's right. Maybe adding an #[inline(always)] to Registers::new will help though.

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