-
Notifications
You must be signed in to change notification settings - Fork 223
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
How to get a pin's mask or pin number #14
Comments
I don't quite understand what you are trying to do. Can you please clarify, what your goal is? |
Similar to what your macro I described above is doing. I want to change a bit on a register. As currently analog read is not implemented I am trying to do it myself in the meantime: Sorry if I am not making myself clear enough, let me know if more info is needed and thanks for the help and effort! |
Still not quite sure ... But I think I got something for you: If you downgrade the pins, you can match them like this (or slightly different, this code is untested): let pin = pc3.downgrade();
if let atmega328p_hal::port::Pin::C(id, _) = pin {
// ...
} else {
panic!("Only pins of port C can be used for analog reads!");
} |
Yeah! This is exactly what I was looking for, that "id". Only correction "i think" is that this is the correct import that worked for me:
Thanks a lot for the help and assistance! Great work! |
I cannot seem to figure out how can I retrieve the pin number programmatically.
My intention is do be able to write something similar to what you do in /avr-generic/port.rs does but in my main code base:
For which I need $i.
But I am not able to find an way on how to obtain that number. Could you provide an example on how to achieve this?
The text was updated successfully, but these errors were encountered: