pub struct Tsc<'d, T: Instance, K: PeriMode> { /* private fields */ }
Expand description
TSC driver
Implementations§
Source§impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K>
impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K>
Sourcepub fn get_acquisition_bank_status(
&self,
bank: &AcquisitionBank,
) -> AcquisitionBankStatus
pub fn get_acquisition_bank_status( &self, bank: &AcquisitionBank, ) -> AcquisitionBankStatus
Get the status of all groups involved in a AcquisitionBank
Sourcepub fn get_acquisition_bank_values(
&self,
bank: &AcquisitionBank,
) -> AcquisitionBankReadings
pub fn get_acquisition_bank_values( &self, bank: &AcquisitionBank, ) -> AcquisitionBankReadings
Get the values for all channels involved in a AcquisitionBank
Sourcepub fn create_acquisition_bank(
&self,
acquisition_bank_pins: AcquisitionBankPins,
) -> AcquisitionBank
pub fn create_acquisition_bank( &self, acquisition_bank_pins: AcquisitionBankPins, ) -> AcquisitionBank
Creates a new TSC acquisition bank from the provided pin configuration.
This method creates a AcquisitionBank
that can be used for efficient,
repeated TSC acquisitions. It automatically generates the appropriate mask
for the provided pins.
§Note on TSC Hardware Limitation
The TSC hardware can only read one channel pin from each TSC group per acquisition.
§Arguments
acquisition_bank_pins
- The pin configuration for the acquisition bank.
§Returns
A new AcquisitionBank
instance.
§Example
let tsc = // ... initialize TSC
let tsc_sensor1: tsc::IOPinWithRole<G1, tsc_pin_roles::Channel> = ...;
let tsc_sensor2: tsc::IOPinWithRole<G2, tsc_pin_roles::Channel> = ...;
let bank = tsc.create_acquisition_bank(AcquisitionBankPins {
g1_pin: Some(tsc_sensor1),
g2_pin: Some(tsc_sensor2),
..Default::default()
});
// Use the bank for acquisitions
tsc.set_active_channels_bank(&bank);
tsc.start();
// ... perform acquisition ...
Sourcepub fn set_active_channels_mask(&mut self, mask: u32)
pub fn set_active_channels_mask(&mut self, mask: u32)
Sets the active channels for the next TSC acquisition.
This is a low-level method that directly sets the channel mask. For most use cases,
consider using set_active_channels_bank
with a AcquisitionBank
instead, which
provides a higher-level interface and additional safety checks.
This method configures which sensor channels will be read during the next touch sensing acquisition cycle. It should be called before starting a new acquisition with the start() method.
§Arguments
mask
- A 32-bit mask where each bit represents a channel. Set bits indicate active channels.
§Note
Only one pin from each TSC group can be read for each acquisition. This method does not perform checks to ensure this limitation is met. Incorrect masks may lead to unexpected behavior.
§Safety
This method doesn’t perform extensive checks on the provided mask. Ensure that the mask is valid and adheres to hardware limitations to avoid undefined behavior.
Sourcepub fn set_active_channels(
&mut self,
channels: &[IOPin],
) -> Result<(), AcquisitionBankError>
pub fn set_active_channels( &mut self, channels: &[IOPin], ) -> Result<(), AcquisitionBankError>
Convenience method for setting active channels directly from a slice of tsc::IOPin. This method performs safety checks but is less efficient for repeated use.
Sourcepub fn set_active_channels_bank(&mut self, bank: &AcquisitionBank)
pub fn set_active_channels_bank(&mut self, bank: &AcquisitionBank)
Sets the active channels for the next TSC acquisition using a pre-configured acquisition bank.
This method efficiently configures the TSC peripheral to read the channels specified
in the provided AcquisitionBank
. It’s the recommended way to set up
channel configurations for acquisition, especially when using the same set of channels repeatedly.
§Arguments
bank
- A reference to aAcquisitionBank
containing the pre-configured TSC channel mask.
§Example
let tsc_sensor1: tsc::IOPinWithRole<G1, Channel> = ...;
let tsc_sensor2: tsc::IOPinWithRole<G5, Channel> = ...;
let mut touch_controller: Tsc<'_, TSC, Async> = ...;
let bank = touch_controller.create_acquisition_bank(AcquisitionBankPins {
g1_pin: Some(tsc_sensor1),
g2_pin: Some(tsc_sensor2),
..Default::default()
});
touch_controller.set_active_channels_bank(&bank);
touch_controller.start();
// ... perform acquisition ...
This method should be called before starting a new acquisition with the start()
method.
Sourcepub fn group_get_status(&self, index: Group) -> GroupStatus
pub fn group_get_status(&self, index: Group) -> GroupStatus
Get the individual group status to check acquisition complete
Sourcepub fn group_get_value(&self, index: Group) -> u16
pub fn group_get_value(&self, index: Group) -> u16
Get the count for the acquisiton, valid once group status is set
Sourcepub fn discharge_io(&mut self, status: bool)
pub fn discharge_io(&mut self, status: bool)
Discharge the IOs for subsequent acquisition
Source§impl<'d, T: Instance> Tsc<'d, T, Async>
impl<'d, T: Instance> Tsc<'d, T, Async>
Sourcepub fn new_async(
peri: impl Peripheral<P = T> + 'd,
pin_groups: PinGroups<'d, T>,
config: Config,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
) -> Result<Self, GroupError>
pub fn new_async( peri: impl Peripheral<P = T> + 'd, pin_groups: PinGroups<'d, T>, config: Config, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, ) -> Result<Self, GroupError>
Create a Tsc instance that can be awaited for completion
Sourcepub async fn pend_for_acquisition(&mut self)
pub async fn pend_for_acquisition(&mut self)
Asyncronously wait for the end of an acquisition
Source§impl<'d, T: Instance> Tsc<'d, T, Blocking>
impl<'d, T: Instance> Tsc<'d, T, Blocking>
Sourcepub fn new_blocking(
peri: impl Peripheral<P = T> + 'd,
pin_groups: PinGroups<'d, T>,
config: Config,
) -> Result<Self, GroupError>
pub fn new_blocking( peri: impl Peripheral<P = T> + 'd, pin_groups: PinGroups<'d, T>, config: Config, ) -> Result<Self, GroupError>
Create a Tsc instance that must be polled for completion
Sourcepub fn poll_for_acquisition(&mut self)
pub fn poll_for_acquisition(&mut self)
Wait for end of acquisition