Crate dshot_frame

Crate dshot_frame 

Source
Expand description

Support for the DShot ESC protocol

DShot has two-byte frames, where the first 11 bits are the throttle speed, bit 12 is a telemetry request flag, and the last four bits are a checksum.

Throttle values below 48 are reserved for special commands.

It is transmitted over the wire at a fixed speed, with ones and zeroes both being pulses, but ones being twice as long as zeroes.

§Usage

This example is adapted from an embassy-stm32 codebase:

let mut pwm = SimplePwm::new(
    timer,
    Some(PwmPin::new_ch1(pin, OutputType::PushPull)),
    None,
    None,
    None,
    Hertz(150_000),
    CountingMode::EdgeAlignedUp,
);
let max_duty_cycle = pwm.get_max_duty() as u16;

let frame = Frame::<NormalDshot>::new(1000, false).unwrap();
pwm.waveform_up(&mut dma, Ch1, &frame.duty_cycles()).await;
// Pull the line low after sending a frame.
pwm.set_duty(channel, 0);
pwm.enable(channel);

Structs§

BidirectionalDshot
Bidirectional (inverted) DShot protocol.
ErpmTelemetry
eRPM telemetry frame as sent by ESC in bidirectional DShot mode.
Frame
A DShot frame parameterized by its protocol variant.
NormalDshot
Standard (non-inverted) DShot protocol.

Enums§

Command
Fixed commands that occupy the lower 48 speed values.

Traits§

DshotProtocol
Defines the behavior of a DShot protocol variant.

Type Aliases§

BidirectionalFrame
NormalFrame