Skip to content

Commit

Permalink
Remove dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Nov 29, 2023
1 parent bc92958 commit 45652a8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 204 deletions.
193 changes: 0 additions & 193 deletions src/comparator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,6 @@ impl Config {
self.inverted = inverted;
self
}

/*
pub fn power_mode(mut self, power_mode: PowerMode) -> Self {
self.power_mode = power_mode;
self
}*/

/*
/// Sets the output to be Comparator 1 XOR Comparator 2.
/// Used to implement window comparator mode.
pub fn output_xor(mut self) -> Self {
self.output_xor = true;
self
}*/
}

#[derive(Copy, Clone, Eq, PartialEq)]
Expand All @@ -152,12 +138,6 @@ pub enum Hysteresis {
H70mV = 0b111,
}

/*#[derive(Copy, Clone, Eq, PartialEq)]
pub enum PowerMode {
HighSpeed = 0b00,
MediumSpeed = 0b01,
}*/

/// Comparator positive input
pub trait PositiveInput<C> {
fn setup(&self, comp: &C);
Expand All @@ -178,32 +158,6 @@ pub trait NegativeInput<C> {
fn setup(&self, comp: &C);
}

/*
/// Comparator 1 positive input used as positive input for Comparator 2.
/// Used to implement window comparator mode.
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Comp1InP;
/// Comparator 2 positive input used as positive input for Comparator 1.
/// Used to implement window comparator mode.
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct Comp2InP;
macro_rules! window_input_pin {
($COMP:ident, $pin:ty) => {
impl PositiveInput<$COMP> for $pin {
fn setup(&self, comp: &$COMP) {
comp.csr().modify(|_, w| w.winmode().set_bit())
}
}
};
}
window_input_pin!(COMP1, Comp2InP);
window_input_pin!(COMP2, Comp1InP);
*/

macro_rules! positive_input_pin {
($COMP:ident, $pin_0:ident, $pin_1:ident) => {
impl PositiveInput<$COMP> for &$pin_0<Analog> {
Expand Down Expand Up @@ -568,153 +522,6 @@ impl_comparator!(COMP6, comp2, ExtiEvent::COMP6);
))]
impl_comparator!(COMP7, comp2, ExtiEvent::COMP7);

/*
/// Uses two comparators to implement a window comparator.
/// See Figure 69 in RM0444 Rev 5.
pub struct WindowComparator<U, L, ED> {
pub upper: Comparator<U, ED>,
pub lower: Comparator<L, ED>,
}
pub trait WindowComparatorExt<UC, LC> {
/// Uses two comparators to implement a window comparator
///
/// See Figure 69 in RM0444 Rev 5. Ignores and overrides the `output_xor` setting in `config`.
fn window_comparator<I: PositiveInput<UC>, L: NegativeInput<LC>, U: NegativeInput<UC>>(
self,
input: I,
lower_threshold: L,
upper_threshold: U,
config: Config,
clocks: &Clocks,
) -> WindowComparator<UC, LC, Disabled>;
}
macro_rules! impl_window_comparator {
($UPPER:ident, $LOWER:ident, $LOTHR:expr) => {
impl WindowComparatorExt<$UPPER, $LOWER> for ($UPPER, $LOWER) {
fn window_comparator<
I: PositiveInput<$UPPER>,
L: NegativeInput<$LOWER>,
U: NegativeInput<$UPPER>,
>(
self,
input: I,
lower_threshold: L,
upper_threshold: U,
config: Config,
clocks: &Clocks,
) -> WindowComparator<$UPPER, $LOWER, Disabled> {
let (upper, lower) = self;
let mut configu = config.clone();
configu.output_xor = true;
let upper = upper.comparator(input, upper_threshold, configu, clocks);
let mut configl = config;
configl.output_xor = false;
let lower = lower.comparator($LOTHR, lower_threshold, configl, clocks);
WindowComparator { upper, lower }
}
}
impl WindowComparator<$UPPER, $LOWER, Disabled> {
/// Enables the comparator
pub fn enable(self) -> WindowComparator<$UPPER, $LOWER, Enabled> {
WindowComparator {
upper: self.upper.enable(),
lower: self.lower.enable(),
}
}
/// Enables raising the `ADC_COMP` interrupt at the specified signal edge
pub fn listen(&self, edge: SignalEdge, exti: &mut EXTI) {
self.upper.listen(edge, exti)
}
}
impl WindowComparator<$UPPER, $LOWER, Enabled> {
/// Disables the comparator
pub fn disable(self) -> WindowComparator<$UPPER, $LOWER, Disabled> {
WindowComparator {
upper: self.upper.disable(),
lower: self.lower.disable(),
}
}
/// Returns the value of the output of the comparator
pub fn output(&self) -> bool {
self.upper.output()
}
/// Returns `true` if the input signal is above the lower threshold
pub fn above_lower(&self) -> bool {
self.lower.output()
}
}
impl<ED> WindowComparator<$UPPER, $LOWER, ED> {
/// Configures a GPIO pin to output the signal of the comparator
///
/// Multiple GPIO pins may be configured as the output simultaneously.
pub fn output_pin<P: OutputPin<$UPPER>>(&self, pin: P) {
self.upper.output_pin(pin)
}
/// Disables raising interrupts for the output signal
pub fn unlisten(&self, exti: &mut EXTI) {
self.upper.unlisten(exti)
}
/// Returns `true` if the output signal interrupt is pending for the `edge`
pub fn is_pending(&self, edge: SignalEdge, exti: &EXTI) -> bool {
self.upper.is_pending(edge, exti)
}
/// Unpends the output signal interrupt
pub fn unpend(&self, exti: &EXTI) {
self.upper.unpend(exti)
}
}
};
}
impl_window_comparator!(COMP1, COMP2, Comp1InP);
impl_window_comparator!(COMP2, COMP1, Comp2InP);
pub fn window_comparator12<
I: PositiveInput<COMP1>,
L: NegativeInput<COMP2>,
U: NegativeInput<COMP1>,
>(
comp: COMP,
input: I,
lower_threshold: L,
upper_threshold: U,
config: Config,
rcc: &mut Rcc,
) -> WindowComparator<COMP1, COMP2, Disabled> {
let (comp1, comp2) = comp.split(rcc);
(comp1, comp2).window_comparator(input, lower_threshold, upper_threshold, config, &rcc.clocks)
}
pub fn window_comparator21<
I: PositiveInput<COMP2>,
L: NegativeInput<COMP1>,
U: NegativeInput<COMP2>,
>(
comp: COMP,
input: I,
lower_threshold: L,
upper_threshold: U,
config: Config,
rcc: &mut Rcc,
) -> WindowComparator<COMP2, COMP1, Disabled> {
let (comp1, comp2) = comp.split(rcc);
(comp2, comp1).window_comparator(input, lower_threshold, upper_threshold, config, &rcc.clocks)
}*/

#[cfg(not(any(
feature = "stm32g473",
feature = "stm32g483",
Expand Down
11 changes: 0 additions & 11 deletions src/dac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,6 @@ macro_rules! dac_helper {
}
}

/*pub fn enable_unbuffered(self) -> $CX<MODE_BITS, EnabledUnbuffered> {
let dac = unsafe { &(*<$DAC>::ptr()) };
dac.dac_mcr.modify(|_, w| unsafe { w.$mode().bits(2) });
dac.dac_cr.modify(|_, w| w.$en().set_bit());
$CX {
_enabled: PhantomData,
}
}*/

pub fn enable_generator(self, config: GeneratorConfig) -> $CX<MODE_BITS, WaveGenerator> {
let dac = unsafe { &(*<$DAC>::ptr()) };

Expand Down

0 comments on commit 45652a8

Please sign in to comment.