Merge pull request #4149 from embassy-rs/stm32-otg-fix-trdt
stm32/otg: calculate TRDT using AHB freq instead of kernel freq.
This commit is contained in:
commit
52e4c7c30c
@ -647,6 +647,8 @@ fn main() {
|
|||||||
PeripheralRccKernelClock::Clock(clock) => clock_gen.gen_clock(p.name, clock),
|
PeripheralRccKernelClock::Clock(clock) => clock_gen.gen_clock(p.name, clock),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bus_clock_frequency = clock_gen.gen_clock(p.name, &rcc.bus_clock);
|
||||||
|
|
||||||
// A refcount leak can result if the same field is shared by peripherals with different stop modes
|
// A refcount leak can result if the same field is shared by peripherals with different stop modes
|
||||||
// This condition should be checked in stm32-data
|
// This condition should be checked in stm32-data
|
||||||
let stop_mode = match rcc.stop_mode {
|
let stop_mode = match rcc.stop_mode {
|
||||||
@ -660,6 +662,9 @@ fn main() {
|
|||||||
fn frequency() -> crate::time::Hertz {
|
fn frequency() -> crate::time::Hertz {
|
||||||
#clock_frequency
|
#clock_frequency
|
||||||
}
|
}
|
||||||
|
fn bus_frequency() -> crate::time::Hertz {
|
||||||
|
#bus_clock_frequency
|
||||||
|
}
|
||||||
|
|
||||||
const RCC_INFO: crate::rcc::RccInfo = unsafe {
|
const RCC_INFO: crate::rcc::RccInfo = unsafe {
|
||||||
crate::rcc::RccInfo::new(
|
crate::rcc::RccInfo::new(
|
||||||
|
|||||||
@ -97,6 +97,8 @@ pub(crate) unsafe fn get_freqs() -> &'static Clocks {
|
|||||||
|
|
||||||
pub(crate) trait SealedRccPeripheral {
|
pub(crate) trait SealedRccPeripheral {
|
||||||
fn frequency() -> Hertz;
|
fn frequency() -> Hertz;
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn bus_frequency() -> Hertz;
|
||||||
const RCC_INFO: RccInfo;
|
const RCC_INFO: RccInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -549,7 +549,7 @@ foreach_interrupt!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
fn calculate_trdt<T: Instance>(speed: Dspd) -> u8 {
|
fn calculate_trdt<T: Instance>(speed: Dspd) -> u8 {
|
||||||
let ahb_freq = T::frequency().0;
|
let ahb_freq = T::bus_frequency().0;
|
||||||
match speed {
|
match speed {
|
||||||
Dspd::HIGH_SPEED => {
|
Dspd::HIGH_SPEED => {
|
||||||
// From RM0431 (F72xx), RM0090 (F429), RM0390 (F446)
|
// From RM0431 (F72xx), RM0090 (F429), RM0390 (F446)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user