parent
711dd120d1
commit
e3fe08428f
3 changed files with 41 additions and 12 deletions
2
ci.sh
2
ci.sh
|
@ -84,6 +84,7 @@ cargo batch \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \
|
||||||
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f072c8,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \
|
||||||
|
@ -110,6 +111,7 @@ cargo batch \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \
|
||||||
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l431cb,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \
|
||||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \
|
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \
|
||||||
|
|
|
@ -11,14 +11,13 @@ pub const HSI_FREQ: Hertz = Hertz(8_000_000);
|
||||||
///
|
///
|
||||||
/// hse takes precedence over hsi48 if both are enabled
|
/// hse takes precedence over hsi48 if both are enabled
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Default)]
|
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub hse: Option<Hertz>,
|
pub hse: Option<Hertz>,
|
||||||
pub bypass_hse: bool,
|
pub bypass_hse: bool,
|
||||||
pub usb_pll: bool,
|
pub usb_pll: bool,
|
||||||
|
|
||||||
#[cfg(not(stm32f0x0))]
|
#[cfg(crs)]
|
||||||
pub hsi48: bool,
|
pub hsi48: Option<super::Hsi48Config>,
|
||||||
|
|
||||||
pub sys_ck: Option<Hertz>,
|
pub sys_ck: Option<Hertz>,
|
||||||
pub hclk: Option<Hertz>,
|
pub hclk: Option<Hertz>,
|
||||||
|
@ -27,12 +26,31 @@ pub struct Config {
|
||||||
pub ls: super::LsConfig,
|
pub ls: super::LsConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
hse: Default::default(),
|
||||||
|
bypass_hse: Default::default(),
|
||||||
|
usb_pll: Default::default(),
|
||||||
|
hsi48: Some(Default::default()),
|
||||||
|
sys_ck: Default::default(),
|
||||||
|
hclk: Default::default(),
|
||||||
|
pclk: Default::default(),
|
||||||
|
ls: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) unsafe fn init(config: Config) {
|
pub(crate) unsafe fn init(config: Config) {
|
||||||
let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0);
|
let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0);
|
||||||
|
|
||||||
|
#[cfg(crs)]
|
||||||
|
let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
|
||||||
|
#[cfg(not(crs))]
|
||||||
|
let hsi48: Option<Hertz> = None;
|
||||||
|
|
||||||
let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| {
|
let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| {
|
||||||
#[cfg(not(stm32f0x0))]
|
if hsi48.is_some() {
|
||||||
if config.hsi48 {
|
|
||||||
return (48_000_000, true);
|
return (48_000_000, true);
|
||||||
}
|
}
|
||||||
(HSI_FREQ.0, false)
|
(HSI_FREQ.0, false)
|
||||||
|
@ -169,5 +187,9 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
pclk2_tim: Some(Hertz(pclk * timer_mul)),
|
pclk2_tim: Some(Hertz(pclk * timer_mul)),
|
||||||
hclk1: Some(Hertz(hclk)),
|
hclk1: Some(Hertz(hclk)),
|
||||||
rtc: rtc,
|
rtc: rtc,
|
||||||
|
hsi48: hsi48,
|
||||||
|
|
||||||
|
// TODO:
|
||||||
|
pll1_p: None,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,12 +215,9 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
});
|
});
|
||||||
|
|
||||||
#[cfg(crs)]
|
#[cfg(crs)]
|
||||||
let _hsi48 = config.hsi48.map(|config| {
|
let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
|
||||||
//
|
|
||||||
super::init_hsi48(config)
|
|
||||||
});
|
|
||||||
#[cfg(not(crs))]
|
#[cfg(not(crs))]
|
||||||
let _hsi48: Option<Hertz> = None;
|
let hsi48: Option<Hertz> = None;
|
||||||
|
|
||||||
let _plls = [
|
let _plls = [
|
||||||
&config.pll,
|
&config.pll,
|
||||||
|
@ -274,12 +271,12 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src));
|
RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src));
|
||||||
#[cfg(any(rcc_l0_v2))]
|
#[cfg(any(rcc_l0_v2))]
|
||||||
let clk48 = match config.clk48_src {
|
let clk48 = match config.clk48_src {
|
||||||
Clk48Src::HSI48 => _hsi48,
|
Clk48Src::HSI48 => hsi48,
|
||||||
Clk48Src::PLL1_VCO_DIV_2 => pll.clk48,
|
Clk48Src::PLL1_VCO_DIV_2 => pll.clk48,
|
||||||
};
|
};
|
||||||
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
||||||
let clk48 = match config.clk48_src {
|
let clk48 = match config.clk48_src {
|
||||||
Clk48Src::HSI48 => _hsi48,
|
Clk48Src::HSI48 => hsi48,
|
||||||
Clk48Src::MSI => msi,
|
Clk48Src::MSI => msi,
|
||||||
Clk48Src::PLLSAI1_Q => pllsai1.q,
|
Clk48Src::PLLSAI1_Q => pllsai1.q,
|
||||||
Clk48Src::PLL1_Q => pll.q,
|
Clk48Src::PLL1_Q => pll.q,
|
||||||
|
@ -393,6 +390,7 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
msi: msi,
|
msi: msi,
|
||||||
#[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))]
|
#[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))]
|
||||||
clk48: clk48,
|
clk48: clk48,
|
||||||
|
hsi48: hsi48,
|
||||||
|
|
||||||
#[cfg(not(any(stm32l0, stm32l1)))]
|
#[cfg(not(any(stm32l0, stm32l1)))]
|
||||||
pll1_p: pll.p,
|
pll1_p: pll.p,
|
||||||
|
@ -407,6 +405,13 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
||||||
pllsai1_r: pllsai1.r,
|
pllsai1_r: pllsai1.r,
|
||||||
|
|
||||||
|
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||||
|
pllsai2_p: None,
|
||||||
|
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||||
|
pllsai2_q: None,
|
||||||
|
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||||
|
pllsai2_r: None,
|
||||||
|
|
||||||
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
||||||
pllsai2_p: pllsai2.p,
|
pllsai2_p: pllsai2.p,
|
||||||
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
||||||
|
|
Loading…
Reference in a new issue