mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-22 06:42:32 +00:00
Add IOConfig struct and pub fn io_config()
The STM32 TSC needs to do successive acquisitions when using multiple channels in a group. To do this the IOs must be configured for each acquisition. This change reflects the implementations in the STM32 HAL. See: * https://community.st.com/t5/stm32-mcus-products/tsc-channel-selection/td-p/164783 Specifically, see the HAL solution provided. It shows that only one acquisition channel must enabled in a group during an acquisition cycle, then the next channel in the next acquisition cycle, and so on. * https://www.st.com/content/ccc/resource/technical/document/user_manual/group0/d6/4c/20/0d/a1/c1/4c/99/DM00210526/files/DM00210526.pdf/jcr:content/translations/en.DM00210526.pdf While this is about the STM Touch Library, table 8 (and others) show the acquisition timings required for multiple channels in a group.
This commit is contained in:
parent
1c466b81e6
commit
ebfbcc40be
@ -227,6 +227,15 @@ impl Default for Config {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct IOConfig {
|
||||
/// Channel IO mask
|
||||
pub channel_ios: u32,
|
||||
/// Shield IO mask
|
||||
pub shield_ios: u32,
|
||||
/// Sampling IO mask
|
||||
pub sampling_ios: u32,
|
||||
}
|
||||
|
||||
/// Pin struct that maintains usage
|
||||
#[allow(missing_docs)]
|
||||
pub struct TscPin<'d, T, C> {
|
||||
@ -761,6 +770,27 @@ impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K> {
|
||||
groups
|
||||
}
|
||||
|
||||
pub fn io_config(&mut self, config: &IOConfig) {
|
||||
// Disable Schmitt trigger hysteresis on all used TSC IOs
|
||||
T::regs()
|
||||
.iohcr()
|
||||
.write(|w| w.0 = !(config.channel_ios | config.shield_ios | config.sampling_ios));
|
||||
|
||||
// Set channel and shield IOs
|
||||
T::regs()
|
||||
.ioccr()
|
||||
.write(|w| w.0 = config.channel_ios | config.shield_ios);
|
||||
|
||||
// Set sampling IOs
|
||||
T::regs().ioscr().write(|w| w.0 = config.sampling_ios);
|
||||
|
||||
// Set the groups to be acquired
|
||||
T::regs()
|
||||
.iogcsr()
|
||||
.write(|w| w.0 = Self::extract_groups(config.channel_ios));
|
||||
|
||||
}
|
||||
|
||||
fn new_inner(
|
||||
peri: impl Peripheral<P = T> + 'd,
|
||||
g1: Option<PinGroup<'d, T, G1>>,
|
||||
@ -804,6 +834,15 @@ impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K> {
|
||||
});
|
||||
|
||||
// Set IO configuration
|
||||
let io_config = IOConfig {
|
||||
channel_ios: config.channel_ios,
|
||||
sampling_ios: config.sampling_ios,
|
||||
shield_ios: config.shield_ios,
|
||||
};
|
||||
|
||||
Self.io_config(&io_config);
|
||||
|
||||
/*
|
||||
// Disable Schmitt trigger hysteresis on all used TSC IOs
|
||||
T::regs()
|
||||
.iohcr()
|
||||
@ -822,6 +861,8 @@ impl<'d, T: Instance, K: PeriMode> Tsc<'d, T, K> {
|
||||
.iogcsr()
|
||||
.write(|w| w.0 = Self::extract_groups(config.channel_ios));
|
||||
|
||||
*/
|
||||
|
||||
// Disable interrupts
|
||||
T::regs().ier().modify(|w| {
|
||||
w.set_eoaie(false);
|
||||
|
Loading…
Reference in New Issue
Block a user