mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-28 21:01:06 +00:00
ucpd: Add software trim setting of the CC Rp/Rd for stm32u5 parts.
This commit is contained in:
parent
0eceb08b90
commit
701e824175
@ -193,6 +193,18 @@ impl<'d, T: Instance> Ucpd<'d, T> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Software trim according to RM0456, p. 3480/3462
|
||||||
|
#[cfg(stm32u5)]
|
||||||
|
{
|
||||||
|
let trim_rd_cc1 = unsafe { *(0x0BFA_0544 as *const u8) & 0xF };
|
||||||
|
let trim_rd_cc2 = unsafe { *(0x0BFA_0546 as *const u8) & 0xF };
|
||||||
|
|
||||||
|
r.cfgr3().write(|w| {
|
||||||
|
w.set_trim_cc1_rd(trim_rd_cc1);
|
||||||
|
w.set_trim_cc2_rd(trim_rd_cc2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
cc_phy: CcPhy { _lifetime: PhantomData },
|
cc_phy: CcPhy { _lifetime: PhantomData },
|
||||||
}
|
}
|
||||||
@ -314,6 +326,25 @@ impl<'d, T: Instance> CcPhy<'d, T> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Software trim according to RM0456, p. 3480/3462
|
||||||
|
#[cfg(stm32u5)]
|
||||||
|
T::REGS.cfgr3().modify(|w| match cc_pull {
|
||||||
|
CcPull::Source1_5A => {
|
||||||
|
let trim_1a5_cc1 = unsafe { *(0x0BFA_07A7 as *const u8) & 0xF };
|
||||||
|
let trim_1a5_cc2 = unsafe { *(0x0BFA_07A8 as *const u8) & 0xF };
|
||||||
|
|
||||||
|
w.set_trim_cc1_rp(trim_1a5_cc1);
|
||||||
|
w.set_trim_cc2_rp(trim_1a5_cc2);
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let trim_3a0_cc1 = unsafe { *(0x0BFA_0545 as *const u8) & 0xF };
|
||||||
|
let trim_3a0_cc2 = unsafe { *(0x0BFA_0547 as *const u8) & 0xF };
|
||||||
|
|
||||||
|
w.set_trim_cc1_rp(trim_3a0_cc1);
|
||||||
|
w.set_trim_cc2_rp(trim_3a0_cc2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Disable dead-battery pull-down resistors which are enabled by default on boot.
|
// Disable dead-battery pull-down resistors which are enabled by default on boot.
|
||||||
critical_section::with(|cs| {
|
critical_section::with(|cs| {
|
||||||
init(
|
init(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user