Git Product home page Git Product logo

drv8833-driver's Introduction

Rust Driver for DRV8833 Dual Bridge Motor Driver

Build 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.

drv8833-driver's People

Contributors

milewski avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.