aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuntc <[email protected]>2023-01-04 10:19:39 +1100
committerhuntc <[email protected]>2023-01-04 10:19:39 +1100
commit651eec02423c42afb80e8f2eaedb4b618148a26e (patch)
tree97ed472a4d8cd37dd4fe6d94beecc2b7969c202a
parent0aa2a9ac2705ead5186d4c1d53bba55064c33db7 (diff)
Pass WDT config around
By passing WDT config around we can control it more easily and promote sharing it between files.
-rw-r--r--embassy-boot/nrf/src/lib.rs6
-rw-r--r--examples/boot/bootloader/nrf/src/main.rs9
2 files changed, 9 insertions, 6 deletions
diff --git a/embassy-boot/nrf/src/lib.rs b/embassy-boot/nrf/src/lib.rs
index 205bbd6df..f40ae62d6 100644
--- a/embassy-boot/nrf/src/lib.rs
+++ b/embassy-boot/nrf/src/lib.rs
@@ -149,11 +149,7 @@ pub struct WatchdogFlash<'d> {
149 149
150impl<'d> WatchdogFlash<'d> { 150impl<'d> WatchdogFlash<'d> {
151 /// Start a new watchdog with a given flash and WDT peripheral and a timeout 151 /// Start a new watchdog with a given flash and WDT peripheral and a timeout
152 pub fn start(flash: Nvmc<'d>, wdt: WDT, timeout: u32) -> Self { 152 pub fn start(flash: Nvmc<'d>, wdt: WDT, config: wdt::Config) -> Self {
153 let mut config = wdt::Config::default();
154 config.timeout_ticks = 32768 * timeout; // timeout seconds
155 config.run_during_sleep = true;
156 config.run_during_debug_halt = false;
157 let (_wdt, [wdt]) = match wdt::Watchdog::try_new(wdt, config) { 153 let (_wdt, [wdt]) = match wdt::Watchdog::try_new(wdt, config) {
158 Ok(x) => x, 154 Ok(x) => x,
159 Err(_) => { 155 Err(_) => {
diff --git a/examples/boot/bootloader/nrf/src/main.rs b/examples/boot/bootloader/nrf/src/main.rs
index 8266206b3..aca3b857a 100644
--- a/examples/boot/bootloader/nrf/src/main.rs
+++ b/examples/boot/bootloader/nrf/src/main.rs
@@ -6,6 +6,7 @@ use cortex_m_rt::{entry, exception};
6use defmt_rtt as _; 6use defmt_rtt as _;
7use embassy_boot_nrf::*; 7use embassy_boot_nrf::*;
8use embassy_nrf::nvmc::Nvmc; 8use embassy_nrf::nvmc::Nvmc;
9use embassy_nrf::wdt;
9 10
10#[entry] 11#[entry]
11fn main() -> ! { 12fn main() -> ! {
@@ -20,8 +21,14 @@ fn main() -> ! {
20 */ 21 */
21 22
22 let mut bl = BootLoader::default(); 23 let mut bl = BootLoader::default();
24
25 let mut wdt_config = wdt::Config::default();
26 wdt_config.timeout_ticks = 32768 * 5; // timeout seconds
27 wdt_config.run_during_sleep = true;
28 wdt_config.run_during_debug_halt = false;
29
23 let start = bl.prepare(&mut SingleFlashConfig::new(&mut BootFlash::<_, 4096>::new( 30 let start = bl.prepare(&mut SingleFlashConfig::new(&mut BootFlash::<_, 4096>::new(
24 WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, 5), 31 WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config),
25 ))); 32 )));
26 unsafe { bl.load(start) } 33 unsafe { bl.load(start) }
27} 34}