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

SNS - Initial ADC Implementation #25

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

H00pyFr00d
Copy link

@H00pyFr00d H00pyFr00d commented Oct 10, 2024

Converted the adc.hpp from 2024. David and I discussed and realised that no ADC exclusive sensor was ever used last year, and so only the MUX code has ever been used

As such this is being temporarily abandoned, the work done thusfar (however minimal) is being kept here

(Update)

We determined that it was worth implementing, though because Embassy has ADC functionality most of the C++ implementation could be ignored

I've implemented something basic for ADC, but it's not been tested and will need looked at by somebody else

Copy link

linear bot commented Oct 10, 2024

HYPE-39 Implement ADC

@davidbeechey davidbeechey changed the title HYPE-39 - Initial ADC Implementation SNS - Initial ADC Implementation Oct 10, 2024
Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few changes are needed now because of the change in repo structure. You'll need to move the lib/io/stm32l476rg/src/adc.rs into boards/stm32l476rg/src/io. (You need to open the boards/stm32l476rg folder in VS Code to get IDE features from Rust Analyzer.) Not sure about the channel...

lib/io/src/adc.rs Show resolved Hide resolved
lib/io/stm32l476rg/src/adc.rs Outdated Show resolved Hide resolved
@H00pyFr00d H00pyFr00d marked this pull request as draft October 21, 2024 17:48
@H00pyFr00d
Copy link
Author

ADC implementation which passes cargo build, should (in theory) work

Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Figured out the channel thing:

  • embassy_stm32::adc::Adc::new takes in a peripheral which is the ADC on the board (there is more than one), e.g. p.ADC1
  • Then the AnyAdcChannel input to Adc::blocking_read is a pin which implements the AnyAdcChannel trait for selected ADC which was passed into new.

Basically makes sense to rename pin to channel anyway but otherwise looks perfect. To instantiate it would be this (I've just checked that this compiles properly):

let adc = Adc::new(p.ADC1);
let hyped_adc = Stm32l476rgAdc::new(adc, p.PA0.degrade_adc());

Also fix typos + formatting, then mark as ready for review :)

boards/stm32l476rg/src/io/adc.rs Outdated Show resolved Hide resolved
boards/stm32l476rg/src/io/adc.rs Outdated Show resolved Hide resolved
lib/io/src/adc.rs Outdated Show resolved Hide resolved
@davidbeechey davidbeechey marked this pull request as ready for review October 31, 2024 19:24
@davidbeechey davidbeechey added the needs-reviews Needs reviews, otherwise finished label Oct 31, 2024
@davidbeechey davidbeechey added the needs-testing Needs testing in the lab before merging label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-reviews Needs reviews, otherwise finished needs-testing Needs testing in the lab before merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants