aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-22 14:18:48 -0400
committerBob McWhirter <[email protected]>2021-07-22 14:18:48 -0400
commitd68f2617e663c933c11d5406c7ae12abc5e82938 (patch)
treee5f6ac816921ef0eca6118a331147af028465ecc /examples
parent3655ceff279159b757d7a04ffac3483a7bf5c7b4 (diff)
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.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32f4/src/bin/spi.rs7
-rw-r--r--examples/stm32h7/src/bin/usart_dma.rs11
2 files changed, 6 insertions, 12 deletions
diff --git a/examples/stm32f4/src/bin/spi.rs b/examples/stm32f4/src/bin/spi.rs
index 7cf391394..f8c9997ed 100644
--- a/examples/stm32f4/src/bin/spi.rs
+++ b/examples/stm32f4/src/bin/spi.rs
@@ -18,17 +18,14 @@ use embassy_stm32::pac;
18use embassy_stm32::spi::{Config, Spi}; 18use embassy_stm32::spi::{Config, Spi};
19use embassy_stm32::time::Hertz; 19use embassy_stm32::time::Hertz;
20use embedded_hal::blocking::spi::Transfer; 20use embedded_hal::blocking::spi::Transfer;
21use embassy_stm32::dbgmcu::Dbgmcu;
21 22
22#[entry] 23#[entry]
23fn main() -> ! { 24fn main() -> ! {
24 info!("Hello World, dude!"); 25 info!("Hello World, dude!");
25 26
26 unsafe { 27 unsafe {
27 pac::DBGMCU.cr().modify(|w| { 28 Dbgmcu::enable_all();
28 w.set_dbg_sleep(true);
29 w.set_dbg_standby(true);
30 w.set_dbg_stop(true);
31 });
32 29
33 pac::RCC.ahb1enr().modify(|w| { 30 pac::RCC.ahb1enr().modify(|w| {
34 w.set_gpioaen(true); 31 w.set_gpioaen(true);
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs
index 0073d5c66..097466cea 100644
--- a/examples/stm32h7/src/bin/usart_dma.rs
+++ b/examples/stm32h7/src/bin/usart_dma.rs
@@ -14,6 +14,7 @@ use embassy::time::Clock;
14use embassy::util::Forever; 14use embassy::util::Forever;
15use embassy_stm32::dma::NoDma; 15use embassy_stm32::dma::NoDma;
16use embassy_stm32::usart::{Config, Uart}; 16use embassy_stm32::usart::{Config, Uart};
17use embassy_stm32::dbgmcu::Dbgmcu;
17use example_common::*; 18use example_common::*;
18use embassy_traits::uart::Write as _Write; 19use embassy_traits::uart::Write as _Write;
19 20
@@ -72,13 +73,9 @@ fn main() -> ! {
72 73
73 let pp = unsafe { pac::Peripherals::steal() }; 74 let pp = unsafe { pac::Peripherals::steal() };
74 75
75 pp.DBGMCU.cr.modify(|_, w| { 76 unsafe {
76 w.dbgsleep_d1().set_bit(); 77 Dbgmcu::enable_all();
77 w.dbgstby_d1().set_bit(); 78 }
78 w.dbgstop_d1().set_bit();
79 w.d1dbgcken().set_bit();
80 w
81 });
82 79
83 pp.RCC.ahb4enr.modify(|_, w| { 80 pp.RCC.ahb4enr.modify(|_, w| {
84 w.gpioaen().set_bit(); 81 w.gpioaen().set_bit();