https://github.com/milewski/drv8833-driver
Rust Driver for DRV8833 Dual Bridge Motor Driver.
https://github.com/milewski/drv8833-driver
drv8833 embedded esp32 expressif-esp32 motor-driver
Last synced: about 1 year ago
JSON representation
Rust Driver for DRV8833 Dual Bridge Motor Driver.
- Host: GitHub
- URL: https://github.com/milewski/drv8833-driver
- Owner: milewski
- License: mit
- Created: 2024-04-01T10:12:02.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T06:11:12.000Z (about 2 years ago)
- Last Synced: 2025-04-10T04:02:44.722Z (about 1 year ago)
- Topics: drv8833, embedded, esp32, expressif-esp32, motor-driver
- Language: Rust
- Homepage:
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Rust Driver for DRV8833 Dual Bridge Motor Driver
[](https://github.com/milewski/drv8833-driver/actions/workflows/rust.yml)
[](https://crates.io/crates/drv8833-driver)
[](https://docs.rs/drv8833-driver)
Driver for the DRV8833 motor driver, supporting the operation of the motor in various modes.
See the [documentation](https://docs.rs/drv8833-driver) for more details.
For detailed information on the DRV8833, refer to the [datasheet](https://www.ti.com/lit/ds/symlink/drv8833.pdf).
# Installation
You can install the package via Cargo:
```sh
cargo add drv8833-driver
```
## Usage
Below is an example demonstrating how to use the driver with the [esp-idf-hal](https://crates.io/crates/esp-idf-hal) crate:
```rust
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::>,
);
// Control the motor
motor.forward(100)?;
motor.reverse(100)?;
motor.stop()?;
motor.coast()?;
Ok(())
}
```
## License
The MIT License (MIT). Please see [License File](./LICENSE) for more information.