From 83211c2b615a781c7569907aff2f9ae977b16be3 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sun, 27 Mar 2022 18:45:10 +0300 Subject: [PATCH] Add workaround for F2 errata --- embassy-stm32/build.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 4cba1c66..2c8409a3 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -166,6 +166,15 @@ fn main() { None => TokenStream::new(), }; + let after_enable = if chip_name.starts_with("stm32f2") { + // Errata: ES0005 - 2.1.11 Delay after an RCC peripheral clock enabling + quote! { + cortex_m::asm::dsb(); + } + } else { + TokenStream::new() + }; + let pname = format_ident!("{}", p.name); let clk = format_ident!("{}", rcc.clock.to_ascii_lowercase()); let en_reg = format_ident!("{}", en.register.to_ascii_lowercase()); @@ -180,7 +189,8 @@ fn main() { } fn enable() { critical_section::with(|_| unsafe { - crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true)) + crate::pac::RCC.#en_reg().modify(|w| w.#set_en_field(true)); + #after_enable }) } fn disable() {