@@ -93,11 +93,35 @@ impl Config {
93
93
self
94
94
}
95
95
96
+ /// Invert the comparator output
97
+ ///
98
+ /// NOTE: This does NOT affect the value read by [Comparator::output]
99
+ ///
100
+ /// The following observers are affected by this setting
101
+ /// * Pin output
102
+ /// * EXTI interrupt/wakeup
103
+ /// * TIMx
104
+ ///
105
+ /// The following observers are NOT affected by this setting
106
+ /// * HRTIM
107
+ /// * Software using [Comparator::output]
96
108
pub fn output_inverted ( mut self ) -> Self {
97
109
self . inverted = true ;
98
110
self
99
111
}
100
112
113
+ /// Invert the comparator output
114
+ ///
115
+ /// NOTE: This does NOT affect the value read by [Comparator::output]
116
+ ///
117
+ /// The following observers are affected by this setting
118
+ /// * Pin output
119
+ /// * EXTI interrupt/wakeup
120
+ /// * TIMx
121
+ ///
122
+ /// The following observers are NOT affected by this setting
123
+ /// * HRTIM
124
+ /// * Software using [Comparator::output]
101
125
pub fn output_polarity ( mut self , inverted : bool ) -> Self {
102
126
self . inverted = inverted;
103
127
self
@@ -451,7 +475,25 @@ macro_rules! impl_comparator {
451
475
}
452
476
453
477
impl <ED : EnabledState > Comparator <$COMP, ED > {
478
+ /// Invert the comparator output
479
+ ///
480
+ /// NOTE: This does NOT affect the value read by [Comparator::output]
481
+ ///
482
+ /// The following observers are affected by this setting
483
+ /// * Pin output
484
+ /// * EXTI interrupt/wakeup
485
+ /// * TIMx
486
+ ///
487
+ /// The following observers are NOT affected by this setting
488
+ /// * HRTIM
489
+ /// * Software using [Comparator::output]
490
+ pub fn set_inverted( & mut self , inverted: bool ) {
491
+ self . regs. csr( ) . modify( |_, w| w. pol( ) . bit( inverted) ) ;
492
+ }
493
+
454
494
/// Returns the value of the output of the comparator
495
+ ///
496
+ /// NOTE: This is taken before any potential inversion
455
497
pub fn output( & self ) -> bool {
456
498
self . regs. csr( ) . read( ) . value( ) . bit_is_set( )
457
499
}
0 commit comments