diff options
| author | Gerzain Mata <[email protected]> | 2025-07-23 15:05:04 -0700 |
|---|---|---|
| committer | Gerzain Mata <[email protected]> | 2025-07-23 15:05:04 -0700 |
| commit | c5565ccc288863b7d7e5a82aa42141eb7a1cff9f (patch) | |
| tree | abbcb9ba71d8874b35b42ab4cc23dcf518d564ea /embassy-stm32 | |
| parent | b4dc4e567c7eda25fe533c7fa771466d1628cb90 (diff) | |
Working USB. Still no enumeration
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/Cargo.toml | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/wba.rs | 23 | ||||
| -rw-r--r-- | embassy-stm32/src/usb/otg.rs | 2 |
3 files changed, 16 insertions, 13 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 38254ee40..b5b734910 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -81,7 +81,7 @@ futures-util = { version = "0.3.30", default-features = false } | |||
| 81 | sdio-host = "0.9.0" | 81 | sdio-host = "0.9.0" |
| 82 | critical-section = "1.1" | 82 | critical-section = "1.1" |
| 83 | #stm32-metapac = { version = "16" } | 83 | #stm32-metapac = { version = "16" } |
| 84 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-9fc86ca7b3a8bc05182bf1ce3045602df1f5dce3" } | 84 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-dbdc1a4ea26229805def4738b777933803086f93" } |
| 85 | 85 | ||
| 86 | vcell = "0.1.3" | 86 | vcell = "0.1.3" |
| 87 | nb = "1.0.0" | 87 | nb = "1.0.0" |
| @@ -110,7 +110,7 @@ proc-macro2 = "1.0.36" | |||
| 110 | quote = "1.0.15" | 110 | quote = "1.0.15" |
| 111 | 111 | ||
| 112 | #stm32-metapac = { version = "16", default-features = false, features = ["metadata"]} | 112 | #stm32-metapac = { version = "16", default-features = false, features = ["metadata"]} |
| 113 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-9fc86ca7b3a8bc05182bf1ce3045602df1f5dce3", default-features = false, features = ["metadata"] } | 113 | stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-dbdc1a4ea26229805def4738b777933803086f93", default-features = false, features = ["metadata"] } |
| 114 | 114 | ||
| 115 | [features] | 115 | [features] |
| 116 | default = ["rt"] | 116 | default = ["rt"] |
diff --git a/embassy-stm32/src/rcc/wba.rs b/embassy-stm32/src/rcc/wba.rs index 30076b60d..4ca622614 100644 --- a/embassy-stm32/src/rcc/wba.rs +++ b/embassy-stm32/src/rcc/wba.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | pub use crate::pac::pwr::vals::Vos as VoltageScale; | 1 | pub use crate::pac::pwr::vals::Vos as VoltageScale; |
| 2 | use crate::pac::rcc::regs::Cfgr1; | 2 | use crate::pac::rcc::regs::Cfgr1; |
| 3 | pub use crate::pac::rcc::vals::{Hpre as AHBPrescaler, Hsepre as HsePrescaler, Ppre as APBPrescaler, Sw as Sysclk, Pllsrc as PllSource }; | 3 | pub use crate::pac::rcc::vals::{ |
| 4 | Hpre as AHBPrescaler, Hsepre as HsePrescaler, Ppre as APBPrescaler, Sw as Sysclk, Pllsrc as PllSource, | ||
| 5 | Plldiv as PllDiv, Pllm, Plln as PllMul, | ||
| 6 | }; | ||
| 4 | use crate::pac::rcc::vals::Pllrge; | 7 | use crate::pac::rcc::vals::Pllrge; |
| 5 | use crate::pac::{FLASH, RCC}; | 8 | use crate::pac::{FLASH, RCC}; |
| 6 | use crate::rcc::LSI_FREQ; | 9 | use crate::rcc::LSI_FREQ; |
| @@ -29,28 +32,28 @@ pub struct Pll { | |||
| 29 | /// The PLL pre-divider. | 32 | /// The PLL pre-divider. |
| 30 | /// | 33 | /// |
| 31 | /// The clock speed of the `source` divided by `m` must be between 4 and 16 MHz. | 34 | /// The clock speed of the `source` divided by `m` must be between 4 and 16 MHz. |
| 32 | pub pllm: u8, | 35 | pub pllm: Pllm, |
| 33 | /// The PLL multiplier. | 36 | /// The PLL multiplier. |
| 34 | /// | 37 | /// |
| 35 | /// The multiplied clock – `source` divided by `m` times `n` – must be between 128 and 544 | 38 | /// The multiplied clock – `source` divided by `m` times `n` – must be between 128 and 544 |
| 36 | /// MHz. The upper limit may be lower depending on the `Config { voltage_range }`. | 39 | /// MHz. The upper limit may be lower depending on the `Config { voltage_range }`. |
| 37 | pub mul: u8, | 40 | pub mul: PllMul, |
| 38 | /// The divider for the P output. | 41 | /// The divider for the P output. |
| 39 | /// | 42 | /// |
| 40 | /// The P output is one of several options | 43 | /// The P output is one of several options |
| 41 | /// that can be used to feed the SAI/MDF/ADF Clock mux's. | 44 | /// that can be used to feed the SAI/MDF/ADF Clock mux's. |
| 42 | pub divp: Option<u8>, | 45 | pub divp: Option<PllDiv>, |
| 43 | /// The divider for the Q output. | 46 | /// The divider for the Q output. |
| 44 | /// | 47 | /// |
| 45 | /// The Q ouput is one of severals options that can be used to feed the 48MHz clocks | 48 | /// The Q ouput is one of severals options that can be used to feed the 48MHz clocks |
| 46 | /// and the OCTOSPI clock. It may also be used on the MDF/ADF clock mux's. | 49 | /// and the OCTOSPI clock. It may also be used on the MDF/ADF clock mux's. |
| 47 | pub divq: Option<u8>, | 50 | pub divq: Option<PllDiv>, |
| 48 | /// The divider for the R output. | 51 | /// The divider for the R output. |
| 49 | /// | 52 | /// |
| 50 | /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r` | 53 | /// When used to drive the system clock, `source` divided by `m` times `n` divided by `r` |
| 51 | /// must not exceed 160 MHz. System clocks above 55 MHz require a non-default | 54 | /// must not exceed 160 MHz. System clocks above 55 MHz require a non-default |
| 52 | /// `Config { voltage_range }`. | 55 | /// `Config { voltage_range }`. |
| 53 | pub divr: Option<u8>, | 56 | pub divr: Option<PllDiv>, |
| 54 | 57 | ||
| 55 | pub frac: Option<u16>, | 58 | pub frac: Option<u16>, |
| 56 | } | 59 | } |
| @@ -318,10 +321,10 @@ fn init_pll(config: Option<Pll>, input: &PllInput, voltage_range: VoltageScale) | |||
| 318 | 321 | ||
| 319 | let divr = RCC.pll1divr(); | 322 | let divr = RCC.pll1divr(); |
| 320 | divr.write(|w| { | 323 | divr.write(|w| { |
| 321 | w.set_plln(pll.mul as u16); | 324 | w.set_plln(pll.mul); |
| 322 | w.set_pllp(pll.divp.unwrap_or(1)); | 325 | w.set_pllp(pll.divp.unwrap_or(PllDiv::DIV1)); |
| 323 | w.set_pllq(pll.divq.unwrap_or(1)); | 326 | w.set_pllq(pll.divq.unwrap_or(PllDiv::DIV1)); |
| 324 | w.set_pllr(pll.divr.unwrap_or(1)); | 327 | w.set_pllr(pll.divr.unwrap_or(PllDiv::DIV1)); |
| 325 | // w.set_pllfracn(pll.frac.unwrap_or(1)); | 328 | // w.set_pllfracn(pll.frac.unwrap_or(1)); |
| 326 | }); | 329 | }); |
| 327 | RCC.pll1fracr().write(|w| {w.set_pllfracn(pll.frac.unwrap_or(1));}); | 330 | RCC.pll1fracr().write(|w| {w.set_pllfracn(pll.frac.unwrap_or(1));}); |
diff --git a/embassy-stm32/src/usb/otg.rs b/embassy-stm32/src/usb/otg.rs index c8499bdc7..02b27ed48 100644 --- a/embassy-stm32/src/usb/otg.rs +++ b/embassy-stm32/src/usb/otg.rs | |||
| @@ -336,7 +336,7 @@ impl<'d, T: Instance> Bus<'d, T> { | |||
| 336 | critical_section::with(|_| { | 336 | critical_section::with(|_| { |
| 337 | crate::pac::RCC.ahb2enr().modify(|w| { | 337 | crate::pac::RCC.ahb2enr().modify(|w| { |
| 338 | w.set_usb_otg_hsen(true); | 338 | w.set_usb_otg_hsen(true); |
| 339 | w.set_otghsphyen(true); | 339 | w.set_usb_otg_hs_phyen(true); |
| 340 | }); | 340 | }); |
| 341 | }); | 341 | }); |
| 342 | } | 342 | } |
