Skip to content

Commit

Permalink
Add notes about reference voltage
Browse files Browse the repository at this point in the history
  • Loading branch information
RossPorter506 committed Jan 20, 2025
1 parent 4a5caaf commit 1629c9b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//!
//! As a convenience, `.read_voltage_mv()` combines `.read()` and `.count_to_mv()`.
//!
//! Currently the only supported ADC voltage reference is `AVCC`, the operating voltage of the MSP430.
//!
//! The ADC may read from any of the following pins:
//!
//! P1.0 - P1.7 (channels 0 to 7), P5.0 - P5.3 (channels 8 to 11).
Expand Down Expand Up @@ -245,6 +247,8 @@ pub struct ClockSet(ClockSource);

/// Configuration object for an ADC.
///
/// Currently the only supported voltage reference is AVCC.
///
/// The default configuration is based on the default register values:
/// - Predivider = 1 and clock divider = 1
/// - 10-bit resolution
Expand Down Expand Up @@ -413,6 +417,8 @@ impl Adc {
}

/// Convert an ADC count to a voltage value in millivolts.
///
/// `ref_voltage_mv` is the reference voltage of the ADC in millivolts.
pub fn count_to_mv(&self, count: u16, ref_voltage_mv: u16) -> u16 {
use crate::pac::adc::adcctl2::ADCRES_A;
let resolution = match self.adc_reg.adcctl2.read().adcres().variant() {
Expand Down

0 comments on commit 1629c9b

Please sign in to comment.