Merge pull request #2805 from embassy-rs/f4-otg-hs-fix

stm32/otg: fix OTG_HS in FS mode.
This commit is contained in:
Dario Nieuwenhuis 2024-04-12 01:37:01 +00:00 committed by GitHub
commit b1902957c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -562,51 +562,29 @@ impl<'d, T: Instance> Bus<'d, T> {
fn init(&mut self) { fn init(&mut self) {
super::common_init::<T>(); super::common_init::<T>();
#[cfg(stm32f7)]
{
// Enable ULPI clock if external PHY is used // Enable ULPI clock if external PHY is used
let ulpien = !self.phy_type.internal(); let _ulpien = !self.phy_type.internal();
critical_section::with(|_| {
crate::pac::RCC.ahb1enr().modify(|w| {
if T::HIGH_SPEED {
w.set_usb_otg_hsulpien(ulpien);
} else {
w.set_usb_otg_hsen(ulpien);
}
});
// Low power mode #[cfg(any(stm32f2, stm32f4, stm32f7))]
crate::pac::RCC.ahb1lpenr().modify(|w| {
if T::HIGH_SPEED { if T::HIGH_SPEED {
w.set_usb_otg_hsulpilpen(ulpien); critical_section::with(|_| {
} else { let rcc = crate::pac::RCC;
w.set_usb_otg_hslpen(ulpien); rcc.ahb1enr().modify(|w| w.set_usb_otg_hsulpien(_ulpien));
} rcc.ahb1lpenr().modify(|w| w.set_usb_otg_hsulpilpen(_ulpien));
});
}); });
} }
#[cfg(stm32h7)] #[cfg(stm32h7)]
{
// Enable ULPI clock if external PHY is used
let ulpien = !self.phy_type.internal();
critical_section::with(|_| { critical_section::with(|_| {
crate::pac::RCC.ahb1enr().modify(|w| { let rcc = crate::pac::RCC;
if T::HIGH_SPEED { if T::HIGH_SPEED {
w.set_usb_otg_hs_ulpien(ulpien); rcc.ahb1enr().modify(|w| w.set_usb_otg_hs_ulpien(_ulpien));
rcc.ahb1lpenr().modify(|w| w.set_usb_otg_hs_ulpilpen(_ulpien));
} else { } else {
w.set_usb_otg_fs_ulpien(ulpien); rcc.ahb1enr().modify(|w| w.set_usb_otg_fs_ulpien(_ulpien));
rcc.ahb1lpenr().modify(|w| w.set_usb_otg_fs_ulpilpen(_ulpien));
} }
}); });
crate::pac::RCC.ahb1lpenr().modify(|w| {
if T::HIGH_SPEED {
w.set_usb_otg_hs_ulpilpen(ulpien);
} else {
w.set_usb_otg_fs_ulpilpen(ulpien);
}
});
});
}
let r = T::regs(); let r = T::regs();
let core_id = r.cid().read().0; let core_id = r.cid().read().0;