aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarun <[email protected]>2024-05-03 12:40:26 -0400
committerKarun <[email protected]>2024-05-03 19:45:26 -0400
commit8e92e8718d513298fa87a51e4039ae11a4f6d502 (patch)
treea5be7b0209d3a0b539f72269305afe8330d109e0
parent0f8b3b8c65484a444d1dc9f6179ce3a60a63c06f (diff)
Add example documentation
-rw-r--r--embassy-stm32/src/tsc/mod.rs60
1 files changed, 60 insertions, 0 deletions
diff --git a/embassy-stm32/src/tsc/mod.rs b/embassy-stm32/src/tsc/mod.rs
index a37341b31..6b9d8fcf5 100644
--- a/embassy-stm32/src/tsc/mod.rs
+++ b/embassy-stm32/src/tsc/mod.rs
@@ -1,4 +1,64 @@
1//! TSC Peripheral Interface 1//! TSC Peripheral Interface
2//!
3//!
4//! # Example (stm32)
5//! ``` rust, ignore
6//!
7//! let mut device_config = embassy_stm32::Config::default();
8//! {
9//! device_config.rcc.mux = ClockSrc::MSI(Msirange::RANGE_4MHZ);
10//! }
11//!
12//! let context = embassy_stm32::init(device_config);
13//!
14//! let config = tsc::Config {
15//! ct_pulse_high_length: ChargeTransferPulseCycle::_2,
16//! ct_pulse_low_length: ChargeTransferPulseCycle::_2,
17//! spread_spectrum: false,
18//! spread_spectrum_deviation: SSDeviation::new(2).unwrap(),
19//! spread_spectrum_prescaler: false,
20//! pulse_generator_prescaler: PGPrescalerDivider::_4,
21//! max_count_value: MaxCount::_8191,
22//! io_default_mode: false,
23//! synchro_pin_polarity: false,
24//! acquisition_mode: false,
25//! max_count_interrupt: false,
26//! channel_ios: TscIOPin::Group2Io2 | TscIOPin::Group7Io3,
27//! shield_ios: TscIOPin::Group1Io3.into(),
28//! sampling_ios: TscIOPin::Group1Io2 | TscIOPin::Group2Io1 | TscIOPin::Group7Io2,
29//! };
30//!
31//! let mut g1: PinGroup<embassy_stm32::peripherals::TSC, G1> = PinGroup::new();
32//! g1.set_io2(context.PB13, PinType::Sample);
33//! g1.set_io3(context.PB14, PinType::Shield);
34//!
35//! let mut g2: PinGroup<embassy_stm32::peripherals::TSC, G2> = PinGroup::new();
36//! g2.set_io1(context.PB4, PinType::Sample);
37//! g2.set_io2(context.PB5, PinType::Channel);
38//!
39//! let mut g7: PinGroup<embassy_stm32::peripherals::TSC, G7> = PinGroup::new();
40//! g7.set_io2(context.PE3, PinType::Sample);
41//! g7.set_io3(context.PE4, PinType::Channel);
42//!
43//! let mut touch_controller = tsc::Tsc::new(
44//! context.TSC,
45//! Some(g1),
46//! Some(g2),
47//! None,
48//! None,
49//! None,
50//! None,
51//! Some(g7),
52//! None,
53//! config,
54//! );
55//!
56//! touch_controller.discharge_io(true);
57//! Timer::after_millis(1).await;
58//!
59//! touch_controller.start();
60//!
61//! ```
2 62
3#![macro_use] 63#![macro_use]
4 64