drv8833-driver 0.1.0

A driver for DRV8833 motor driver.
Documentation
  • Coverage
  • 77.27%
    17 out of 22 items documented0 out of 0 items with examples
  • Size
  • Source code size: 40.52 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 665.77 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • milewski/drv8833-driver
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • milewski

Rust Driver for DRV8833 Dual Bridge Motor Driver

Crate Documentation

Driver for the DRV8833 motor driver, supporting the operation of the motor in various modes. See the documentation for more details.

For detailed information on the DRV8833, refer to the datasheet.

Installation

You can install the package via Cargo:

cargo add drv8833-driver

Usage

Below is an example demonstrating how to use the driver with the esp-idf-hal crate:

use esp_idf_hal::gpio::{AnyInputPin, Input, PinDriver};
use esp_idf_hal::ledc::{LedcDriver, LedcTimerDriver};
use esp_idf_hal::ledc::config::TimerConfig;
use esp_idf_hal::prelude::Peripherals;

use drv8833_driver::{MotorDriver, PwmMovement};

fn main() -> anyhow::Result<()> {
    // Initialize peripherals
    let peripherals = Peripherals::take()?;

    // Initialize GPIO pins
    let in1 = PinDriver::output(peripherals.pins.gpio1)?;
    let in2 = PinDriver::output(peripherals.pins.gpio2)?;
    let in3 = PinDriver::output(peripherals.pins.gpio3)?;
    let in4 = PinDriver::output(peripherals.pins.gpio4)?;

    // Initialize LEDC timer and driver
    let timer = LedcTimerDriver::new(peripherals.ledc.timer0, &TimerConfig::default())?;
    let pwm = LedcDriver::new(peripherals.ledc.channel0, &timer, peripherals.pins.gpio5)?;

    // Initialize motor driver
    let motor = MotorDriver::new_pwm_parallel(
        in1, in2, in3, in4, pwm, None::<PinDriver<AnyInputPin, Input>>,
    );

    // Control the motor
    motor.forward(100)?;
    motor.reverse(100)?;
    motor.stop()?;
    motor.coast()?;

    Ok(())
}

License

The MIT License (MIT). Please see License File for more information.