#[non_exhaustive]pub struct Unit<'d> {
pub counter: Counter<'d>,
pub channel0: Channel<'d, 0>,
pub channel1: Channel<'d, 1>,
/* private fields */
}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>The counter for PCNT unit.
channel0: Channel<'d, 0>The first channel in PCNT unit.
channel1: Channel<'d, 1>The second channel in PCNT unit.
Implementations§
Source§impl<'d> Unit<'d>
impl<'d> Unit<'d>
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].
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].
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.
The maximum possible threshold is 1023.
Sourcepub fn interrupt_is_set(&self) -> bool
pub fn interrupt_is_set(&self) -> bool
Returns whether an interrupt is active for this unit.
Sourcepub fn reset_interrupt(&self)
pub fn reset_interrupt(&self)
Clears the interrupt bit for this unit.
Sourcepub fn set_interrupt_handler(&mut self, handler: InterruptHandler)
Available on crate feature unstable only.
pub fn set_interrupt_handler(&mut self, handler: InterruptHandler)
unstable only.Registers a handler invoked when this unit’s interrupt status bit is set.
The hardware interrupt is shared by every unit in the same PCNT
register block. This method installs a dispatcher on that interrupt
and records handler for this unit only.
This method ignores handler priority.
§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Trait Implementations§
Source§impl InterruptConfigurable for Unit<'_>
Available on crate feature unstable only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
impl InterruptConfigurable for Unit<'_>
unstable only.§Stability
This API is marked as unstable and is only available when the unstable
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
Source§fn set_interrupt_handler(&mut self, handler: InterruptHandler)
fn set_interrupt_handler(&mut self, handler: InterruptHandler)
impl Send for Unit<'_>
unstable only.