<div align="center">
<h1>dvcdbg</h1>
</div>
> š ļø Lightweight logging & debugging crate for embedded Rust (no_std friendly)
`dvcdbg` is a lightweight, `no_std`-friendly logging and debugging library for embedded Rust. It is designed to simplify the initial setup and bring-up of new hardware by providing a convenient set of diagnostic tools.
---
## ⨠Key Features
- ā
Works in `no_std` environments
- ā
Lightweight and fast, formatless logging support
- ā
Includes useful embedded utilities:
- I2C bus scanner (`scan_i2c!`)
- Hex dump (`write_hex!`)
- Execution cycle measurement (`measure_cycles!`)
- ā
Quick diagnostic workflow with `quick_diag!`
- ā
Serial logger abstraction for various HALs
- ā
Feature flags allow selective compilation:
- `logger` ā logging utilities
- `scanner` ā I2C scanning utilities
- `macros` ā helper macros (`impl_fmt_write_for_serial!`, `quick_diag!`, etc.)
---
## š¦ Quickstart
```sh
cargo add dvcdbg --features "macros"
```
---
## š Usage Example (Arduino)
- [Detailed settings](docs/USAGE.md)
```rust
use arduino_hal::default_serial;
use dvcdbg::prelude::*;
fn main() {
let dp = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(dp);
let mut serial = default_serial!(dp, pins, 57600);
let mut logger = SerialLogger::new(&mut serial);
#[cfg(feature = "macros")]
{
// Initialization I2C instance and timer
let i2c = arduino_hal::I2c::new(
dp.TWI,
pins.a4.into_pull_up_input(),
pins.a5.into_pull_up_input(),
100_000,
);
let timer = arduino_hal::hal::timer::Timer1::new(dp.TC1, arduino_hal::hal::clock::Clock::new());
// Quick diagnostic: scans I2C bus and measures cycles for test code
quick_diag!(logger, i2c, timer, {
your_test_code();
});
}
}
fn your_test_code() {
//
}
```
---
## Architecture

---
## š Macros Included
* `impl_fmt_write_for_serial!` ā implement `core::fmt::Write` for any serial type
* `write_hex!` ā print byte slices in hexadecimal format
* `measure_cycles!` ā measure execution cycles or timestamps
* `loop_with_delay!` ā loop with fixed delay for testing
* `assert_log!` ā log assertions without panicking
* `scan_i2c!` ā scan I²C bus for connected devices
* `quick_diag!` ā all-in-one diagnostic workflow
---
## š Documentation
* [API Documentation (docs.rs)](https://docs.rs/dvcdbg)
---
## š Binary Size Optimisation
Since `dvcdbg` is designed for a `no_std` environment, it is important to minimise the final binary size.
Enabling **LTO (link-time optimisation)** and **strip** during release builds will remove unused code from `dvcdbg` and other dependent crates, significantly reducing the binary size.
Add the following settings to your application's `Cargo.toml`.
```toml
# Cargo.toml (application)
[profile.release]
lto = true
strip = true
```
---
## š ļø Supported Environments
* Rust `no_std`
* AVR (Arduino Uno)
* ESP-IDF / other HALs supported via serial abstraction
---
## š¤ Contributing
Bug reports, feature suggestions, and pull requests are welcome!
See [CONTRIBUTING.md](docs/CONTRIBUTING.md) for guidelines.
---
## š License
[MIT](docs/LICENSE-MIT) OR [Apache-2.0](docs/LICENSE-APACHE)