From d68f2617e663c933c11d5406c7ae12abc5e82938 Mon Sep 17 00:00:00 2001 From: Bob McWhirter Date: Thu, 22 Jul 2021 14:18:48 -0400 Subject: Add a `Dbgmcu` struct capable of enabling all relevant DBGMCU.cr fields. Includes the addition of a `dbgmcu!(...)` macro table which currently takes the form of (cr, $fn_name:ident) where `$fn_name` is something like `set_dbgsleep_d1` etc. The method is unsafe, since it's performing unsafe PAC operations. Two examples modified to demonstrate its usage. --- embassy-stm32/src/dbgmcu/mod.rs | 13 +++++++++++++ embassy-stm32/src/lib.rs | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 embassy-stm32/src/dbgmcu/mod.rs (limited to 'embassy-stm32/src') diff --git a/embassy-stm32/src/dbgmcu/mod.rs b/embassy-stm32/src/dbgmcu/mod.rs new file mode 100644 index 000000000..8dc4cc53f --- /dev/null +++ b/embassy-stm32/src/dbgmcu/mod.rs @@ -0,0 +1,13 @@ +pub struct Dbgmcu {} + +impl Dbgmcu { + pub unsafe fn enable_all() { + crate::pac::DBGMCU.cr().modify(|cr| { + crate::pac::dbgmcu! { + (cr, $fn_name:ident) => { + cr.$fn_name(true); + }; + } + }); + } +} diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index c10310e2d..07f8b9f3b 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs @@ -31,6 +31,8 @@ pub mod adc; pub mod clock; #[cfg(dac)] pub mod dac; +#[cfg(dbgmcu)] +pub mod dbgmcu; #[cfg(all(eth, feature = "net"))] pub mod eth; #[cfg(exti)] -- cgit