diff options
| author | michel <[email protected]> | 2024-10-10 15:14:53 +0200 |
|---|---|---|
| committer | michel <[email protected]> | 2024-11-29 17:58:35 +0100 |
| commit | 31da5155e840d97e432cf2fa06c6fa4c2a19bf9a (patch) | |
| tree | 50b2745e97e0305fb06afcfdf3a649529a2d0d3a /examples | |
| parent | a5b34a7980edaba5d8de05c68a48972dd9239f75 (diff) | |
Refactor TSC module: Remove redundant 'Tsc' prefixes for improved naming consistency
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32f3/src/bin/tsc_blocking.rs | 6 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/tsc_async.rs | 4 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/tsc_blocking.rs | 6 | ||||
| -rw-r--r-- | examples/stm32l0/src/bin/tsc_multipin.rs | 10 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/tsc_async.rs | 4 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/tsc_blocking.rs | 6 | ||||
| -rw-r--r-- | examples/stm32l4/src/bin/tsc_multipin.rs | 12 | ||||
| -rw-r--r-- | examples/stm32u5/src/bin/tsc.rs | 10 |
8 files changed, 29 insertions, 29 deletions
diff --git a/examples/stm32f3/src/bin/tsc_blocking.rs b/examples/stm32f3/src/bin/tsc_blocking.rs index fa7f718e6..2c33838e5 100644 --- a/examples/stm32f3/src/bin/tsc_blocking.rs +++ b/examples/stm32f3/src/bin/tsc_blocking.rs | |||
| @@ -64,9 +64,9 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 64 | 64 | ||
| 65 | let mut g: PinGroupWithRoles<peripherals::TSC, G4> = PinGroupWithRoles::default(); | 65 | let mut g: PinGroupWithRoles<peripherals::TSC, G4> = PinGroupWithRoles::default(); |
| 66 | // D68 on the STM32F303ZE nucleo-board | 66 | // D68 on the STM32F303ZE nucleo-board |
| 67 | g.set_io2::<tsc_pin_roles::Sample>(context.PA10); | 67 | g.set_io2::<tsc::pin_roles::Sample>(context.PA10); |
| 68 | // D69 on the STM32F303ZE nucleo-board | 68 | // D69 on the STM32F303ZE nucleo-board |
| 69 | let tsc_sensor = g.set_io1::<tsc_pin_roles::Channel>(context.PA9); | 69 | let tsc_sensor = g.set_io1::<tsc::pin_roles::Channel>(context.PA9); |
| 70 | 70 | ||
| 71 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { | 71 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { |
| 72 | g4: Some(g.pin_group), | 72 | g4: Some(g.pin_group), |
| @@ -119,7 +119,7 @@ const MAX_GROUP_STATUS_READ_ATTEMPTS: usize = 10; | |||
| 119 | // attempt to read group status and delay when still ongoing | 119 | // attempt to read group status and delay when still ongoing |
| 120 | async fn read_touch_value( | 120 | async fn read_touch_value( |
| 121 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, | 121 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, |
| 122 | sensor_pin: TscIOPin, | 122 | sensor_pin: tsc::IOPin, |
| 123 | ) -> Option<u16> { | 123 | ) -> Option<u16> { |
| 124 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { | 124 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { |
| 125 | match touch_controller.group_get_status(sensor_pin.group()) { | 125 | match touch_controller.group_get_status(sensor_pin.group()) { |
diff --git a/examples/stm32l0/src/bin/tsc_async.rs b/examples/stm32l0/src/bin/tsc_async.rs index cebe9712f..dae351c2e 100644 --- a/examples/stm32l0/src/bin/tsc_async.rs +++ b/examples/stm32l0/src/bin/tsc_async.rs | |||
| @@ -58,8 +58,8 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 58 | let context = embassy_stm32::init(device_config); | 58 | let context = embassy_stm32::init(device_config); |
| 59 | 59 | ||
| 60 | let mut pin_group: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); | 60 | let mut pin_group: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); |
| 61 | pin_group.set_io1::<tsc_pin_roles::Sample>(context.PA0); | 61 | pin_group.set_io1::<tsc::pin_roles::Sample>(context.PA0); |
| 62 | let sensor = pin_group.set_io2::<tsc_pin_roles::Channel>(context.PA1); | 62 | let sensor = pin_group.set_io2::<tsc::pin_roles::Channel>(context.PA1); |
| 63 | 63 | ||
| 64 | let tsc_conf = Config { | 64 | let tsc_conf = Config { |
| 65 | ct_pulse_high_length: ChargeTransferPulseCycle::_4, | 65 | ct_pulse_high_length: ChargeTransferPulseCycle::_4, |
diff --git a/examples/stm32l0/src/bin/tsc_blocking.rs b/examples/stm32l0/src/bin/tsc_blocking.rs index 65203925c..e1f24639b 100644 --- a/examples/stm32l0/src/bin/tsc_blocking.rs +++ b/examples/stm32l0/src/bin/tsc_blocking.rs | |||
| @@ -69,8 +69,8 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); | 71 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); |
| 72 | g1.set_io1::<tsc_pin_roles::Sample>(context.PA0); | 72 | g1.set_io1::<tsc::pin_roles::Sample>(context.PA0); |
| 73 | let tsc_sensor = g1.set_io2::<tsc_pin_roles::Channel>(context.PA1); | 73 | let tsc_sensor = g1.set_io2::<tsc::pin_roles::Channel>(context.PA1); |
| 74 | 74 | ||
| 75 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { | 75 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { |
| 76 | g1: Some(g1.pin_group), | 76 | g1: Some(g1.pin_group), |
| @@ -123,7 +123,7 @@ const MAX_GROUP_STATUS_READ_ATTEMPTS: usize = 10; | |||
| 123 | // attempt to read group status and delay when still ongoing | 123 | // attempt to read group status and delay when still ongoing |
| 124 | async fn read_touch_value( | 124 | async fn read_touch_value( |
| 125 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, | 125 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, |
| 126 | sensor_pin: TscIOPin, | 126 | sensor_pin: tsc::IOPin, |
| 127 | ) -> Option<u16> { | 127 | ) -> Option<u16> { |
| 128 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { | 128 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { |
| 129 | match touch_controller.group_get_status(sensor_pin.group()) { | 129 | match touch_controller.group_get_status(sensor_pin.group()) { |
diff --git a/examples/stm32l0/src/bin/tsc_multipin.rs b/examples/stm32l0/src/bin/tsc_multipin.rs index 85feb50b0..bf75a5657 100644 --- a/examples/stm32l0/src/bin/tsc_multipin.rs +++ b/examples/stm32l0/src/bin/tsc_multipin.rs | |||
| @@ -78,7 +78,7 @@ const SENSOR_THRESHOLD: u16 = 35; | |||
| 78 | 78 | ||
| 79 | async fn acquire_sensors( | 79 | async fn acquire_sensors( |
| 80 | touch_controller: &mut Tsc<'static, peripherals::TSC, mode::Async>, | 80 | touch_controller: &mut Tsc<'static, peripherals::TSC, mode::Async>, |
| 81 | tsc_acquisition_bank: &TscAcquisitionBank, | 81 | tsc_acquisition_bank: &AcquisitionBank, |
| 82 | ) { | 82 | ) { |
| 83 | touch_controller.set_active_channels_mask(tsc_acquisition_bank.mask()); | 83 | touch_controller.set_active_channels_mask(tsc_acquisition_bank.mask()); |
| 84 | touch_controller.start(); | 84 | touch_controller.start(); |
| @@ -95,11 +95,11 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 95 | 95 | ||
| 96 | // ---------- initial configuration of TSC ---------- | 96 | // ---------- initial configuration of TSC ---------- |
| 97 | let mut pin_group1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); | 97 | let mut pin_group1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); |
| 98 | pin_group1.set_io1::<tsc_pin_roles::Sample>(context.PA0); | 98 | pin_group1.set_io1::<tsc::pin_roles::Sample>(context.PA0); |
| 99 | let tsc_sensor0 = pin_group1.set_io2(context.PA1); | 99 | let tsc_sensor0 = pin_group1.set_io2(context.PA1); |
| 100 | 100 | ||
| 101 | let mut pin_group5: PinGroupWithRoles<peripherals::TSC, G5> = PinGroupWithRoles::default(); | 101 | let mut pin_group5: PinGroupWithRoles<peripherals::TSC, G5> = PinGroupWithRoles::default(); |
| 102 | pin_group5.set_io1::<tsc_pin_roles::Sample>(context.PB3); | 102 | pin_group5.set_io1::<tsc::pin_roles::Sample>(context.PB3); |
| 103 | let tsc_sensor1 = pin_group5.set_io2(context.PB4); | 103 | let tsc_sensor1 = pin_group5.set_io2(context.PB4); |
| 104 | let tsc_sensor2 = pin_group5.set_io3(context.PB6); | 104 | let tsc_sensor2 = pin_group5.set_io3(context.PB6); |
| 105 | 105 | ||
| @@ -128,14 +128,14 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 128 | // ---------- setting up acquisition banks ---------- | 128 | // ---------- setting up acquisition banks ---------- |
| 129 | // sensor0 and sensor1 in this example belong to different TSC-groups, | 129 | // sensor0 and sensor1 in this example belong to different TSC-groups, |
| 130 | // therefore we can acquire and read them both in one go. | 130 | // therefore we can acquire and read them both in one go. |
| 131 | let bank1 = touch_controller.create_acquisition_bank(TscAcquisitionBankPins { | 131 | let bank1 = touch_controller.create_acquisition_bank(AcquisitionBankPins { |
| 132 | g1_pin: Some(tsc_sensor0), | 132 | g1_pin: Some(tsc_sensor0), |
| 133 | g5_pin: Some(tsc_sensor1), | 133 | g5_pin: Some(tsc_sensor1), |
| 134 | ..Default::default() | 134 | ..Default::default() |
| 135 | }); | 135 | }); |
| 136 | // `sensor1` and `sensor2` belongs to the same TSC-group, therefore we must make sure to | 136 | // `sensor1` and `sensor2` belongs to the same TSC-group, therefore we must make sure to |
| 137 | // acquire them one at the time. Therefore, we organize them into different acquisition banks. | 137 | // acquire them one at the time. Therefore, we organize them into different acquisition banks. |
| 138 | let bank2 = touch_controller.create_acquisition_bank(TscAcquisitionBankPins { | 138 | let bank2 = touch_controller.create_acquisition_bank(AcquisitionBankPins { |
| 139 | g5_pin: Some(tsc_sensor2), | 139 | g5_pin: Some(tsc_sensor2), |
| 140 | ..Default::default() | 140 | ..Default::default() |
| 141 | }); | 141 | }); |
diff --git a/examples/stm32l4/src/bin/tsc_async.rs b/examples/stm32l4/src/bin/tsc_async.rs index ada2c468f..b9a059e2e 100644 --- a/examples/stm32l4/src/bin/tsc_async.rs +++ b/examples/stm32l4/src/bin/tsc_async.rs | |||
| @@ -50,9 +50,9 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 50 | 50 | ||
| 51 | let mut pin_group: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); | 51 | let mut pin_group: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); |
| 52 | // D25 | 52 | // D25 |
| 53 | pin_group.set_io1::<tsc_pin_roles::Sample>(context.PB4); | 53 | pin_group.set_io1::<tsc::pin_roles::Sample>(context.PB4); |
| 54 | // D21 | 54 | // D21 |
| 55 | let tsc_sensor = pin_group.set_io2::<tsc_pin_roles::Channel>(context.PB5); | 55 | let tsc_sensor = pin_group.set_io2::<tsc::pin_roles::Channel>(context.PB5); |
| 56 | 56 | ||
| 57 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { | 57 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { |
| 58 | g2: Some(pin_group.pin_group), | 58 | g2: Some(pin_group.pin_group), |
diff --git a/examples/stm32l4/src/bin/tsc_blocking.rs b/examples/stm32l4/src/bin/tsc_blocking.rs index 76aba55ba..12084f8e2 100644 --- a/examples/stm32l4/src/bin/tsc_blocking.rs +++ b/examples/stm32l4/src/bin/tsc_blocking.rs | |||
| @@ -74,9 +74,9 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 74 | 74 | ||
| 75 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); | 75 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); |
| 76 | // D25 | 76 | // D25 |
| 77 | g2.set_io1::<tsc_pin_roles::Sample>(context.PB4); | 77 | g2.set_io1::<tsc::pin_roles::Sample>(context.PB4); |
| 78 | // D21 | 78 | // D21 |
| 79 | let tsc_sensor = g2.set_io2::<tsc_pin_roles::Channel>(context.PB5); | 79 | let tsc_sensor = g2.set_io2::<tsc::pin_roles::Channel>(context.PB5); |
| 80 | 80 | ||
| 81 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { | 81 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { |
| 82 | g2: Some(g2.pin_group), | 82 | g2: Some(g2.pin_group), |
| @@ -128,7 +128,7 @@ const MAX_GROUP_STATUS_READ_ATTEMPTS: usize = 10; | |||
| 128 | // attempt to read group status and delay when still ongoing | 128 | // attempt to read group status and delay when still ongoing |
| 129 | async fn read_touch_value( | 129 | async fn read_touch_value( |
| 130 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, | 130 | touch_controller: &mut tsc::Tsc<'_, peripherals::TSC, mode::Blocking>, |
| 131 | sensor_pin: TscIOPin, | 131 | sensor_pin: tsc::IOPin, |
| 132 | ) -> Option<u16> { | 132 | ) -> Option<u16> { |
| 133 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { | 133 | for _ in 0..MAX_GROUP_STATUS_READ_ATTEMPTS { |
| 134 | match touch_controller.group_get_status(sensor_pin.group()) { | 134 | match touch_controller.group_get_status(sensor_pin.group()) { |
diff --git a/examples/stm32l4/src/bin/tsc_multipin.rs b/examples/stm32l4/src/bin/tsc_multipin.rs index f26a6f4eb..2fadbe16a 100644 --- a/examples/stm32l4/src/bin/tsc_multipin.rs +++ b/examples/stm32l4/src/bin/tsc_multipin.rs | |||
| @@ -74,7 +74,7 @@ const SENSOR_THRESHOLD: u16 = 20; | |||
| 74 | 74 | ||
| 75 | async fn acquire_sensors( | 75 | async fn acquire_sensors( |
| 76 | touch_controller: &mut Tsc<'static, peripherals::TSC, mode::Async>, | 76 | touch_controller: &mut Tsc<'static, peripherals::TSC, mode::Async>, |
| 77 | tsc_acquisition_bank: &TscAcquisitionBank, | 77 | tsc_acquisition_bank: &AcquisitionBank, |
| 78 | ) { | 78 | ) { |
| 79 | touch_controller.set_active_channels_mask(tsc_acquisition_bank.mask()); | 79 | touch_controller.set_active_channels_mask(tsc_acquisition_bank.mask()); |
| 80 | touch_controller.start(); | 80 | touch_controller.start(); |
| @@ -91,11 +91,11 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 91 | 91 | ||
| 92 | // ---------- initial configuration of TSC ---------- | 92 | // ---------- initial configuration of TSC ---------- |
| 93 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); | 93 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); |
| 94 | g1.set_io1::<tsc_pin_roles::Sample>(context.PB12); | 94 | g1.set_io1::<tsc::pin_roles::Sample>(context.PB12); |
| 95 | let sensor0 = g1.set_io2::<tsc_pin_roles::Channel>(context.PB13); | 95 | let sensor0 = g1.set_io2::<tsc::pin_roles::Channel>(context.PB13); |
| 96 | 96 | ||
| 97 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); | 97 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); |
| 98 | g2.set_io1::<tsc_pin_roles::Sample>(context.PB4); | 98 | g2.set_io1::<tsc::pin_roles::Sample>(context.PB4); |
| 99 | let sensor1 = g2.set_io2(context.PB5); | 99 | let sensor1 = g2.set_io2(context.PB5); |
| 100 | let sensor2 = g2.set_io3(context.PB6); | 100 | let sensor2 = g2.set_io3(context.PB6); |
| 101 | 101 | ||
| @@ -124,14 +124,14 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 124 | // ---------- setting up acquisition banks ---------- | 124 | // ---------- setting up acquisition banks ---------- |
| 125 | // sensor0 and sensor1 belong to different TSC-groups, therefore we can acquire and | 125 | // sensor0 and sensor1 belong to different TSC-groups, therefore we can acquire and |
| 126 | // read them both in one go. | 126 | // read them both in one go. |
| 127 | let bank1 = touch_controller.create_acquisition_bank(TscAcquisitionBankPins { | 127 | let bank1 = touch_controller.create_acquisition_bank(AcquisitionBankPins { |
| 128 | g1_pin: Some(sensor0), | 128 | g1_pin: Some(sensor0), |
| 129 | g2_pin: Some(sensor1), | 129 | g2_pin: Some(sensor1), |
| 130 | ..Default::default() | 130 | ..Default::default() |
| 131 | }); | 131 | }); |
| 132 | // `sensor1` and `sensor2` belongs to the same TSC-group, therefore we must make sure to | 132 | // `sensor1` and `sensor2` belongs to the same TSC-group, therefore we must make sure to |
| 133 | // acquire them one at the time. We do this by organizing them into different acquisition banks. | 133 | // acquire them one at the time. We do this by organizing them into different acquisition banks. |
| 134 | let bank2 = touch_controller.create_acquisition_bank(TscAcquisitionBankPins { | 134 | let bank2 = touch_controller.create_acquisition_bank(AcquisitionBankPins { |
| 135 | g2_pin: Some(sensor2), | 135 | g2_pin: Some(sensor2), |
| 136 | ..Default::default() | 136 | ..Default::default() |
| 137 | }); | 137 | }); |
diff --git a/examples/stm32u5/src/bin/tsc.rs b/examples/stm32u5/src/bin/tsc.rs index 800486665..a85acc4c7 100644 --- a/examples/stm32u5/src/bin/tsc.rs +++ b/examples/stm32u5/src/bin/tsc.rs | |||
| @@ -36,15 +36,15 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 36 | }; | 36 | }; |
| 37 | 37 | ||
| 38 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); | 38 | let mut g1: PinGroupWithRoles<peripherals::TSC, G1> = PinGroupWithRoles::default(); |
| 39 | g1.set_io2::<tsc_pin_roles::Sample>(context.PB13); | 39 | g1.set_io2::<tsc::pin_roles::Sample>(context.PB13); |
| 40 | g1.set_io3::<tsc_pin_roles::Shield>(context.PB14); | 40 | g1.set_io3::<tsc::pin_roles::Shield>(context.PB14); |
| 41 | 41 | ||
| 42 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); | 42 | let mut g2: PinGroupWithRoles<peripherals::TSC, G2> = PinGroupWithRoles::default(); |
| 43 | g2.set_io1::<tsc_pin_roles::Sample>(context.PB4); | 43 | g2.set_io1::<tsc::pin_roles::Sample>(context.PB4); |
| 44 | let sensor0 = g2.set_io2(context.PB5); | 44 | let sensor0 = g2.set_io2(context.PB5); |
| 45 | 45 | ||
| 46 | let mut g7: PinGroupWithRoles<peripherals::TSC, G7> = PinGroupWithRoles::default(); | 46 | let mut g7: PinGroupWithRoles<peripherals::TSC, G7> = PinGroupWithRoles::default(); |
| 47 | g7.set_io2::<tsc_pin_roles::Sample>(context.PE3); | 47 | g7.set_io2::<tsc::pin_roles::Sample>(context.PE3); |
| 48 | let sensor1 = g7.set_io3(context.PE4); | 48 | let sensor1 = g7.set_io3(context.PE4); |
| 49 | 49 | ||
| 50 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { | 50 | let pin_groups: PinGroups<peripherals::TSC> = PinGroups { |
| @@ -56,7 +56,7 @@ async fn main(_spawner: embassy_executor::Spawner) { | |||
| 56 | 56 | ||
| 57 | let mut touch_controller = tsc::Tsc::new_async(context.TSC, pin_groups, config, Irqs).unwrap(); | 57 | let mut touch_controller = tsc::Tsc::new_async(context.TSC, pin_groups, config, Irqs).unwrap(); |
| 58 | 58 | ||
| 59 | let acquisition_bank = touch_controller.create_acquisition_bank(TscAcquisitionBankPins { | 59 | let acquisition_bank = touch_controller.create_acquisition_bank(AcquisitionBankPins { |
| 60 | g2_pin: Some(sensor0), | 60 | g2_pin: Some(sensor0), |
| 61 | g7_pin: Some(sensor1), | 61 | g7_pin: Some(sensor1), |
| 62 | ..Default::default() | 62 | ..Default::default() |
