Skip to content

Commit 6f457be

Browse files
authored
Merge pull request #245 from ceigel/adc_max
Add method get_max_value for adc
2 parents 589f5c8 + 73249a8 commit 6f457be

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/adc.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,16 @@ impl ADC {
243243
self.sample_time = sample_time;
244244
}
245245

246+
/// Get the max value for the current resolution
247+
pub fn get_max_value(&self) -> u16 {
248+
match self.resolution {
249+
Resolution::Bits12 => 4095,
250+
Resolution::Bits10 => 1023,
251+
Resolution::Bits8 => 255,
252+
Resolution::Bits6 => 63,
253+
}
254+
}
255+
246256
/// Release the ADC peripheral
247257
///
248258
/// Drops `ADC` and returns the `(pac::ADC, pad::ADC_COMMON)` that is was wrapping, giving the

0 commit comments

Comments
 (0)