Allow chips from L5 (sai_v3_2pdm) and H7 (sai_v3_4pdm) families to use external sai sync

This commit is contained in:
noracarmig 2025-01-26 14:58:56 +00:00
parent 72020fc012
commit fcacbae233

View File

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