Merge pull request #3812 from noracarmig/sai_v3_dma

Allow stm32 H7 and L5 families to use external SAI sync & allow recovering after dropping a DMA channel
This commit is contained in:
Dario Nieuwenhuis 2025-01-26 20:21:51 +00:00 committed by GitHub
commit 7e0c70b1aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -359,11 +359,13 @@ impl AnyChannel {
match self.info().dma {
#[cfg(dma)]
DmaInfo::Dma(r) => {
let state: &ChannelState = &STATE[self.id as usize];
let ch = r.st(info.num);
// "Preceding reads and writes cannot be moved past subsequent writes."
fence(Ordering::SeqCst);
state.complete_count.store(0, Ordering::Release);
self.clear_irqs();
ch.par().write_value(peri_addr as u32);

View File

@ -190,7 +190,7 @@ pub enum SyncInput {
/// Syncs with the other A/B sub-block within the SAI unit
Internal,
/// Syncs with a sub-block in the other SAI unit
#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
#[cfg(any(sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
External(SyncInputInstance),
}
@ -199,14 +199,14 @@ impl SyncInput {
match self {
SyncInput::None => vals::Syncen::ASYNCHRONOUS,
SyncInput::Internal => vals::Syncen::INTERNAL,
#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
#[cfg(any(sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
SyncInput::External(_) => vals::Syncen::EXTERNAL,
}
}
}
/// SAI instance to sync from.
#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
#[cfg(any(sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
#[derive(Copy, Clone, PartialEq)]
#[allow(missing_docs)]
pub enum SyncInputInstance {
@ -704,12 +704,12 @@ fn update_synchronous_config(config: &mut Config) {
config.mode = Mode::Slave;
config.sync_output = false;
#[cfg(any(sai_v1, sai_v2, sai_v3_2pdm, sai_v3_4pdm))]
#[cfg(any(sai_v1, sai_v2))]
{
config.sync_input = SyncInput::Internal;
}
#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
#[cfg(any(sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
{
//this must either be Internal or External
//The asynchronous sub-block on the same SAI needs to enable sync_output
@ -870,7 +870,7 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> {
ch.cr2().modify(|w| w.set_fflush(true));
#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
#[cfg(any(sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
{
if let SyncInput::External(i) = config.sync_input {
T::REGS.gcr().modify(|w| {