API referencestd/embedded

std/embedded/chip/rp_watchdog

Public declarations, types, methods, and source contracts for std/embedded/chip/rp_watchdog.

On this page

Library guide · API index and notation

This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.

import "std/embedded/chip/rp_watchdog"

Names used in signatures

Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.

Alias Package Source file
hal std/embedded/hal rp_watchdog.dodo

RP2040

Constant · Source

Chips, for Countdown.new and Watchdog.at.

pub const RP2040: u32 = 2040

RP2350

Constant · Source

pub const RP2350: u32 = 2350

SCRATCH_WORDS

Constant · Source

The words scratch and set_scratch reach: SCRATCH2 and 3 on the RP2040, SCRATCH0 and 1 on the RP2350. The boot ROMs keep their reboot parameters in the others.

pub const SCRATCH_WORDS: u32 = 2

max_timeout_ms

Function · Source

The longest timeout start accepts on chip, in milliseconds.

pub fn max_timeout_ms(chip: u32) -> u32

Countdown

Struct · Source

The watchdog over any hal.Registers. Implements hal.Watchdog.

pub struct Countdown<R: hal.Registers>: hal.Watchdog {
    // Private implementation fields omitted.
}

Countdown.new

Function · Source

The watchdog of chip, RP2040 or RP2350, with registers its registers and select the power-on state machine’s. It is stopped, and the reason for the last reset is read and its mark cleared. SAFETY: the watchdog’s tick must run at 1 MHz, and only this Countdown may use the watchdog’s CTRL, LOAD, REASON, and SCRATCH registers and the state machine’s WDSEL. (The RP2040’s tick generator, at the end of its watchdog’s registers, is not touched.)

pub unsafe fn new(registers: R, select: R, chip: u32) -> Countdown<R>

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

Countdown.start

Function · Source

Start counting down from timeout_ms milliseconds, or restart with this timeout if it runs already. InvalidInput for 0 or more than max_timeout_ms().

pub fn start(&mut self, timeout_ms: u32) -> void!hal.Error

Countdown.feed

Function · Source

Count down from the timeout again. Does nothing before start.

pub fn feed(&mut self)

Countdown.stop

Function · Source

Stop counting down. The chip is no longer reset, until start.

pub fn stop(&mut self)

Countdown.is_running

Function · Source

True from start until stop.

pub fn is_running(&mut self) -> bool

Countdown.timeout_ms

Function · Source

The timeout start was last given, in milliseconds; 0 before.

pub fn timeout_ms(&self) -> u32

Countdown.max_timeout_ms

Function · Source

The longest timeout start accepts: 8388 ms on the RP2040 and 16777 ms on the RP2350.

pub fn max_timeout_ms(&self) -> u32

Countdown.remaining_us

Function · Source

Microseconds until the watchdog resets the chip, if it is running.

pub fn remaining_us(&mut self) -> u32

Countdown.reset_reason

Function · Source

Why the chip last reset: Timeout if this watchdog was not fed in time, Restart after restart, and Other after power-up, the RUN pin, a debugger, or the boot ROM.

pub fn reset_reason(&self) -> hal.ResetReason

Countdown.scratch

Function · Source

Scratch word index, below SCRATCH_WORDS: whatever the program last stored there, before or after a watchdog reset; 0 after power-up. Traps for another index.

pub fn scratch(&mut self, index: u32) -> u32

Countdown.set_scratch

Function · Source

Store value in scratch word index, below SCRATCH_WORDS, where it survives a watchdog reset. Traps for another index.

pub fn set_scratch(&mut self, index: u32, value: u32)

Countdown.restart

Function · Source

Reset the chip through the watchdog now, as a timeout would but at once, whether it is running or not. reset_reason() then reads Restart. On the chip the reset follows the write; this returns only to a simulation.

pub fn restart(&mut self)

clear_mark

Function · Source

Forget the mark that makes the next watchdog reset the program’s, so that a reset through the boot ROM reads as Other. The chip packages’ reboot_to_bootloader does this before it calls the ROM. SAFETY: watchdog_base must be the chip’s watchdog, and the caller must reset the chip before the program uses its Watchdog again.

pub unsafe fn clear_mark(watchdog_base: usize)

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

Watchdog

Struct · Source

The watchdog on the chip: a Countdown over the watchdog’s and the power-on state machine’s registers, which the chip packages hand out. Implements hal.Watchdog.

pub struct Watchdog: hal.Watchdog {
    // Private implementation fields omitted.
}

Watchdog.at

Function · Source

Countdown.new over the watchdog at watchdog_base and the power-on state machine at psm_base. SAFETY: as for Countdown.new, with the bases those of chip.

pub unsafe fn at(chip: u32, watchdog_base: usize, psm_base: usize) -> Watchdog

Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.

Watchdog.start

Function · Source

pub fn start(&mut self, timeout_ms: u32) -> void!hal.Error

Watchdog.feed

Function · Source

pub fn feed(&mut self)

Watchdog.stop

Function · Source

pub fn stop(&mut self)

Watchdog.is_running

Function · Source

pub fn is_running(&mut self) -> bool

Watchdog.timeout_ms

Function · Source

pub fn timeout_ms(&self) -> u32

Watchdog.max_timeout_ms

Function · Source

pub fn max_timeout_ms(&self) -> u32

Watchdog.remaining_us

Function · Source

pub fn remaining_us(&mut self) -> u32

Watchdog.reset_reason

Function · Source

pub fn reset_reason(&self) -> hal.ResetReason

Watchdog.scratch

Function · Source

pub fn scratch(&mut self, index: u32) -> u32

Watchdog.set_scratch

Function · Source

pub fn set_scratch(&mut self, index: u32, value: u32)

Watchdog.restart

Function · Source

Reset the chip through the watchdog now. Does not return.

pub fn restart(&mut self)

Search every guide, reference page, and API declaration.