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

Support Arduino Nano in arduino-uno crate #69

Merged
merged 3 commits into from
Sep 12, 2020
Merged

Support Arduino Nano in arduino-uno crate #69

merged 3 commits into from
Sep 12, 2020

Conversation

Rahix
Copy link
Owner

@Rahix Rahix commented Sep 7, 2020

Implement support for Arduino Nano as proposed in issue #64.

@Rahix
Copy link
Owner Author

Rahix commented Sep 7, 2020

If someone with an Arduino Nano (not Arduino Nano Every) could give this a try (especially the ADC example), it would be much appreciated! I can't really test whether ADC6 and ADC7 now work as intended ...

@kallemooo
Copy link
Contributor

kallemooo commented Sep 7, 2020

Tested uno-adc.rs on an Arduino Nano.
All ADC channels works as expected.

One suggestion is to add in board documentation or uno-adc.rs how to build the example with the feature 'arduino-nano' enabled.

Test build command:
cargo +nightly build --example uno-adc --features 'arduino-nano'

Test run command:
cargo +nightly run --example uno-adc --features 'arduino-nano'

Test 1

Connected pins:

  • ADC7 connected to 3.3 v
  • ADC6 connected to 5.0 v
  • ADC5 to ADC0 floating

Serial output

Vbandgap: 383
GND: 0
A0: 92 A1: 121 A2: 171 A3: 214 A4: 221 A5: 228 A6: 1023 A7: 696
A0: 565 A1: 468 A2: 423 A3: 406 A4: 360 A5: 331 A6: 1023 A7: 697
A0: 588 A1: 497 A2: 446 A3: 422 A4: 374 A5: 340 A6: 1022 A7: 696

Test 2

Connected pins:

  • ADC7 connected to GND
  • ADC6 connected to 3.3 v
  • ADC5 to ADC0 floating

Serial output

Vbandgap: 344
GND: 0
A0: 83 A1: 80 A2: 111 A3: 165 A4: 186 A5: 191 A6: 695 A7: 0
A0: 67 A1: 102 A2: 152 A3: 189 A4: 197 A5: 200 A6: 697 A7: 0
A0: 70 A1: 106 A2: 158 A3: 197 A4: 210 A5: 217 A6: 695 A7: 0

Show off all pins and channels in the Arduino Uno ADC example.

Signed-off-by: Rahix <rahix@rahix.de>
Some packages of ATmega328P expose the ADC6 and ADC7 signals.  Allow
accessing them when available.  For this, a new `adc-pins` crate feature
is added that needs to be enabled.

Signed-off-by: Rahix <rahix@rahix.de>
The Arduino Nano is very similar to Arduino Uno; add support for it to
the arduino-uno crate via an arduino-nano crate feature.

Signed-off-by: Rahix <rahix@rahix.de>
@Rahix
Copy link
Owner Author

Rahix commented Sep 12, 2020

@kallemooo, thanks so much! That's exactly what I was looking for.

@Rahix Rahix merged commit f7b9b3c into master Sep 12, 2020
@Rahix Rahix deleted the nano-support branch September 12, 2020 09:39
@tippfehlr
Copy link
Contributor

Sorry to bump this old issue.
Would it be possible/Why aren’t A6/7 accessed the way all the other pins are accessed? I guess that pins is general and extra-adc-pins only enables arduino-hal::adc?

@Rahix
Copy link
Owner Author

Rahix commented Jun 21, 2023

The reason is that these pins are not "normal". They can only be used for the ADC and do not support GPIO modes like all other pins. Thus we cannot simply reuse the existing port/pin code and need a different mechanism...

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

Successfully merging this pull request may close these issues.

3 participants