Skip to content

Commit

Permalink
Change default Sampletime to T_1
Browse files Browse the repository at this point in the history
This is the reset value of the ADC.
Now when running the example it is possible to get values other than 0
and 4095 by pressing the user button shortly.
  • Loading branch information
strom-und-spiele committed Jul 19, 2020
1 parent ff7a430 commit 26610c6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ pub struct Adc<ADC> {
/// There is always an overhead of 13 ADC clock cycles.
/// E.g. For Sampletime T_19 the total conversion time (in ADC clock cycles) is
/// 13 + 19 = 32 ADC Clock Cycles
// TODO: there are boundaries on how this can be set depending on the hardware.
// Check them and implement a sample time setting mechanism.
pub enum SampleTime {
T_1,
T_2,
Expand All @@ -59,8 +57,9 @@ pub enum SampleTime {
}

impl Default for SampleTime {
/// T_1 is also the reset value.
fn default() -> Self {
SampleTime::T_19
SampleTime::T_1
}
}

Expand Down Expand Up @@ -426,6 +425,7 @@ macro_rules! adc_hal {
}

/// Note: only allowed when ADSTART = 0
// TODO: there are boundaries on how this can be set depending on the hardware.
fn set_chan_smps(&self, chan: u8, smp: SampleTime) {
match chan {
1 => self.rb.smpr1.modify(|_, w| w.smp1().bits(smp.bitcode())),
Expand Down

0 comments on commit 26610c6

Please sign in to comment.