Merge #426
426: nrf/saadc: API improvements r=Dirbaio a=Dirbaio Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
commit
7318fc026e
@ -14,11 +14,11 @@ use crate::{pac, peripherals};
|
|||||||
|
|
||||||
use pac::{saadc, SAADC};
|
use pac::{saadc, SAADC};
|
||||||
|
|
||||||
|
// We treat the positive and negative channels with the same enum values to keep our type tidy and given they are the same
|
||||||
|
pub(crate) use saadc::ch::pselp::PSELP_A as InputChannel;
|
||||||
|
|
||||||
pub use saadc::{
|
pub use saadc::{
|
||||||
ch::{
|
ch::config::{GAIN_A as Gain, REFSEL_A as Reference, RESP_A as Resistor, TACQ_A as Time},
|
||||||
config::{GAIN_A as Gain, REFSEL_A as Reference, RESP_A as Resistor, TACQ_A as Time},
|
|
||||||
pselp::PSELP_A as InputChannel, // We treat the positive and negative channels with the same enum values to keep our type tidy and given they are the same
|
|
||||||
},
|
|
||||||
oversample::OVERSAMPLE_A as Oversample,
|
oversample::OVERSAMPLE_A as Oversample,
|
||||||
resolution::VAL_A as Resolution,
|
resolution::VAL_A as Resolution,
|
||||||
};
|
};
|
||||||
@ -228,17 +228,24 @@ impl<'d, const N: usize> Drop for OneShot<'d, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal.
|
pub(crate) mod sealed {
|
||||||
pub trait Input {
|
use super::*;
|
||||||
fn channel(&self) -> InputChannel;
|
|
||||||
|
pub trait Input {
|
||||||
|
fn channel(&self) -> InputChannel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// An input that can be used as either or negative end of a ADC differential in the SAADC periperhal.
|
||||||
|
pub trait Input: sealed::Input + Unborrow<Target = Self> {}
|
||||||
|
|
||||||
macro_rules! impl_saadc_input {
|
macro_rules! impl_saadc_input {
|
||||||
($pin:ident, $ch:ident) => {
|
($pin:ident, $ch:ident) => {
|
||||||
impl crate::saadc::Input for crate::peripherals::$pin {
|
impl crate::saadc::sealed::Input for crate::peripherals::$pin {
|
||||||
fn channel(&self) -> crate::saadc::InputChannel {
|
fn channel(&self) -> crate::saadc::InputChannel {
|
||||||
crate::saadc::InputChannel::$ch
|
crate::saadc::InputChannel::$ch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl crate::saadc::Input for crate::peripherals::$pin {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user