Skip to main content

PwmDriver

Trait PwmDriver 

Source
pub trait PwmDriver<R: FlightFloat> {
    // Required methods
    fn len(&self) -> usize;
    fn is_enabled(&self) -> bool;
    fn enable(&mut self, channel: usize) -> Result<(), PwmError>;
    fn disable(&mut self, channel: usize) -> Result<(), PwmError>;
    fn enable_all(&mut self) -> Result<(), PwmError>;
    fn disable_all(&mut self);
    fn set_duty_cycle(
        &mut self,
        channel: usize,
        duty: u16,
    ) -> Result<(), PwmError>;
    fn flush<B: BoardIo>(&mut self, board: &mut B);
    fn send_commands<B: BoardIo>(
        &mut self,
        board: &mut B,
        commands: &[R],
    ) -> Result<(), PwmError>;

    // Provided methods
    fn configure_output_rates(
        &mut self,
        _rates_hz: &[R],
    ) -> Result<(), PwmError> { ... }
    fn output_protocol(
        &self,
        _channel: usize,
    ) -> Result<PwmOutputProtocol, PwmError> { ... }
    fn send_disarmed_commands<B: BoardIo>(
        &mut self,
        board: &mut B,
        output_types: &[MixerOutputType],
    ) -> Result<(), PwmError> { ... }
}

Required Methods§

Source

fn len(&self) -> usize

Source

fn is_enabled(&self) -> bool

Source

fn enable(&mut self, channel: usize) -> Result<(), PwmError>

Source

fn disable(&mut self, channel: usize) -> Result<(), PwmError>

Source

fn enable_all(&mut self) -> Result<(), PwmError>

Source

fn disable_all(&mut self)

Source

fn set_duty_cycle(&mut self, channel: usize, duty: u16) -> Result<(), PwmError>

Sets the duty cycle for a specific channel.

§Arguments
  • channel - The output channel index (0-based).
  • duty - The desired duty cycle, typically represented as a u16 value. The exact interpretation (e.g., 0-ARR, 0-u16::MAX) depends on the implementation. For simulation, we’ll map 0-u16::MAX to the simulator’s expected range (e.g., 1000-2000us).
Source

fn flush<B: BoardIo>(&mut self, board: &mut B)

Sends the current state of all PWM channels to the output/simulator. This should be called once per control loop after all individual set_duty_cycle calls for that loop iteration are complete.

§Arguments
  • now_us - The current flight controller time in microseconds for timestamping.
Source

fn send_commands<B: BoardIo>( &mut self, board: &mut B, commands: &[R], ) -> Result<(), PwmError>

Provided Methods§

Source

fn configure_output_rates(&mut self, _rates_hz: &[R]) -> Result<(), PwmError>

Configures default output update rates in Hz for mixer-owned channels.

Boards that cannot change rates at runtime may ignore this hook, but the core still propagates the mixer-owned rate resource explicitly.

Source

fn output_protocol( &self, _channel: usize, ) -> Result<PwmOutputProtocol, PwmError>

Source

fn send_disarmed_commands<B: BoardIo>( &mut self, board: &mut B, output_types: &[MixerOutputType], ) -> Result<(), PwmError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§