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§
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)
Sourcefn set_duty_cycle(&mut self, channel: usize, duty: u16) -> Result<(), PwmError>
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).
Sourcefn flush<B: BoardIo>(&mut self, board: &mut B)
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.
fn send_commands<B: BoardIo>( &mut self, board: &mut B, commands: &[R], ) -> Result<(), PwmError>
Provided Methods§
Sourcefn configure_output_rates(&mut self, _rates_hz: &[R]) -> Result<(), PwmError>
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.
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>
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.