### Initialize and Use RingBufferedPwmChannel Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html Demonstrates how to initialize a RingBufferedPwmChannel and start continuous PWM generation. It shows starting the DMA transfer and updating duty cycles. ```rust let mut channel = pwm.ch1().into_ring_buffered_channel(dma_ch, &mut buffer, Irqs); channel.start(); // Start DMA transfer channel.write(&[100, 200, 300]).ok(); // Update duty cycles ``` -------------------------------- ### Timer Initialization and Core Functionality Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html?search=u32+-%3E+bool Provides methods for creating a new timer instance, accessing core registers, and controlling the timer's basic operations like starting, stopping, and resetting. ```APIDOC ## Timer Initialization and Core Functionality ### Description Methods for initializing and controlling the fundamental operations of the timer. ### Methods #### `new(tim: Peri<'d, T>) -> Self` **Description:** Creates a new timer driver instance. **Method:** `new` **Endpoint:** N/A (Constructor) #### `regs_core(&self) -> TimCore` **Description:** Gets access to the virtual core 16-bit timer registers. This method is designed to work transparently with timers of varying capabilities by accessing a subset of registers common to less capable timers. **Method:** `regs_core` **Endpoint:** N/A #### `start(&self)` **Description:** Starts the timer. **Method:** `start` **Endpoint:** N/A #### `generate_update_event(&self)` **Description:** Generates a timer update event from software. Setting the URS bit avoids generating an interrupt or DMA request. This event is used solely for loading values from pre-load registers. If called while the timer is running, it may disrupt the output waveform. **Method:** `generate_update_event` **Endpoint:** N/A #### `stop(&self)` **Description:** Stops the timer. **Method:** `stop` **Endpoint:** N/A #### `reset(&self)` **Description:** Resets the counter value to 0. **Method:** `reset` **Endpoint:** N/A #### `bits(&self) -> TimerBits` **Description:** Retrieves the capability of the timer. **Method:** `bits` **Endpoint:** N/A ``` -------------------------------- ### RingBufferedPwmChannel Utility Methods Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html?search=std%3A%3Avec Documentation for utility methods like getting the maximum duty cycle. ```APIDOC ## GET /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/RingBufferedPwmChannel/max_duty_cycle ### Description Gets the maximum possible duty cycle value for the current configuration. ### Method GET ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/RingBufferedPwmChannel/max_duty_cycle ### Parameters None ### Response #### Success Response (200) - **max_duty** (u16) - The maximum duty cycle value. #### Response Example ```json { "max_duty": 65535 } ``` ``` -------------------------------- ### Input Capture and Output Compare Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html?search=std%3A%3Avec APIs for configuring and managing input capture and output compare channels, including interrupt and DMA setup. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_filter ### Description Set input capture filter. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_filter ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **icf** (FilterValue) - The filter value to set. ### Request Example ```json { "channel": "CH1", "icf": "f1" } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/clear_input_interrupt ### Description Clear input interrupt. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/clear_input_interrupt ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel for which to clear the interrupt. ### Request Example ```json { "channel": "CH1" } ``` ### Response #### Success Response (200) None #### Response Example None ## GET /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_input_interrupt ### Description Get input interrupt status. ### Method GET ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_input_interrupt ### Parameters #### Path Parameters None #### Query Parameters - **channel** (Channel) - The channel to check. ### Request Example None ### Response #### Success Response (200) - **return_value** (bool) - True if the interrupt is pending, false otherwise. #### Response Example ```json { "return_value": true } ``` ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/enable_input_interrupt ### Description Enable or disable input interrupt. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/enable_input_interrupt ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **enable** (bool) - True to enable, false to disable. ### Request Example ```json { "channel": "CH1", "enable": true } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_prescaler ### Description Set input capture prescaler. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_prescaler ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **factor** (u8) - The prescaler factor. ### Request Example ```json { "channel": "CH1", "factor": 2 } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_ti_selection ### Description Set input TI selection. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_ti_selection ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **tisel** (InputTISelection) - The TI selection to set. ### Request Example ```json { "channel": "CH1", "tisel": "TI1" } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_mode ### Description Set input capture mode. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_input_capture_mode ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **mode** (InputCaptureMode) - The input capture mode. ### Request Example ```json { "channel": "CH1", "mode": "RisingEdge" } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_output_compare_mode ### Description Set output compare mode. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_output_compare_mode ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **mode** (OutputCompareMode) - The output compare mode. ### Request Example ```json { "channel": "CH1", "mode": "Toggle" } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_output_polarity ### Description Set output polarity. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_output_polarity ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **polarity** (OutputPolarity) - The output polarity. ### Request Example ```json { "channel": "CH1", "polarity": "ActiveHigh" } ``` ### Response #### Success Response (200) None #### Response Example None ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/enable_channel ### Description Enable or disable a channel. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/enable_channel ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to enable or disable. - **enable** (bool) - True to enable, false to disable. ### Request Example ```json { "channel": "CH1", "enable": true } ``` ### Response #### Success Response (200) None #### Response Example None ## GET /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_channel_enable_state ### Description Get enable/disable state of a channel. ### Method GET ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_channel_enable_state ### Parameters #### Path Parameters None #### Query Parameters - **channel** (Channel) - The channel to query. ### Request Example None ### Response #### Success Response (200) - **return_value** (bool) - True if the channel is enabled, false otherwise. #### Response Example ```json { "return_value": true } ``` ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_compare_value ### Description Set compare value for a channel. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/set_compare_value ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **channel** (Channel) - The channel to configure. - **value** (T::Word) - The compare value to set. ### Request Example ```json { "channel": "CH1", "value": 1000 } ``` ### Response #### Success Response (200) None #### Response Example None ## GET /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_compare_value ### Description Get compare value for a channel. ### Method GET ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/get_compare_value ### Parameters #### Path Parameters None #### Query Parameters - **channel** (Channel) - The channel to query. ### Request Example None ### Response #### Success Response (200) - **return_value** (T::Word) - The current compare value. #### Response Example ```json { "return_value": 1000 } ``` ``` -------------------------------- ### Get and Set Pulse Delay Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulseChannel.html?search=std%3A%3Avec Allows getting and setting the pulse delay in ticks. This delay determines the time between the trigger event and the start of the pulse. ```rust pub fn pulse_delay(&mut self) -> u32 ``` ```rust pub fn set_pulse_delay(&mut self, delay: u32) ``` -------------------------------- ### Get Pulse Delay in Rust Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulseChannel.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the pulse delay in ticks from the trigger for a `OnePulseChannel`. This value determines the time between the trigger event and the start of the pulse. ```rust pub fn pulse_delay(&mut self) -> u32 ``` -------------------------------- ### Qei Driver Initialization Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/struct.Qei.html?search=u32+-%3E+bool Initializes a new Qei driver instance with the specified timer, channels, and configuration. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/impl ### Description Creates a new quadrature decoder driver with a given `Config`. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/impl ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **tim** (Peri<'d, T>) - Required - The timer instance. - **ch1** (Peri<'d, impl TimerPin>) - Required - The first quadrature channel pin. - **ch2** (Peri<'d, impl TimerPin>) - Required - The second quadrature channel pin. - **config** (Config) - Required - The configuration for the Qei driver. ### Request Example ```json { "tim": "timer_instance", "ch1": "channel1_pin", "ch2": "channel2_pin", "config": { "prescaler": 0, "polarity": "Rising", "filter": 0 } } ``` ### Response #### Success Response (200) - **Self** (Qei<'d, T>) - The newly created Qei driver instance. #### Response Example ```json { "driver": "qei_instance_details" } ``` ``` -------------------------------- ### Timer Ring Buffer Setup Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html Sets up a ring buffer for a timer channel, typically used for continuous waveform generation or data logging. Requires DMA and interrupt configuration. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/setup_ring_buffer ### Description Setup a ring buffer for the channel. This is typically used for continuous waveform generation or data logging and requires DMA and interrupt configuration. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/setup_ring_buffer ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **dma** (Peri<'a, D>) - Required - The DMA peripheral. - **irq** (impl Binding> + 'a) - Required - The interrupt binding. - **channel** (Channel) - Required - The timer channel. - **dma_buf** (&'a mut [W]) - Required - The buffer for DMA data. ### Request Example ```json { "dma": "", "irq": "", "channel": "CH1", "dma_buf": [0, 1, 2, 3, 4] } ``` ### Response #### Success Response (200) - **ring_buffer** (WritableRingBuffer<'a, W>) - The configured writable ring buffer. #### Response Example ```json { "ring_buffer": "" } ``` ``` -------------------------------- ### RingBufferedPwmChannel: Start DMA Operation Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html Starts the ring buffer operation for the PWM channel. This method must be called after the channel is created for it to function. ```rust pub fn start(&mut self) ``` -------------------------------- ### Create PwmPin Instance Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.PwmPin.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to create new PwmPin instances. The `new` function initializes a PWM pin with a default output type, while `new_with_config` allows for a specific PwmPinConfig to be applied. ```rust pub fn new(pin: Peri<'d, impl TimerPin>, output_type: OutputType) -> Self ``` ```rust pub fn new_with_config( pin: Peri<'d, impl TimerPin>, pin_config: PwmPinConfig, ) -> Self ``` -------------------------------- ### Generic Type Conversion Implementations Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/enum.QeiMode.html?search=u32+-%3E+bool Demonstrates various blanket implementations for generic types, including Any, Borrow, BorrowMut, CloneToUninit, From, Into, TryFrom, and TryInto. These traits enable common operations and conversions for any type that meets the specified bounds. ```rust impl Any for T where T: 'static + ?Sized { fn type_id(&self) -> TypeId; } impl Borrow for T where T: ?Sized { fn borrow(&self) -> &T; } impl BorrowMut for T where T: ?Sized { fn borrow_mut(&mut self) -> &mut T; } unsafe impl CloneToUninit for T where T: Clone { unsafe fn clone_to_uninit(&self, dest: *mut u8); } impl From for T { fn from(t: T) -> T; } impl Into for T where U: From { fn into(self) -> U; } impl TryFrom for T where U: Into { type Error = Infallible; fn try_from(value: U) -> Result>::Error>; } impl TryInto for T where U: TryFrom { type Error = >::Error; fn try_into(self) -> Result>::Error>; } ``` -------------------------------- ### Rust: Get TypeId using Any trait Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/enum.Ch3.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to get the TypeId of a type using the `Any` trait. This is useful for runtime type identification. ```rust impl Any for T where T: 'static + ?Sized, { fn type_id(&self) -> TypeId; } ``` -------------------------------- ### Rust PwmInput Driver Initialization Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/pwm_input/struct.PwmInput.html?search=std%3A%3Avec Provides methods to create new PwmInput driver instances for either channel 1 or channel 2. These methods require timer peripherals, pin configurations, interrupt bindings, pull-up/down settings, and the desired frequency. ```rust pub fn new_ch1( tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, _irq: impl Binding> + 'd, pull: Pull, freq: Hertz, ) -> Self ``` ```rust pub fn new_ch2( tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, _irq: impl Binding> + 'd, pull: Pull, freq: Hertz, ) -> Self ``` -------------------------------- ### Wait for Pulse Start in Rust Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulseChannel.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Asynchronously waits until the trigger event and the configured delay have passed for a `OnePulseChannel`. This is useful for synchronizing operations with the start of a pulse. ```rust pub async fn wait_for_pulse_start(&mut self) ``` -------------------------------- ### Qei Driver Initialization Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/struct.Qei.html API for creating a new Qei driver instance with a given configuration. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/new ### Description Create a new quadrature decoder driver, with a given `Config`. ### Method POST ### Endpoint `/websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/new` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **tim** (Peri<'d, T>) - Required - The timer peripheral instance. - **ch1** (Peri<'d, impl TimerPin>) - Required - The first quadrature encoder input channel. - **ch2** (Peri<'d, impl TimerPin>) - Required - The second quadrature encoder input channel. - **config** (Config) - Required - The configuration for the Qei driver. ### Request Example ```json { "tim": "timer_instance", "ch1": "channel1_pin", "ch2": "channel2_pin", "config": { "prescaler": 1, "period": 65535, "polarity": "RisingEdge" } } ``` ### Response #### Success Response (200) - **Self** (Qei<'d, T>) - The newly created Qei driver instance. #### Response Example ```json { "driver_instance": "" } ``` ``` -------------------------------- ### Get and Set Pulse Width Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulseChannel.html?search=std%3A%3Avec Provides methods to get and set the pulse width in ticks. The pulse width defines the duration of the output pulse after the trigger and delay. ```rust pub fn pulse_width(&mut self) -> u32 ``` ```rust pub fn set_pulse_width(&mut self, width: u32) ``` -------------------------------- ### QEI Driver Configuration Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/index.html Provides details on configuring the Quadrature Encoder Interface (QEI) driver. ```APIDOC ## Structs ### Config Quadrature decoder driver config. ### Qei Quadrature decoder driver. ``` -------------------------------- ### Get Channel 4 of OnePulse (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulse.html?search=std%3A%3Avec A convenience method to get access to Channel 4 of the `OnePulse` driver. It's a wrapper around `Self::channel`. ```rust pub fn ch4(&mut self) -> OnePulseChannel<'_, T> ``` -------------------------------- ### Create PwmPin Instance with PwmPinConfig in Rust Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.PwmPin.html Offers a constructor for PwmPin that accepts a pin and a PwmPinConfig. This allows for creating a PWM pin wrapper with detailed, pre-defined settings. ```rust pub fn new_with_config( pin: Peri<'d, impl TimerPin>, pin_config: PwmPinConfig, ) -> Self ``` -------------------------------- ### Get Channel 3 of OnePulse (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulse.html?search=std%3A%3Avec A convenience method to get access to Channel 3 of the `OnePulse` driver. It's a wrapper around `Self::channel`. ```rust pub fn ch3(&mut self) -> OnePulseChannel<'_, T> ``` -------------------------------- ### Get Channel 2 of OnePulse (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulse.html?search=std%3A%3Avec A convenience method to get access to Channel 2 of the `OnePulse` driver. It's a wrapper around `Self::channel`. ```rust pub fn ch2(&mut self) -> OnePulseChannel<'_, T> ``` -------------------------------- ### Generic Type Conversion: TryFrom/TryInto (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/complementary_pwm/enum.Ossi.html?search=std%3A%3Avec Demonstrates blanket implementations of TryFrom and TryInto for generic types. These traits facilitate fallible conversions between different types, returning a Result. ```Rust type Error = Infallible fn try_from(value: U) -> Result>::Error> type Error = >::Error ``` -------------------------------- ### Get Channel 1 of OnePulse (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/one_pulse/struct.OnePulse.html?search=std%3A%3Avec A convenience method to get access to Channel 1 of the `OnePulse` driver. It's a wrapper around `Self::channel`. ```rust pub fn ch1(&mut self) -> OnePulseChannel<'_, T> ``` -------------------------------- ### Initialize PWM Input Driver (Rust) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/pwm_input/struct.PwmInput.html Creates a new PWM input driver instance for either channel 1 or channel 2. Requires timer peripheral, pin, interrupt binding, pull-up/down configuration, and frequency. Note: Not all timer peripherals are supported; consult your chip's reference manual. ```rust pub fn new_ch1( tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, _irq: impl Binding> + 'd, pull: Pull, freq: Hertz, ) -> Self ``` ```rust pub fn new_ch2( tim: Peri<'d, T>, pin: Peri<'d, impl TimerPin>, _irq: impl Binding> + 'd, pull: Pull, freq: Hertz, ) -> Self ``` -------------------------------- ### Get and Set PWM Duty Cycle Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/complementary_pwm/struct.ComplementaryPwm.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides a method to get the maximum possible duty cycle value, which depends on the timer's clock rate and configured frequency. It also allows setting the duty cycle for a specific channel, with values ranging from 0 (0%) to `get_max_duty()` (100%). ```rust pub fn get_max_duty(&self) -> u32 pub fn set_duty(&mut self, channel: Channel, duty: u32) ``` -------------------------------- ### SimplePwm Initialization and Configuration Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.SimplePwm.html This section covers the creation and configuration of the SimplePwm driver, including setting frequency and period. ```APIDOC ## SimplePwm Initialization and Configuration ### Description Provides methods for creating and configuring the SimplePwm driver, including setting its operating frequency and period. ### Methods #### `new` * **Description**: Creates a new simple PWM driver instance. * **Parameters**: * `tim` (Peri<'d, T>): The timer peripheral to use. * `ch1` (Option>): Optional PWM pin for channel 1. * `ch2` (Option>): Optional PWM pin for channel 2. * `ch3` (Option>): Optional PWM pin for channel 3. * `ch4` (Option>): Optional PWM pin for channel 4. * `freq` (Hertz): The desired PWM frequency. * `counting_mode` (CountingMode): The timer's counting mode. #### `set_frequency` * **Description**: Sets the PWM frequency. The actual frequency may differ due to hardware limitations. * **Parameters**: * `freq` (Hertz): The desired frequency. #### `get_frequency` * **Description**: Gets the current PWM driver frequency. * **Returns**: `Hertz` - The current frequency. #### `set_period_ms` * **Description**: Sets the PWM period in milliseconds. The actual period may differ due to hardware limitations. * **Parameters**: * `ms` (u32): The desired period in milliseconds. #### `set_period_us` * **Description**: Sets the PWM period in microseconds. The actual period may differ due to hardware limitations. * **Parameters**: * `us` (u32): The desired period in microseconds. #### `set_period_secs` * **Description**: Sets the PWM period in seconds. The actual period may differ due to hardware limitations. * **Parameters**: * `secs` (u32): The desired period in seconds. #### `set_period` * **Description**: Sets the PWM period using an `embassy_time::Duration`. The actual period may differ due to hardware limitations. * **Parameters**: * `period` (Duration): The desired period. #### `max_duty_cycle` * **Description**: Gets the maximum duty cycle value, which depends on the configured frequency and the timer's clock rate. * **Returns**: `u32` - The maximum duty cycle value. ``` -------------------------------- ### Timer Control Operations Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html?search= Functions for starting, stopping, resetting, and generating events for the timer. ```APIDOC ## Timer Control Operations ### Description This section details the methods for controlling the timer's operation, including starting, stopping, and event generation. ### Methods #### `start(&self)` **Description**: Starts the timer. **Method**: `&self` #### `generate_update_event(&self)` **Description**: Generates a timer update event from software. Setting URS avoids generating an interrupt or DMA request. This update event is solely used to load values from pre-load registers. If called while the timer is running, it may disrupt the output waveform. **Method**: `&self` #### `stop(&self)` **Description**: Stops the timer. **Method**: `&self` #### `reset(&self)` **Description**: Resets the counter value to 0. **Method**: `&self` ``` -------------------------------- ### SimplePwmChannel Methods Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.SimplePwmChannel.html?search=u32+-%3E+bool This section details the methods available for interacting with a SimplePwmChannel, allowing fine-grained control over PWM output. ```APIDOC ## SimplePwmChannel ### Description A single channel of a PWM, obtained from `SimplePwm::split`, `SimplePwm::channel`, `SimplePwm::ch1`, etc. It is not possible to change the PWM frequency because the frequency configuration is shared with all four channels. ### Methods #### `enable(&mut self)` ##### Description Enable the given channel. ##### Method `enable` #### `disable(&mut self)` ##### Description Disable the given channel. ##### Method `disable` #### `is_enabled(&self) -> bool` ##### Description Check whether the given channel is enabled. ##### Method `is_enabled` #### `get_frequency(&self) -> Hertz` ##### Description Get the frequency of the PWM channel. ##### Method `get_frequency` #### `max_duty_cycle(&self) -> u32` ##### Description Get the maximum duty value. This value depends on the configured frequency and the timer’s clock rate from RCC. ##### Method `max_duty_cycle` #### `set_duty_cycle(&mut self, duty: u32)` ##### Description Set the duty for a given channel. The value ranges from 0 for 0% duty, to `max_duty_cycle` for 100% duty, both included. ##### Method `set_duty_cycle` #### `set_duty_cycle_fully_off(&mut self)` ##### Description Set the duty cycle to 0%, or always inactive. ##### Method `set_duty_cycle_fully_off` #### `set_duty_cycle_fully_on(&mut self)` ##### Description Set the duty cycle to 100%, or always active. ##### Method `set_duty_cycle_fully_on` #### `set_duty_cycle_fraction(&mut self, num: u32, denom: u32)` ##### Description Set the duty cycle to `num / denom`. The caller is responsible for ensuring that `num` is less than or equal to `denom`, and that `denom` is not zero. ##### Method `set_duty_cycle_fraction` #### `set_duty_cycle_percent(&mut self, percent: u8)` ##### Description Set the duty cycle to `percent / 100`. The caller is responsible for ensuring that `percent` is less than or equal to 100. ##### Method `set_duty_cycle_percent` #### `current_duty_cycle(&self) -> u16` ##### Description Get the duty for a given channel. The value ranges from 0 for 0% duty, to `max_duty_cycle` for 100% duty, both included. ##### Method `current_duty_cycle` #### `set_polarity(&mut self, polarity: OutputPolarity)` ##### Description Set the output polarity for a given channel. ##### Method `set_polarity` #### `set_output_compare_mode(&mut self, mode: OutputCompareMode)` ##### Description Set the output compare mode for a given channel. ##### Method `set_output_compare_mode` #### `into_ring_buffered_channel, D: UpDma>(self, tx_dma: Peri<'d, D>, dma_buf: &'d mut [W], irq: impl Binding> + 'd) -> RingBufferedPwmChannel<'d, T, W>` ##### Description Convert this PWM channel into a ring-buffered PWM channel. This allows continuous PWM waveform generation using a DMA ring buffer. The ring buffer enables dynamic updates to the PWM duty cycle without blocking. ##### Arguments * `tx_dma` - The DMA channel to use for transferring duty cycle values * `dma_buf` - The buffer to use as a ring buffer (must be non-empty and <= 65535 elements) ##### Panics Panics if `dma_buf` is empty or longer than 65535 elements. ##### Method `into_ring_buffered_channel` ``` -------------------------------- ### Implement CloneToUninit for T (Nightly) Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/enum.QeiMode.html?search=std%3A%3Avec An experimental, nightly-only blanket implementation of `CloneToUninit` for any type `T` that implements `Clone`. This unsafe function copies `self` to an uninitialized memory location. ```Rust unsafe impl CloneToUninit for T { unsafe fn clone_to_uninit(&self, dest: *mut u8) { // Implementation details } } ``` -------------------------------- ### PwmPin::new_with_config Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.PwmPin.html?search=u32+-%3E+bool Creates a new PWM pin instance with a specific configuration, allowing for more detailed control over PWM behavior. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/PwmPin/new_with_config ### Description Create a new PWM pin instance with a specific configuration. ### Method POST ### Endpoint `/websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/PwmPin/new_with_config` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **pin** (Peri<'d, impl TimerPin>) - Required - The pin to be wrapped for PWM output. - **pin_config** (PwmPinConfig) - Required - The configuration details for the PWM pin. ### Request Example ```json { "pin": "", "pin_config": { "frequency": 1000, "duty_cycle": 0.5 } } ``` ### Response #### Success Response (200) - **Self** (PwmPin<'d, T, C>) - A new PwmPin instance with the specified configuration. #### Response Example ```json { "pwm_pin_instance": "" } ``` ``` -------------------------------- ### Qei Driver Get Count Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/struct.Qei.html?search=u32+-%3E+bool Retrieves the current count value from the Qei driver. ```APIDOC ## GET /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/impl/count ### Description Gets the current count value. ### Method GET ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/impl/count ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **u16** (u16) - The current count value. #### Response Example ```json { "count": 1234 } ``` ``` -------------------------------- ### Get Timer Update DMA State Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the current enable/disable state of the update DMA functionality for the timer. ```rust pub fn get_update_dma_state(&self) -> bool ``` -------------------------------- ### QEI Driver Structure Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/index.html?search=u32+-%3E+bool Information about the Quadrature Decoder driver itself. ```APIDOC ## Struct: Qei ### Description Quadrature decoder driver. ### Fields * **(No specific fields documented in the provided text)** ### Example ```json { "example": "// Qei driver instance details would go here" } ``` ### Response #### Success Response (200) * **(No specific success response documented in the provided text)** #### Response Example ```json { "example": "// Success response details would go here" } ``` ``` -------------------------------- ### Create PwmPin Instance with OutputType in Rust Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.PwmPin.html Provides a constructor for PwmPin that takes a pin and an OutputType. This method initializes a PWM pin wrapper with a specified output configuration. ```rust pub fn new(pin: Peri<'d, impl TimerPin>, output_type: OutputType) -> Self ``` -------------------------------- ### RingBufferedPwmChannel Control Methods Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html?search=std%3A%3Avec Documentation for methods controlling the operation of the RingBufferedPwmChannel, including starting, stopping, pausing, and clearing the buffer. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/RingBufferedPwmChannel ### Description Methods for controlling the RingBufferedPwmChannel's DMA operation. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/RingBufferedPwmChannel ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **command** (string) - Required - The control command to execute (e.g., "start", "stop", "pause", "clear", "request_reset", "request_pause"). ### Request Example ```json { "command": "start" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### RingBufferedPwmChannel: Get Capacity Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html Returns the total capacity of the ring buffer. This indicates the maximum number of elements the buffer can hold. ```rust pub const fn capacity(&self) -> usize ``` -------------------------------- ### PwmPin::new_with_config Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.PwmPin.html Creates a new PWM pin instance with a specific configuration, allowing for more detailed control over PWM behavior. ```APIDOC ## POST /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/PwmPin::new_with_config ### Description Create a new PWM pin instance with a specific configuration. ### Method POST ### Endpoint /websites/embassy_dev_embassy-stm32_git_stm32c092kb_timer/PwmPin::new_with_config ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body - **pin** (Peri<'d, impl TimerPin>) - Required - The pin to be wrapped for PWM usage. - **pin_config** (PwmPinConfig) - Required - The specific configuration for the PWM pin. ``` -------------------------------- ### Get PWM Channel Frequency Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.SimplePwmChannel.html?search= Retrieves the current operating frequency of the PWM channel. The frequency is determined by the timer's configuration. ```rust pub fn get_frequency(&self) -> Hertz Get the frequency of the PWM channel. ``` -------------------------------- ### PWM Input Driver API Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/pwm_input/struct.PwmInput.html?search=u32+-%3E+bool This section details the methods available for the PwmInput driver, including initialization, control, and data retrieval. ```APIDOC ## PwmInput Driver API ### Description The `PwmInput` driver facilitates the measurement of pulse width and period using timer peripherals. It supports channels CH1 and CH2. Note that not all timer peripherals are supported; consult your chip's reference manual for compatibility. ### Methods #### `new_ch1` * **Description**: Creates a new PWM input driver instance for Channel 1. * **Parameters**: * `tim` (Peri<'d, T>): The timer peripheral instance. * `pin` (Peri<'d, impl TimerPin>): The timer pin for Channel 1. * `_irq` (impl Binding> + 'd): The interrupt binding for the timer. * `pull` (Pull): The pin pull configuration. * `freq` (Hertz): The desired frequency. * **Returns**: `Self` (a new `PwmInput` instance). #### `new_ch2` * **Description**: Creates a new PWM input driver instance for Channel 2. * **Parameters**: * `tim` (Peri<'d, T>): The timer peripheral instance. * `pin` (Peri<'d, impl TimerPin>): The timer pin for Channel 2. * `_irq` (impl Binding> + 'd): The interrupt binding for the timer. * `pull` (Pull): The pin pull configuration. * `freq` (Hertz): The desired frequency. * **Returns**: `Self` (a new `PwmInput` instance). #### `enable` * **Description**: Enables the configured PWM input channel. * **Method**: `&mut self` #### `disable` * **Description**: Disables the configured PWM input channel. * **Method**: `&mut self` #### `is_enabled` * **Description**: Checks if the PWM input channel is currently enabled. * **Method**: `&self` * **Returns**: `bool` - `true` if enabled, `false` otherwise. #### `get_period_ticks` * **Description**: Retrieves the measured period of the PWM signal in timer ticks. * **Method**: `&self` * **Returns**: `u32` - The period in timer ticks. #### `get_width_ticks` * **Description**: Retrieves the measured pulse width of the PWM signal in timer ticks. * **Method**: `&self` * **Returns**: `u32` - The pulse width in timer ticks. #### `get_duty_cycle` * **Description**: Calculates and returns the duty cycle of the PWM signal as a percentage (0.0 to 100.0). * **Method**: `&self` * **Returns**: `f32` - The duty cycle percentage. #### `wait_for_period` * **Description**: Asynchronously waits until a rising edge is detected on the input pin, indicating the start of a new period. * **Method**: `&self` * **Returns**: `u32` - The period measured in timer ticks. #### `wait_for_width` * **Description**: Asynchronously waits until a falling edge is detected on the input pin, indicating the end of the pulse. * **Method**: `&self` * **Returns**: `u32` - The pulse width measured in timer ticks. ``` -------------------------------- ### Get Counting Mode for STM32 Timer Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/low_level/struct.Timer.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Retrieves the current counting mode of the timer. This indicates how the timer is currently configured to count. ```rust pub fn get_counting_mode(&self) -> CountingMode ``` -------------------------------- ### Implement TryFrom for T Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/qei/enum.QeiMode.html?search=std%3A%3Avec A blanket implementation of `TryFrom` for `T` where `U` implements `Into`. This allows for fallible conversions from `U` to `T`, returning a `Result`. ```Rust impl TryFrom for T where U: Into, { type Error = Infallible; fn try_from(value: U) -> Result>::Error> { Ok(value.into()) } } ``` -------------------------------- ### RingBufferedPwmChannel: Get Current Length Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/ringbuffered/struct.RingBufferedPwmChannel.html Returns the current number of elements stored in the ring buffer. This indicates how much data is pending or has been written. ```rust pub fn len(&mut self) -> Result ``` -------------------------------- ### Initialize SimplePwm Driver Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/simple_pwm/struct.SimplePwm.html Creates a new SimplePwm driver instance. It requires a timer peripheral, optional PWM pins for up to four channels, the desired frequency, and the counting mode. ```rust pub fn new( tim: Peri<'d, T>, ch1: Option>, ch2: Option>, ch3: Option>, ch4: Option>, freq: Hertz, counting_mode: CountingMode, ) -> Self ``` -------------------------------- ### CoreInstance Implementations Source: https://docs.embassy.dev/embassy-stm32/git/stm32c092kb/timer/trait.CoreInstance.html Details the specific implementations of the CoreInstance trait for various timer peripherals. ```APIDOC ### `impl CoreInstance for TIM1` #### `type UpdateInterrupt = TIM1_BRK_UP_TRG_COM` #### `type Word = u16` ### `impl CoreInstance for TIM2` #### `type UpdateInterrupt = TIM2` #### `type Word = u32` ### `impl CoreInstance for TIM3` #### `type UpdateInterrupt = TIM3` #### `type Word = u16` ### `impl CoreInstance for TIM14` #### `type UpdateInterrupt = TIM14` #### `type Word = u16` ### `impl CoreInstance for TIM15` #### `type UpdateInterrupt = TIM15` #### `type Word = u16` ### `impl CoreInstance for TIM16` #### `type UpdateInterrupt = TIM16` #### `type Word = u16` ### `impl CoreInstance for TIM17` #### `type UpdateInterrupt = TIM17` #### `type Word = u16` ```