aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/sai/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32/src/sai/mod.rs')
-rw-r--r--embassy-stm32/src/sai/mod.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/embassy-stm32/src/sai/mod.rs b/embassy-stm32/src/sai/mod.rs
index fb8b23b79..579c34c13 100644
--- a/embassy-stm32/src/sai/mod.rs
+++ b/embassy-stm32/src/sai/mod.rs
@@ -6,12 +6,12 @@ use core::marker::PhantomData;
6use embassy_hal_internal::PeripheralType; 6use embassy_hal_internal::PeripheralType;
7 7
8pub use crate::dma::word; 8pub use crate::dma::word;
9use crate::dma::{ringbuffer, Channel, ReadableRingBuffer, Request, TransferOptions, WritableRingBuffer}; 9use crate::dma::{Channel, ReadableRingBuffer, Request, TransferOptions, WritableRingBuffer, ringbuffer};
10use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed}; 10use crate::gpio::{AfType, AnyPin, OutputType, Pull, SealedPin as _, Speed};
11pub use crate::pac::sai::vals::Mckdiv as MasterClockDivider; 11pub use crate::pac::sai::vals::Mckdiv as MasterClockDivider;
12use crate::pac::sai::{vals, Sai as Regs}; 12use crate::pac::sai::{Sai as Regs, vals};
13use crate::rcc::{self, RccPeripheral}; 13use crate::rcc::{self, RccPeripheral};
14use crate::{peripherals, Peri}; 14use crate::{Peri, peripherals};
15 15
16/// SAI error 16/// SAI error
17#[derive(Debug, PartialEq, Eq, Clone, Copy)] 17#[derive(Debug, PartialEq, Eq, Clone, Copy)]
@@ -391,10 +391,11 @@ pub struct Config {
391 pub frame_sync_polarity: FrameSyncPolarity, 391 pub frame_sync_polarity: FrameSyncPolarity,
392 pub frame_sync_active_level_length: word::U7, 392 pub frame_sync_active_level_length: word::U7,
393 pub frame_sync_definition: FrameSyncDefinition, 393 pub frame_sync_definition: FrameSyncDefinition,
394 pub frame_length: u8, 394 pub frame_length: u16,
395 pub clock_strobe: ClockStrobe, 395 pub clock_strobe: ClockStrobe,
396 pub output_drive: OutputDrive, 396 pub output_drive: OutputDrive,
397 pub master_clock_divider: Option<MasterClockDivider>, 397 pub master_clock_divider: MasterClockDivider,
398 pub nodiv: bool,
398 pub is_high_impedance_on_inactive_slot: bool, 399 pub is_high_impedance_on_inactive_slot: bool,
399 pub fifo_threshold: FifoThreshold, 400 pub fifo_threshold: FifoThreshold,
400 pub companding: Companding, 401 pub companding: Companding,
@@ -423,7 +424,8 @@ impl Default for Config {
423 frame_sync_active_level_length: word::U7(16), 424 frame_sync_active_level_length: word::U7(16),
424 frame_sync_definition: FrameSyncDefinition::ChannelIdentification, 425 frame_sync_definition: FrameSyncDefinition::ChannelIdentification,
425 frame_length: 32, 426 frame_length: 32,
426 master_clock_divider: None, 427 master_clock_divider: MasterClockDivider::DIV1,
428 nodiv: false,
427 clock_strobe: ClockStrobe::Rising, 429 clock_strobe: ClockStrobe::Rising,
428 output_drive: OutputDrive::Immediately, 430 output_drive: OutputDrive::Immediately,
429 is_high_impedance_on_inactive_slot: false, 431 is_high_impedance_on_inactive_slot: false,
@@ -677,8 +679,8 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> {
677 w.set_syncen(config.sync_input.syncen()); 679 w.set_syncen(config.sync_input.syncen());
678 w.set_mono(config.stereo_mono.mono()); 680 w.set_mono(config.stereo_mono.mono());
679 w.set_outdriv(config.output_drive.outdriv()); 681 w.set_outdriv(config.output_drive.outdriv());
680 w.set_mckdiv(config.master_clock_divider.unwrap_or(MasterClockDivider::DIV1)); 682 w.set_mckdiv(config.master_clock_divider);
681 w.set_nodiv(config.master_clock_divider.is_none()); 683 w.set_nodiv(config.nodiv);
682 w.set_dmaen(true); 684 w.set_dmaen(true);
683 }); 685 });
684 686
@@ -696,7 +698,7 @@ impl<'d, T: Instance, W: word::Word> Sai<'d, T, W> {
696 w.set_fspol(config.frame_sync_polarity.fspol()); 698 w.set_fspol(config.frame_sync_polarity.fspol());
697 w.set_fsdef(config.frame_sync_definition.fsdef()); 699 w.set_fsdef(config.frame_sync_definition.fsdef());
698 w.set_fsall(config.frame_sync_active_level_length.0 as u8 - 1); 700 w.set_fsall(config.frame_sync_active_level_length.0 as u8 - 1);
699 w.set_frl(config.frame_length - 1); 701 w.set_frl((config.frame_length - 1).try_into().unwrap());
700 }); 702 });
701 703
702 ch.slotr().modify(|w| { 704 ch.slotr().modify(|w| {