Skip to content

Commit

Permalink
fix adc read voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
dotcypress committed Nov 22, 2023
1 parent a272fa0 commit 0fea786
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/analog/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ impl Adc {
let vref = if let Some(vref) = &self.vref {
*vref
} else {
let vref_cal: u32 = unsafe { ptr::read_volatile(0x1FFF_75AA as *const u16) as u32 };
let vref_cal: u32 = unsafe { ptr::read_volatile(0x1FFF_756A as *const u16) as u32 };

let mut vref = VRef::new();
let vref_val: u32 = if vref.enabled(self) {
Expand All @@ -253,7 +253,7 @@ impl Adc {
};

self.read(pin).map(|raw: u32| {
let adc_mv = (vref as u32 * raw) >> 16;
let adc_mv = (vref as u32 * raw) >> 12;

Check warning on line 256 in src/analog/adc.rs

View workflow job for this annotation

GitHub Actions / clippy

casting to the same type is unnecessary (`u32` -> `u32`)

warning: casting to the same type is unnecessary (`u32` -> `u32`) --> src/analog/adc.rs:256:27 | 256 | let adc_mv = (vref as u32 * raw) >> 12; | ^^^^^^^^^^^ help: try: `vref` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
adc_mv as u16
})
}
Expand Down

0 comments on commit 0fea786

Please sign in to comment.