Skip to content

Commit

Permalink
add initial driver implementation
Browse files Browse the repository at this point in the history
this contains some basic test coverage using `embedded-hal-mock` but
requires dbrgn/embedded-hal-mock#52 to support the `PwmPin` trait. for
the time being the PR branch is being used as a git dependency, this
should be changed back to a normal dependency once the PR has been
merged and a new release of `embedded-hal-mock` has been published.
  • Loading branch information
rursprung committed Dec 4, 2022
1 parent 777c417 commit a155b30
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 7 deletions.
10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ name = "tb6612fng"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
description = "A `no_std` driver for the TB6612FNG motor driver."
repository = "https://github.com/rursprung/tb6612fng-rs"
keywords = ["tb6612fng", "embedded", "driver", "no_std", "motor", "dc motor", "controller"]

[dependencies]
embedded-hal = "0.2"

defmt = { version = "0.3", optional = true }

[dev-dependencies]
embedded-hal-mock = { git = "https://github.com/rursprung/embedded-hal-mock.git", branch = "add-pwmpin-mock" }
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Rust Driver for TB6612FNG Motor Driver
This is a `no_std` driver for the [TB6612FNG motor driver](https://www.sparkfun.com/datasheets/Robotics/TB6612FNG.pdf) as can e.g. be found on the corresponding [SparkFun module](https://www.sparkfun.com/products/14450).

Note that this work is not affiliated with any of the vendors of the controller or controller boards.

The motor driver itself supports two motors and has a standby pin which controls both at the same time.
The crate can be either used to control a single motor (using the `Motor` struct directly) or
to control both motors (using the `Tb6612fng` struct) - the latter also supports using the standby functionality.

See the documentation for usage examples.

## When to use what
* You plan on using both motors and the standby feature: use `Tb6612fng`
* You plan on using both motors without the standby feature: use two separate `Motor`s
* You plan on using a single motor with the standby feature: use `Motor` and control the standby pin manually
* You plan on using a single motor without the standby feature: use `Motor`

## Optional features
* `defmt`: you can enable the [`defmt`](https://defmt.ferrous-systems.com/) feature to get a `defmt::debug!` call for every speed change.
Loading

0 comments on commit a155b30

Please sign in to comment.