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

Represent pins A6 and A7 of Arduino Nano similar to other pins #446

Open
Fundevoge opened this issue Nov 7, 2023 · 3 comments
Open

Represent pins A6 and A7 of Arduino Nano similar to other pins #446

Fundevoge opened this issue Nov 7, 2023 · 3 comments

Comments

@Fundevoge
Copy link
Contributor

As can be seen in the image, the Arduino Nano gives access to ADC_MUX 111 and ADC_MUX 110 via the pins A6 and A7.
It would be nice if these pins could be used somehow but it probably would require some refactoring as the availability of these pins depends on the package/board variant (TQFP and VQFN Package Only; Arduino Uno has the wrong package, Arduino Pro Mini does not forward it) and not on the processor variant.

@Rahix
Copy link
Owner

Rahix commented Nov 7, 2023

They are supported, access just works a bit different than for all the other pins. Check the example code here:

// Arduino Nano has two more ADC pins A6 and A7. Accessing them works a bit different from
// the other pins as they are not normal IO pins. The code below shows how it works.
let (a6, a7) = (
adc.read_blocking(&adc::channel::ADC6),
adc.read_blocking(&adc::channel::ADC7),
);
ufmt::uwrite!(&mut serial, "A6: {} A7: {}", a6, a7).void_unwrap();

@Fundevoge
Copy link
Contributor Author

I see, thanks for pointing it out.
It would be convenient to be able to use pins.a6 and then get a Pin<Analog, ADC6> or similar that does not implement the PinOps so it cannot be converted, but implements AdcChannel so a6.analog_read() is possible.
But I also understand that this is not the most important feature...

@Rahix
Copy link
Owner

Rahix commented Nov 19, 2023

If you manage to make this work nicely, I'd be happy to take a PR implementing this :)

So far my reasoning was that writing code generic over ADC channels is already possible using AdcChannel so I didn't bother going any further here.

@Rahix Rahix changed the title Support pins A6 and A7 of Arduino Nano Represent pins A6 and A7 of Arduino Nano similar to other pins Nov 19, 2023
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