# _embedded_hal_PwmPin in k210_hal::prelude - Rust
A single PWM channel / pin
Keywords: rust, rustlang, rust-lang, _embedded_hal_PwmPin

# Trait k210_hal::prelude::_embedded_hal_PwmPin

source · [−]

    pub trait _embedded_hal_PwmPin {
        type Error;
        type Duty;
        fn try_disable(&mut self) -> Result<(), Self::Error>;
        fn try_enable(&mut self) -> Result<(), Self::Error>;
        fn try_get_duty(&self) -> Result<Self::Duty, Self::Error>;
        fn try_get_max_duty(&self) -> Result<Self::Duty, Self::Error>;
        fn try_set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>;
    }

Expand description

A single PWM channel / pin

See `Pwm` for details

## Associated Types

source

#### type Error

Enumeration of `PwmPin` errors

source

#### type Duty

Type for the `duty` methods

The implementer is free to choose a float / percentage representation (e.g. `0.0 .. 1.0`) or an integer representation (e.g. `0 .. 65535`)

## Required methods

source

#### fn try_disable(&mut self) -> Result<(), Self::Error>

Disables a PWM `channel`

source

#### fn try_enable(&mut self) -> Result<(), Self::Error>

Enables a PWM `channel`

source

#### fn try_get_duty(&self) -> Result<Self::Duty, Self::Error>

Returns the current duty cycle

source

#### fn try_get_max_duty(&self) -> Result<Self::Duty, Self::Error>

Returns the maximum duty cycle value

source

#### fn try_set_duty(&mut self, duty: Self::Duty) -> Result<(), Self::Error>

Sets a new duty cycle

## Implementors