### Create and Start WindowWatchdog (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.WindowWatchdog.html?search= Initializes and immediately starts the WindowWatchdog. It requires the peripheral instance, the total timeout period in microseconds, and the 'closed window' duration in microseconds. The 'closed window' duration must be less than the total timeout. ```rust pub fn new(_instance: Peri<'d, T>, timeout_us: u32, window_us: u32) -> Self ``` -------------------------------- ### Create and Manage Independent Watchdog Timer (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html?search=u32+-%3E+bool This snippet shows how to create, start, and reload an Independent Watchdog (IWDG) timer. The `new` function initializes the watchdog with a specified timeout in microseconds. The `unleash` function starts the watchdog, and `pet` reloads it to prevent a system reset. Ensure `pet` is called within the timeout interval. ```rust pub struct IndependentWatchdog<'d, T: Instance> { /* private fields */ } impl<'d, T: Instance> IndependentWatchdog<'d, T> { pub fn new(_instance: Peri<'d, T>, timeout_us: u32) -> Self { // ... implementation ... } pub fn unleash(&mut self) { // ... implementation ... } pub fn pet(&mut self) { // ... implementation ... } } ``` -------------------------------- ### Start IndependentWatchdog (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html Starts (unleashes) the Independent Watchdog timer. Once started, the watchdog will trigger a system reset if its timer expires. This method requires mutable access to the watchdog instance. ```rust pub fn unleash(&mut self) ``` -------------------------------- ### Independent Watchdog Driver API Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html This section details the core functionalities of the Independent Watchdog driver, including initialization, starting, and periodic reloading. ```APIDOC ## Independent Watchdog Driver API ### Description Provides functionalities to manage the Independent Watchdog Timer (IWDG) for embedded systems. This includes creating an IWDG instance with a specified timeout, starting the watchdog, and periodically 'petting' (reloading) it to prevent a system reset. ### Methods #### `new(_instance: Peri<'d, T>, timeout_us: u32) -> Self` ##### Description Creates a new Independent Watchdog (IWDG) instance. The watchdog is initialized with a given timeout value in microseconds. The watchdog must be explicitly started using `unleash()` and periodically reloaded using `pet()` to avoid a system reset. ##### Parameters * **`_instance`** (`Peri<'d, T>`): The peripheral instance for the IWDG. * **`timeout_us`** (`u32`): The timeout value in microseconds. ##### Returns * `Self`: An instance of the `IndependentWatchdog`. #### `unleash(&mut self)` ##### Description Starts (unleashes) the watchdog timer. Once started, if the timer expires without being reloaded, the microcontroller will reset. ##### Parameters * `&mut self`: A mutable reference to the `IndependentWatchdog` instance. #### `pet(&mut self)` ##### Description Reloads (pets) the watchdog timer. This action must be performed repeatedly within the specified timeout interval to prevent the watchdog from triggering a system reset. ##### Parameters * `&mut self`: A mutable reference to the `IndependentWatchdog` instance. ### Request Example ```rust // Example of creating and using the watchdog use embassy_stm32::iwdg; let mut iwdg = iwdg::IndependentWatchdog::new(peri, 30_000_000); // 30 seconds timeout iwdg.unleash(); // In a loop or periodically: // iwdg.pet(); ``` ### Response * **Success Response**: N/A (These are methods, not endpoints returning data). * **Error Handling**: Specific error types are not detailed in this documentation, but potential issues could arise from invalid peripheral instances or incorrect timeout values during initialization. ``` -------------------------------- ### Create and Initialize IndependentWatchdog (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html Creates a new instance of the Independent Watchdog (IWDG) driver. It requires a peripheral instance and a timeout value in microseconds. The watchdog must be started using `unleash()` and periodically reloaded with `pet()` to prevent a system reset. ```rust pub fn new(_instance: Peri<'d, T>, timeout_us: u32) -> Self ``` -------------------------------- ### WindowWatchdog Initialization and Usage Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.WindowWatchdog.html This section details the creation and usage of the Window Watchdog driver, including its parameters and the 'pet' functionality. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_wdg ### Description Initializes and starts the window watchdog timer. Once activated, the WWDG cannot be stopped without a system reset. The counter counts down from an initial value to 0x3F, triggering a reset. Petting the watchdog while the counter is above the window register 'W' also causes an immediate reset. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_wdg ### Parameters #### Query Parameters - **timeout_us** (u32) - Required - Total watchdog period in microseconds (counter-to-reset time). - **window_us** (u32) - Required - Closed-window duration in microseconds. During this initial portion of the period, petting the watchdog causes a reset. Pass 0 to disable the window restriction. Must be strictly less than `timeout_us`. ### Request Example ```json { "timeout_us": 1000000, "window_us": 500000 } ``` ### Response #### Success Response (200) - **Self** (WindowWatchdog) - The initialized WindowWatchdog instance. #### Response Example ```json { "message": "WindowWatchdog initialized successfully" } ``` ## PUT /websites/embassy_dev_embassy-stm32_git_stm32c092kb_wdg/pet ### Description Pets (reloads) the watchdog timer. This must be called while the counter has fallen into the open window (counter <= W). Calling too early (counter > W) causes an immediate reset. ### Method PUT ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_wdg/pet ### Parameters #### Request Body This endpoint does not require a request body. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **message** (string) - Indicates the watchdog has been successfully petted. #### Response Example ```json { "message": "Watchdog petted successfully" } ``` ``` -------------------------------- ### WindowWatchdog Initialization and Operation Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.WindowWatchdog.html?search= This section details the initialization of the Window Watchdog timer and its core operations, including petting the watchdog. ```APIDOC ## WindowWatchdog Driver API ### Description The Window Watchdog (WWDG) driver provides functionality to prevent system hangs by requiring periodic 'petting' of the watchdog. If the watchdog is not petted within a specified time window, it triggers a system reset. The counter decrements from an initial value down to 0x3F, triggering a reset. A 'closed window' period exists at the beginning where petting the watchdog also causes a reset. ### `WindowWatchdog::new` #### Description Creates and immediately starts the window watchdog timer. #### Method `pub fn new(_instance: Peri<'d, T>, timeout_us: u32, window_us: u32) -> Self` #### Parameters * **`_instance`** (`Peri<'d, T>`): The peripheral instance for the WWDG. * **`timeout_us`** (`u32`): The total watchdog period in microseconds (time until counter reaches reset). * **`window_us`** (`u32`): The duration of the 'closed window' in microseconds. During this period, petting the watchdog causes an immediate reset. Set to `0` to disable window restriction. Must be less than `timeout_us`. ### `WindowWatchdog::pet` #### Description Pets (reloads) the watchdog timer. This must be called when the counter is within the 'open window' (counter value is less than or equal to the window register `W`). Calling this too early (counter value is greater than `W`) will cause an immediate reset. #### Method `pub fn pet(&mut self)` #### Parameters None ### Response #### Success Response (Initialization) * `Self` (`WindowWatchdog`): The initialized WindowWatchdog instance. #### Success Response (Pet) None (operation is in-place) #### Error Response * A system reset is triggered if the watchdog is petted outside the 'open window' or if the timeout occurs without petting. ``` -------------------------------- ### WDG Instance Trait Definition (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/trait.Instance.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Defines the `Instance` trait for WDG peripherals in the embassy-stm32 library. This trait requires implementations to also satisfy `SealedInstance` and `PeripheralType`, ensuring a consistent interface for WDG operations across various STM32 families. ```rust pub trait Instance: SealedInstance + PeripheralType { } ``` -------------------------------- ### IWDG Instance Trait Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/trait.Instance.html?search=u32+-%3E+bool The `Instance` trait represents an IWDG peripheral instance. It requires implementations of `SealedInstance` and `PeripheralType` traits. ```APIDOC ## Trait: Instance ### Description Represents an IWDG (Independent Watchdog Timer) instance. ### Requirements This trait requires that the implementing type also implements the `SealedInstance` and `PeripheralType` traits. ### Usage This trait is typically used to abstract over different IWDG peripheral instances, allowing for generic code that can operate on any IWDG instance. ```rust // Example of a type implementing the Instance trait pub trait Instance: SealedInstance + PeripheralType { } ``` ### Associated Types - `SealedInstance`: A sealed trait that prevents external implementations. - `PeripheralType`: A trait that defines the peripheral type, likely indicating it's an IWDG peripheral. ``` -------------------------------- ### IndependentWatchdog Driver API Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html?search=std%3A%3Avec This section details the methods available for interacting with the Independent Watchdog (IWDG) driver. ```APIDOC ## IndependentWatchdog Driver API ### Description Provides functionality to manage the Independent Watchdog (IWDG) timer on embedded systems. This driver allows for the creation of an IWDG instance, starting the watchdog, and periodically refreshing (petting) it to prevent system resets. ### Methods #### `new(_instance: Peri<'d, T>, timeout_us: u32) -> Self` ##### Description Creates a new Independent Watchdog (IWDG) instance with a specified timeout in microseconds. The watchdog must be explicitly started using `unleash()` and periodically reloaded with `pet()` to avoid a system reset. ##### Parameters - `_instance` (Peri<'d, T>): The peripheral instance for the IWDG. - `timeout_us` (u32): The timeout value in microseconds. ##### Returns - `Self`: An instance of the `IndependentWatchdog`. #### `unleash(&mut self)` ##### Description Starts (unleashes) the Independent Watchdog timer. Once started, the watchdog will begin counting down, and if not reloaded before the timeout, it will trigger a system reset. ##### Method - `&mut self` #### `pet(&mut self)` ##### Description Reloads (pets) the Independent Watchdog timer. This action resets the watchdog's countdown, preventing a system reset as long as it's called within the specified timeout interval. ##### Method - `&mut self` ``` -------------------------------- ### Define WindowWatchdog Structure (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.WindowWatchdog.html?search= Defines the structure for the WindowWatchdog driver. It is generic over a type T that implements the WwdgInstance trait. The internal fields are private. ```rust pub struct WindowWatchdog<'d, T: WwdgInstance> { /* private fields */ } ``` -------------------------------- ### Define IndependentWatchdog Structure (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html Defines the structure for the Independent Watchdog (IWDG) driver. This structure holds private fields and is generic over a lifetime and an instance type `T` that must implement the `Instance` trait. ```rust pub struct IndependentWatchdog<'d, T: Instance> { /* private fields */ } ``` -------------------------------- ### Reload IndependentWatchdog Timer (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/struct.IndependentWatchdog.html Reloads (pets) the Independent Watchdog timer, preventing an imminent system reset. This function must be called repeatedly within the specified timeout interval to keep the system operational. It requires mutable access to the watchdog instance. ```rust pub fn pet(&mut self) ``` -------------------------------- ### Define WwdgInstance Trait in Rust Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/wdg/trait.WwdgInstance.html?search=u32+-%3E+bool This Rust code defines the WwdgInstance trait, which requires implementors to also implement WwdgSealedInstance, PeripheralType, and RccPeripheral traits. This trait is not dyn compatible. ```rust pub trait WwdgInstance: WwdgSealedInstance + PeripheralType + RccPeripheral { } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.