Skip to content

Commit

Permalink
Make it possible to use the ADC in differential mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Yatekii committed Sep 27, 2020
1 parent e3f2000 commit 9a510ef
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions nrf-hal-common/src/saadc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ use embedded_hal::adc::OneShot;

pub use saadc::{
ch::{
config::{GAIN_A as Gain, REFSEL_A as Reference, RESP_A as Resistor, TACQ_A as Time},
config::{
GAIN_A as Gain, MODE_A as Mode, REFSEL_A as Reference, RESP_A as Resistor,
TACQ_A as Time,
},
pseln::PSELN_A as Pseln,
pselp::PSELP_A as Pselp,
},
Expand Down Expand Up @@ -107,6 +110,7 @@ impl<'a> Channel<'a> {
let SaadcChannelConfig {
reference,
gain,
mode,
resistor,
time,
} = config;
Expand All @@ -115,7 +119,7 @@ impl<'a> Channel<'a> {
w.refsel().variant(reference);
w.gain().variant(gain);
w.tacq().variant(time);
w.mode().se();
w.mode().variant(mode);
w.resp().variant(resistor);
w.resn().bypass();
w.burst().enabled();
Expand Down Expand Up @@ -213,6 +217,8 @@ pub struct SaadcChannelConfig {
pub reference: Reference,
/// Gain used to control the effective input range of the SAADC.
pub gain: Gain,
/// The mode of the differential ADC
pub mode: Mode,
/// Positive channel resistor control.
pub resistor: Resistor,
/// Acquisition time in microseconds.
Expand Down Expand Up @@ -266,6 +272,7 @@ impl Default for SaadcChannelConfig {
SaadcChannelConfig {
reference: Reference::VDD1_4,
gain: Gain::GAIN1_4,
mode: Mode::SE,
resistor: Resistor::BYPASS,
time: Time::_20US,
}
Expand Down

0 comments on commit 9a510ef

Please sign in to comment.