lm3630a 0.1.1

embedded-hal driver for LM3630A LED driver
Documentation
  • Coverage
  • 15.87%
    30 out of 189 items documented0 out of 92 items with examples
  • Size
  • Source code size: 45.82 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.69 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • nakajima

lm3630a

Barebones Rust driver for the TI LM3630A dual-string white LED backlight driver.

  • no_std
  • embedded-hal 1.0 I2C
  • Optional embedded-hal-async 1.0 I2C support via the async feature
  • Supports SEL-selected 7-bit I2C addresses 0x36 and 0x38
  • Typed helpers for brightness, current, boost, ramps, PWM, interrupts, and faults

Status

Early driver. Register coverage is implemented, but it has not yet been validated on hardware.

Usage

use lm3630a::{
    Address, Bank, Brightness, Configuration, ControlConfig, FullScaleCurrent, Lm3630a,
    Mapping,
};

let i2c = /* platform I2C */;
let mut delay = /* platform delay */;

let mut backlight = Lm3630a::new(i2c, Address::SelLow);

// Wait at least 1 ms after HWEN is asserted.
backlight.wait_until_ready(&mut delay);

backlight.set_configuration(Configuration::default())?;
backlight.set_full_scale_current(Bank::A, FullScaleCurrent::from_code(20).unwrap())?;
backlight.set_brightness(Bank::A, Brightness::from_raw(128))?;

backlight.set_control(ControlConfig {
    sleep: false,
    bank_a_mapping: Mapping::Linear,
    bank_b_mapping: Mapping::Linear,
    bank_a_enabled: true,
    bank_b_enabled: false,
    led2_bank: Default::default(),
})?;

Async support

Enable the optional async API with:

lm3630a = { version = "0.1", features = ["async"] }

Async methods are available on the same driver type with an _async suffix, for example:

backlight.wait_until_ready_async(&mut delay).await;
backlight.set_brightness_async(Bank::A, Brightness::from_raw(128)).await?;

Notes

  • Address::SelLow is 0x36 when SEL is tied to GND.
  • Address::SelHigh is 0x38 when SEL is tied to VIN.
  • The datasheet requires a 1 ms wait after HWEN assertion or software reset before I2C access.
  • Reading interrupt status clears the device interrupt status register.
  • Brightness registers are not updated by the device while it is in sleep mode.