mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-10-02 22:54:52 +00:00
chore: clean up stm32h5 ucpd
This commit is contained in:
parent
b127ca9844
commit
d9ef2c94d7
@ -299,24 +299,18 @@ impl<'d, T: Instance> CcPhy<'d, T> {
|
|||||||
#[cfg(stm32h5)]
|
#[cfg(stm32h5)]
|
||||||
T::REGS.cfgr3().modify(|w| match cc_pull {
|
T::REGS.cfgr3().modify(|w| match cc_pull {
|
||||||
CcPull::Source1_5A => {
|
CcPull::Source1_5A => {
|
||||||
#[cfg(stm32h5)]
|
let trim_1a5_cc1 = unsafe { *(0x08FF_F844 as *const u32) & 0xF };
|
||||||
{
|
let trim_1a5_cc2 = unsafe { ((*(0x08FF_F844 as *const u32)) >> 16) & 0xF };
|
||||||
let trim_1a5_cc1 = unsafe { *(0x08FF_F844 as *const u32) & 0xF };
|
|
||||||
let trim_1a5_cc2 = unsafe { ((*(0x08FF_F844 as *const u32)) >> 16) & 0xF };
|
|
||||||
|
|
||||||
w.set_trim_cc1_rp(trim_1a5_cc1 as u8);
|
w.set_trim_cc1_rp(trim_1a5_cc1 as u8);
|
||||||
w.set_trim_cc2_rp(trim_1a5_cc2 as u8);
|
w.set_trim_cc2_rp(trim_1a5_cc2 as u8);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
#[cfg(stm32h5)]
|
let trim_3a0_cc1 = unsafe { (*(0x4002_242C as *const u32) >> 4) & 0xF };
|
||||||
{
|
let trim_3a0_cc2 = unsafe { ((*(0x4002_242C as *const u32)) >> 12) & 0xF };
|
||||||
let trim_3a0_cc1 = unsafe { (*(0x4002_242C as *const u32) >> 4) & 0xF };
|
|
||||||
let trim_3a0_cc2 = unsafe { ((*(0x4002_242C as *const u32)) >> 12) & 0xF };
|
|
||||||
|
|
||||||
w.set_trim_cc1_rp(trim_3a0_cc1 as u8);
|
w.set_trim_cc1_rp(trim_3a0_cc1 as u8);
|
||||||
w.set_trim_cc2_rp(trim_3a0_cc2 as u8);
|
w.set_trim_cc2_rp(trim_3a0_cc2 as u8);
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -57,13 +57,14 @@ async fn main(_spawner: Spawner) {
|
|||||||
|
|
||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
// This pin controls the dead-battery mode on the attached TCPP01-M12.
|
|
||||||
// If low, TCPP01-M12 disconnects CC lines and presents dead-battery resistance on CC lines, thus set high.
|
|
||||||
let _tcpp01_m12_ndb = Output::new(p.PA9, embassy_stm32::gpio::Level::High, embassy_stm32::gpio::Speed::Low);
|
|
||||||
|
|
||||||
let mut ucpd = Ucpd::new(p.UCPD1, Irqs {}, p.PB13, p.PB14, Default::default());
|
let mut ucpd = Ucpd::new(p.UCPD1, Irqs {}, p.PB13, p.PB14, Default::default());
|
||||||
ucpd.cc_phy().set_pull(CcPull::Sink);
|
ucpd.cc_phy().set_pull(CcPull::Sink);
|
||||||
|
|
||||||
|
// This pin controls the dead-battery mode on the attached TCPP01-M12.
|
||||||
|
// If low, TCPP01-M12 disconnects CC lines and presents dead-battery resistance on CC lines, thus set high.
|
||||||
|
// Must only be set after the CC pull is established.
|
||||||
|
let _tcpp01_m12_ndb = Output::new(p.PA9, embassy_stm32::gpio::Level::High, embassy_stm32::gpio::Speed::Low);
|
||||||
|
|
||||||
info!("Waiting for USB connection...");
|
info!("Waiting for USB connection...");
|
||||||
let cable_orientation = wait_attached(ucpd.cc_phy()).await;
|
let cable_orientation = wait_attached(ucpd.cc_phy()).await;
|
||||||
info!("USB cable connected, orientation: {}", cable_orientation);
|
info!("USB cable connected, orientation: {}", cable_orientation);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user