1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
//! TSC Peripheral Interface
//!
//! This module provides an interface for the Touch Sensing Controller (TSC) peripheral.
//! It supports both blocking and async modes of operation, as well as different TSC versions (v1, v2, v3).
//!
//! # Key Concepts
//!
//! - **Pin Groups**: TSC pins are organized into groups, each containing up to four IOs.
//! - **Pin Roles**: Each pin in a group can have a role: Channel, Sample, or Shield.
//! - **Acquisition Banks**: Used for efficient, repeated TSC acquisitions on specific sets of pins.
//!
//! # Example (stm32)
//!
//! ```rust
//! let device_config = embassy_stm32::Config::default();
//! let context = embassy_stm32::init(device_config);
//!
//! let config = tsc::Config {
//! ct_pulse_high_length: ChargeTransferPulseCycle::_4,
//! ct_pulse_low_length: ChargeTransferPulseCycle::_4,
//! spread_spectrum: false,
//! spread_spectrum_deviation: SSDeviation::new(2).unwrap(),
//! spread_spectrum_prescaler: false,
//! pulse_generator_prescaler: PGPrescalerDivider::_16,
//! max_count_value: MaxCount::_255,
//! io_default_mode: false,
//! synchro_pin_polarity: false,
//! acquisition_mode: false,
//! max_count_interrupt: false,
//! };
//!
//! let mut g2: PinGroupWithRoles<embassy_stm32::peripherals::TSC, G2> = PinGroupWithRoles::new();
//! g2.set_io1::<tsc_pin_roles::Sample>(context.PB4);
//! let sensor_pin = g2.set_io2::<tsc_pin_roles::Channel>(context.PB5);
//!
//! let pin_groups = PinGroups {
//! g2: Some(g2.pin_group),
//! ..Default::default()
//! };
//!
//! let mut touch_controller = tsc::Tsc::new_blocking(
//! context.TSC,
//! pin_groups,
//! config,
//! ).unwrap();
//!
//! let discharge_delay = 5; // ms
//!
//! loop {
//! touch_controller.set_active_channels_mask(sensor_pin.pin.into());
//! touch_controller.start();
//! touch_controller.poll_for_acquisition();
//! touch_controller.discharge_io(true);
//! Timer::after_millis(discharge_delay).await;
//!
//! match touch_controller.group_get_status(sensor_pin.pin.group()) {
//! GroupStatus::Complete => {
//! let group_val = touch_controller.group_get_value(sensor_pin.pin.group());
//! // Process the touch value
//! // ...
//! }
//! GroupStatus::Ongoing => {
//! // Handle ongoing acquisition
//! // ...
//! }
//! }
//! }
//! ```
//!
//! # Async Usage
//!
//! For async operation, use `Tsc::new_async` and `pend_for_acquisition` instead of polling.
/// Configuration structures and enums for the TSC peripheral.
/// Definitions and implementations for TSC pin groups.
/// Definitions and implementations for individual TSC I/O pins.
/// Structures and implementations for TSC acquisition banks.
/// Core implementation of the TSC (Touch Sensing Controller) driver.
/// Type definitions used throughout the TSC module.
/// Error types and definitions for the TSC module.
use PhantomData;
pub use *;
pub use *;
use PeripheralType;
use AtomicWaker;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
use crateRccPeripheral;
use crate::;
const TSC_NUM_GROUPS: usize = 6;
const TSC_NUM_GROUPS: usize = 7;
const TSC_NUM_GROUPS: usize = 8;
/// Error type defined for TSC
/// TSC interrupt handler.
pub
/// TSC instance trait
foreach_interrupt!;