mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-25 08:12:30 +00:00
Add example documentation
This commit is contained in:
parent
0f8b3b8c65
commit
8e92e8718d
@ -1,4 +1,64 @@
|
||||
//! TSC Peripheral Interface
|
||||
//!
|
||||
//!
|
||||
//! # Example (stm32)
|
||||
//! ``` rust, ignore
|
||||
//!
|
||||
//! let mut device_config = embassy_stm32::Config::default();
|
||||
//! {
|
||||
//! device_config.rcc.mux = ClockSrc::MSI(Msirange::RANGE_4MHZ);
|
||||
//! }
|
||||
//!
|
||||
//! let context = embassy_stm32::init(device_config);
|
||||
//!
|
||||
//! let config = tsc::Config {
|
||||
//! ct_pulse_high_length: ChargeTransferPulseCycle::_2,
|
||||
//! ct_pulse_low_length: ChargeTransferPulseCycle::_2,
|
||||
//! spread_spectrum: false,
|
||||
//! spread_spectrum_deviation: SSDeviation::new(2).unwrap(),
|
||||
//! spread_spectrum_prescaler: false,
|
||||
//! pulse_generator_prescaler: PGPrescalerDivider::_4,
|
||||
//! max_count_value: MaxCount::_8191,
|
||||
//! io_default_mode: false,
|
||||
//! synchro_pin_polarity: false,
|
||||
//! acquisition_mode: false,
|
||||
//! max_count_interrupt: false,
|
||||
//! channel_ios: TscIOPin::Group2Io2 | TscIOPin::Group7Io3,
|
||||
//! shield_ios: TscIOPin::Group1Io3.into(),
|
||||
//! sampling_ios: TscIOPin::Group1Io2 | TscIOPin::Group2Io1 | TscIOPin::Group7Io2,
|
||||
//! };
|
||||
//!
|
||||
//! let mut g1: PinGroup<embassy_stm32::peripherals::TSC, G1> = PinGroup::new();
|
||||
//! g1.set_io2(context.PB13, PinType::Sample);
|
||||
//! g1.set_io3(context.PB14, PinType::Shield);
|
||||
//!
|
||||
//! let mut g2: PinGroup<embassy_stm32::peripherals::TSC, G2> = PinGroup::new();
|
||||
//! g2.set_io1(context.PB4, PinType::Sample);
|
||||
//! g2.set_io2(context.PB5, PinType::Channel);
|
||||
//!
|
||||
//! let mut g7: PinGroup<embassy_stm32::peripherals::TSC, G7> = PinGroup::new();
|
||||
//! g7.set_io2(context.PE3, PinType::Sample);
|
||||
//! g7.set_io3(context.PE4, PinType::Channel);
|
||||
//!
|
||||
//! let mut touch_controller = tsc::Tsc::new(
|
||||
//! context.TSC,
|
||||
//! Some(g1),
|
||||
//! Some(g2),
|
||||
//! None,
|
||||
//! None,
|
||||
//! None,
|
||||
//! None,
|
||||
//! Some(g7),
|
||||
//! None,
|
||||
//! config,
|
||||
//! );
|
||||
//!
|
||||
//! touch_controller.discharge_io(true);
|
||||
//! Timer::after_millis(1).await;
|
||||
//!
|
||||
//! touch_controller.start();
|
||||
//!
|
||||
//! ```
|
||||
|
||||
#![macro_use]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user