dvcdbg 0.1.2

Lightweight logging and diagnostics toolkit for embedded (no_std, I2C scan, quick tests)
Documentation

šŸ› ļø 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

cargo add dvcdbg --features "macros"

šŸ“„ Usage Example (Arduino)

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() {
    // 
}


šŸ“š 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


šŸš€ 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.

# 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 for guidelines.


šŸ“„ License

MIT OR Apache-2.0