diff options
Diffstat (limited to 'embassy-rp/src')
| -rw-r--r-- | embassy-rp/src/watchdog.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs index 01509ff4e..f4f165b29 100644 --- a/embassy-rp/src/watchdog.rs +++ b/embassy-rp/src/watchdog.rs | |||
| @@ -14,12 +14,12 @@ use crate::pac; | |||
| 14 | use crate::peripherals::WATCHDOG; | 14 | use crate::peripherals::WATCHDOG; |
| 15 | 15 | ||
| 16 | /// Watchdog peripheral | 16 | /// Watchdog peripheral |
| 17 | pub struct Watchdog<'d> { | 17 | pub struct Watchdog { |
| 18 | phantom: PhantomData<&'d WATCHDOG>, | 18 | phantom: PhantomData<WATCHDOG>, |
| 19 | load_value: u32, // decremented by 2 per tick (µs) | 19 | load_value: u32, // decremented by 2 per tick (µs) |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | impl<'d> Watchdog<'d> { | 22 | impl Watchdog { |
| 23 | /// Create a new `Watchdog` | 23 | /// Create a new `Watchdog` |
| 24 | pub fn new(_watchdog: WATCHDOG) -> Self { | 24 | pub fn new(_watchdog: WATCHDOG) -> Self { |
| 25 | Self { | 25 | Self { |
| @@ -35,12 +35,12 @@ impl<'d> Watchdog<'d> { | |||
| 35 | /// * `cycles` - Total number of tick cycles before the next tick is generated. | 35 | /// * `cycles` - Total number of tick cycles before the next tick is generated. |
| 36 | /// It is expected to be the frequency in MHz of clk_ref. | 36 | /// It is expected to be the frequency in MHz of clk_ref. |
| 37 | pub fn enable_tick_generation(&mut self, cycles: u8) { | 37 | pub fn enable_tick_generation(&mut self, cycles: u8) { |
| 38 | const WATCHDOG_TICK_ENABLE_BITS: u32 = 0x200; | ||
| 39 | unsafe { | 38 | unsafe { |
| 40 | let watchdog = pac::WATCHDOG; | 39 | let watchdog = pac::WATCHDOG; |
| 41 | watchdog | 40 | watchdog.tick().write(|w| { |
| 42 | .tick() | 41 | w.set_enable(true); |
| 43 | .write_value(pac::watchdog::regs::Tick(WATCHDOG_TICK_ENABLE_BITS | cycles as u32)) | 42 | w.set_cycles(cycles.into()) |
| 43 | }); | ||
| 44 | } | 44 | } |
| 45 | } | 45 | } |
| 46 | 46 | ||
