diff options
| author | Kevin <[email protected]> | 2024-09-15 20:09:42 +0200 |
|---|---|---|
| committer | Kevin <[email protected]> | 2024-09-22 00:23:07 +0200 |
| commit | 6d9af8304cf88dbfa3713acfef4d89ba3a95c2d8 (patch) | |
| tree | 92aa105670259bfd9aa9b60209c62eb2f3cdaa23 /embassy-stm32/src/usb | |
| parent | 2f60d78ea318f51ff59868c348b77cf880012198 (diff) | |
Add USBPHYC clock configuration for H7RS series
Diffstat (limited to 'embassy-stm32/src/usb')
| -rw-r--r-- | embassy-stm32/src/usb/mod.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/otg.rs | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/embassy-stm32/src/usb/mod.rs b/embassy-stm32/src/usb/mod.rs index 7d8c79618..a473285bf 100644 --- a/embassy-stm32/src/usb/mod.rs +++ b/embassy-stm32/src/usb/mod.rs | |||
| @@ -13,9 +13,19 @@ fn common_init<T: Instance>() { | |||
| 13 | // Check the USB clock is enabled and running at exactly 48 MHz. | 13 | // Check the USB clock is enabled and running at exactly 48 MHz. |
| 14 | // frequency() will panic if not enabled | 14 | // frequency() will panic if not enabled |
| 15 | let freq = T::frequency(); | 15 | let freq = T::frequency(); |
| 16 | |||
| 17 | // On the H7RS, the USBPHYC embeds a PLL accepting one of the input frequencies listed below and providing 48MHz to OTG_FS and 60MHz to OTG_HS internally | ||
| 18 | #[cfg(stm32h7rs)] | ||
| 19 | if ![16_000_000, 19_200_000, 20_000_000, 24_000_000, 26_000_000, 32_000_000].contains(&freq.0) { | ||
| 20 | panic!( | ||
| 21 | "USB clock should be one of 16, 19.2, 20, 24, 26, 32Mhz but is {} Hz. Please double-check your RCC settings.", | ||
| 22 | freq.0 | ||
| 23 | ) | ||
| 24 | } | ||
| 16 | // Check frequency is within the 0.25% tolerance allowed by the spec. | 25 | // Check frequency is within the 0.25% tolerance allowed by the spec. |
| 17 | // Clock might not be exact 48Mhz due to rounding errors in PLL calculation, or if the user | 26 | // Clock might not be exact 48Mhz due to rounding errors in PLL calculation, or if the user |
| 18 | // has tight clock restrictions due to something else (like audio). | 27 | // has tight clock restrictions due to something else (like audio). |
| 28 | #[cfg(not(stm32h7rs))] | ||
| 19 | if freq.0.abs_diff(48_000_000) > 120_000 { | 29 | if freq.0.abs_diff(48_000_000) > 120_000 { |
| 20 | panic!( | 30 | panic!( |
| 21 | "USB clock should be 48Mhz but is {} Hz. Please double-check your RCC settings.", | 31 | "USB clock should be 48Mhz but is {} Hz. Please double-check your RCC settings.", |
diff --git a/embassy-stm32/src/usb/otg.rs b/embassy-stm32/src/usb/otg.rs index 59b5401cc..00cafe6e4 100644 --- a/embassy-stm32/src/usb/otg.rs +++ b/embassy-stm32/src/usb/otg.rs | |||
| @@ -554,7 +554,7 @@ fn calculate_trdt<T: Instance>(speed: Dspd) -> u8 { | |||
| 554 | match speed { | 554 | match speed { |
| 555 | Dspd::HIGH_SPEED => { | 555 | Dspd::HIGH_SPEED => { |
| 556 | // From RM0431 (F72xx), RM0090 (F429), RM0390 (F446) | 556 | // From RM0431 (F72xx), RM0090 (F429), RM0390 (F446) |
| 557 | if ahb_freq >= 30_000_000 { | 557 | if ahb_freq >= 30_000_000 || cfg!(stm32h7rs) { |
| 558 | 0x9 | 558 | 0x9 |
| 559 | } else { | 559 | } else { |
| 560 | panic!("AHB frequency is too low") | 560 | panic!("AHB frequency is too low") |
