Merge pull request #3716 from elagil/fix_stm32f4_i2s_clocks
Fix STM32F4 I2S clock calculations
This commit is contained in:
commit
90cb610ef7
@ -714,6 +714,16 @@ fn main() {
|
|||||||
// Generate RCC
|
// Generate RCC
|
||||||
clock_gen.clock_names.insert("sys".to_string());
|
clock_gen.clock_names.insert("sys".to_string());
|
||||||
clock_gen.clock_names.insert("rtc".to_string());
|
clock_gen.clock_names.insert("rtc".to_string());
|
||||||
|
|
||||||
|
// STM32F4 SPI in I2S mode receives a clock input from the dedicated I2S PLL.
|
||||||
|
// For this, there is an additional clock MUX, which is not present in other
|
||||||
|
// peripherals and does not fit the current RCC structure of stm32-data.
|
||||||
|
if chip_name.starts_with("stm32f4") && !chip_name.starts_with("stm32f410") {
|
||||||
|
clock_gen.clock_names.insert("plli2s1_p".to_string());
|
||||||
|
clock_gen.clock_names.insert("plli2s1_q".to_string());
|
||||||
|
clock_gen.clock_names.insert("plli2s1_r".to_string());
|
||||||
|
}
|
||||||
|
|
||||||
let clock_idents: Vec<_> = clock_gen.clock_names.iter().map(|n| format_ident!("{}", n)).collect();
|
let clock_idents: Vec<_> = clock_gen.clock_names.iter().map(|n| format_ident!("{}", n)).collect();
|
||||||
g.extend(quote! {
|
g.extend(quote! {
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
|||||||
@ -458,7 +458,7 @@ impl<'d, W: Word> I2S<'d, W> {
|
|||||||
|
|
||||||
/// Write data directly to the raw I2S ringbuffer.
|
/// Write data directly to the raw I2S ringbuffer.
|
||||||
/// This can be used to fill the buffer before starting the DMA transfer.
|
/// This can be used to fill the buffer before starting the DMA transfer.
|
||||||
pub async fn write_immediate(&mut self, data: &mut [W]) -> Result<(usize, usize), Error> {
|
pub async fn write_immediate(&mut self, data: &[W]) -> Result<(usize, usize), Error> {
|
||||||
match &mut self.tx_ring_buffer {
|
match &mut self.tx_ring_buffer {
|
||||||
Some(ring) => Ok(ring.write_immediate(data)?),
|
Some(ring) => Ok(ring.write_immediate(data)?),
|
||||||
_ => return Err(Error::NotATransmitter),
|
_ => return Err(Error::NotATransmitter),
|
||||||
@ -491,10 +491,9 @@ impl<'d, W: Word> I2S<'d, W> {
|
|||||||
|
|
||||||
let regs = T::info().regs;
|
let regs = T::info().regs;
|
||||||
|
|
||||||
// TODO move i2s to the new mux infra.
|
#[cfg(all(rcc_f4, not(stm32f410)))]
|
||||||
//#[cfg(all(rcc_f4, not(stm32f410)))]
|
let pclk = unsafe { crate::rcc::get_freqs() }.plli2s1_r.to_hertz().unwrap();
|
||||||
//let pclk = unsafe { get_freqs() }.plli2s1_q.unwrap();
|
#[cfg(not(all(rcc_f4, not(stm32f410))))]
|
||||||
//#[cfg(stm32f410)]
|
|
||||||
let pclk = T::frequency();
|
let pclk = T::frequency();
|
||||||
|
|
||||||
let (odd, div) = compute_baud_rate(pclk, freq, config.master_clock, config.format);
|
let (odd, div) = compute_baud_rate(pclk, freq, config.master_clock, config.format);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user