API referencestd/embedded

std/embedded/chip/esp_watchdog

Public declarations, types, methods, and source contracts for std/embedded/chip/esp_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/esp_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 esp_watchdog.dodo

MAX_TIMEOUT_MS

Constant · Source

The longest timeout start accepts, in milliseconds: an hour.

pub const MAX_TIMEOUT_MS: u32 = 3_600_000

SCRATCH_WORDS

Constant · Source

pub const SCRATCH_WORDS: u32 = 2

CAUSE_MWDT0

Constant · Source

LP_CLKRST RESET_CAUSE’s cause of a timer group 0 watchdog reset.

pub const CAUSE_MWDT0: u32 = 0x07

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 the timer group with registers timer, stopped, with its mark and scratch words in store, LP_AON’s registers. cause is the cause of the last reset from LP_CLKRST RESET_CAUSE; with the mark it gives reset_reason(), and the mark is then cleared. clock reads microseconds, for remaining_us(). SAFETY: the group’s watchdog clock must count the 40 MHz crystal, and only this Countdown may use the group’s watchdog registers and LP_AON STORE0, STORE2, and STORE3.

pub unsafe fn new(timer: R, store: R, cause: u32, clock: fn() -> u64) -> 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 while stopped.

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: MAX_TIMEOUT_MS, an hour.

pub fn max_timeout_ms(&self) -> u32

Countdown.remaining_us

Function · Source

Microseconds until the watchdog resets the chip, if it is running; 0 while it is stopped. The watchdog’s count cannot be read, so this counts from the last start or feed on the clock.

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 or a panic halted the program while it ran, Restart after restart, and Other after power-up, the reset pin, a software reset, a debugger, or flashing.

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 any 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 every reset but losing power. 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 within 10 us, whether it is running or not. reset_reason() then reads Restart. On the chip the reset follows; this returns only to a simulation.

pub fn restart(&mut self)

Watchdog

Struct · Source

The watchdog on the chip: a Countdown over TIMG0’s and LP_AON’s registers, which the chip package hands out. Implements hal.Watchdog.

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

Watchdog.at

Function · Source

Countdown.new over the timer group at timer_base and LP_AON at store_base. SAFETY: as for Countdown.new.

pub unsafe fn at(timer_base: usize, store_base: usize, cause: u32, clock: fn() -> u64) -> 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.