Skip to content

Commit

Permalink
fix: flush SAI FIFO on init
Browse files Browse the repository at this point in the history
  • Loading branch information
elagil committed Nov 14, 2024
1 parent 4692f06 commit edb9b03
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions embassy-stm32/src/sai/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,15 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> {
ring_buffer: RingBuffer<'d, W>,
config: Config,
) -> Self {
let ch = T::REGS.ch(sub_block as usize);

#[cfg(any(sai_v1, sai_v2, sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
{
let ch = T::REGS.ch(sub_block as usize);
ch.cr1().modify(|w| w.set_saien(false));
}

ch.cr2().modify(|w| w.set_fflush(true));

#[cfg(any(sai_v4_2pdm, sai_v4_4pdm))]
{
if let SyncInput::External(i) = config.sync_input {
Expand All @@ -888,7 +891,6 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> {

#[cfg(any(sai_v1, sai_v2, sai_v3_2pdm, sai_v3_4pdm, sai_v4_2pdm, sai_v4_4pdm))]
{
let ch = T::REGS.ch(sub_block as usize);
ch.cr1().modify(|w| {
w.set_mode(config.mode.mode(if Self::is_transmitter(&ring_buffer) {
TxRx::Transmitter
Expand Down

0 comments on commit edb9b03

Please sign in to comment.