#[non_exhaustive]pub struct Unit<'d, const NUM: usize> {
pub counter: Counter<'d, NUM>,
pub channel0: Channel<'d, NUM, 0>,
pub channel1: Channel<'d, NUM, 1>,
/* private fields */
}
unstable
only.Expand description
Represents a pulse counter unit.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.counter: Counter<'d, NUM>
The counter for PCNT unit.
channel0: Channel<'d, NUM, 0>
The first channel in PCNT unit.
channel1: Channel<'d, NUM, 1>
The second channel in PCNT unit.
Implementations§
Source§impl<const NUM: usize> Unit<'_, NUM>
impl<const NUM: usize> Unit<'_, NUM>
Sourcepub fn set_low_limit(&self, value: Option<i16>) -> Result<(), InvalidLowLimit>
pub fn set_low_limit(&self, value: Option<i16>) -> Result<(), InvalidLowLimit>
Configures a lower limit to the count value.
When the count drops to this value:
- A low limit interrupt is triggered.
- The count is reset to 0.
If None is specified, then no interrupt is triggered and the count wraps around after [i16::MIN].
Note: The specified value must be negative.
Sourcepub fn set_high_limit(&self, value: Option<i16>) -> Result<(), InvalidHighLimit>
pub fn set_high_limit(&self, value: Option<i16>) -> Result<(), InvalidHighLimit>
Configures a high limit to the count value.
When the count rises to this value:
- A high limit interrupt is triggered.
- The count is reset to 0.
If None is specified, then no interrupt is triggered and the count wraps around after [i16::MAX].
Note: The specified value must be positive.
Sourcepub fn set_threshold0(&self, value: Option<i16>)
pub fn set_threshold0(&self, value: Option<i16>)
Configures a threshold value to trigger an interrupt.
When the count equals this value a threshold0 interrupt is triggered. If None is specified, then no interrupt is triggered.
Sourcepub fn set_threshold1(&self, value: Option<i16>)
pub fn set_threshold1(&self, value: Option<i16>)
Configures a threshold value to trigger an interrupt.
When the count equals this value a threshold1 interrupt is triggered. If None is specified, then no interrupt is triggered.
Sourcepub fn set_filter(
&self,
threshold: Option<u16>,
) -> Result<(), InvalidFilterThreshold>
pub fn set_filter( &self, threshold: Option<u16>, ) -> Result<(), InvalidFilterThreshold>
Configures the glitch filter hardware of the unit.
threshold
is the minimum number of APB_CLK cycles for a pulse to be
considered valid. If it is None, the filter is disabled.
Note: This maximum possible threshold is 1023.
Sourcepub fn unlisten(&self, _cs: CriticalSection<'_>)
pub fn unlisten(&self, _cs: CriticalSection<'_>)
Disable interrupts for this unit.
Sourcepub fn interrupt_is_set(&self) -> bool
pub fn interrupt_is_set(&self) -> bool
Returns true if an interrupt is active for this unit.
Sourcepub fn reset_interrupt(&self)
pub fn reset_interrupt(&self)
Clear the interrupt bit for this unit.