#led-driver #led #driver #embedded-hal #embedded-hal-driver #lumissil

已删除 is31fl3205

Lumissil Microsystems IS31FL3205 LED 驱动程序的 rust-embedded 驱动

1 个不稳定版本

0.0.1 2022年7月8日

#8 in #lumissil

MIT 许可证

16KB
188 代码行

is31fl3205

Lumissil Microsystems IS31FL3205 LED 驱动程序的 rust-embedded 驱动

描述

IS31FL3205 是一个具有 12 个恒定电流通道的 LED 驱动器。每个通道可以通过 16 位进行脉冲宽度调制 (PWM),以实现平滑的 LED 亮度控制。此外,每个通道都有一个 8 位输出电流控制寄存器,允许微调电流以进行丰富的 RGB 颜色混合,例如,纯白色 LED 应用。每个通道的最大输出电流可以通过一个 8 位全局控制寄存器进行调整。

IS31FL3205 使用专有可编程算法来最小化由 MLCC 解耦电容器引起的可听噪声。所有寄存器都可以通过高速 I2C(1MHz)进行编程。IS31FL3205 可以通过拉低 SDB 引脚或使用软件关断功能以最小电流消耗来关闭。IS31FL3205 提供 QFN-20(3mm × 3mm)封装。它可在 -40°C 至 +125°C 的温度范围内从 2.7V 至 5.5V 之间工作。

示例

示例基于 stm32h7xx_hal

// Initialize a delay provider
let mut delay: Delay = Delay::new(cp.SYST, ccdr.clocks);

// Initialize I2C pins, SCL, SDA
let scl = scl
    .into_alternate_af4()
    .internal_pull_up(true)
    .set_open_drain();
let sda = sda
    .into_alternate_af4()
    .internal_pull_up(true)
    .set_open_drain();

// Initialize the Enable line
let en = en.into_push_pull_output();

// Initialize 
let i2c: stm32h7xx_hal::i2c::I2c<I2C1> =
    i2c.i2c((scl, sda), 1.MHz(), prec, clocks);

// Initialize with blocking I2C for device at address 0x00
let mut interface = Is31fl3205::init_with_i2c(0x00, i2c, en);

// Enable the device, bringing the enable line high and configuring
// the oscillator clock, pwm resolution
interface.enable_device(
    delay,
    OscillatorClock::SixteenMHz,
    PwmResolution::SixteenBit,
    SoftwareShutdownMode::Normal,
)
.unwrap();

// Set maximum current drain as specified by the current resistance
interface.set_global_current(0xFF).unwrap();

// Set brightness scaling for all leds
interface.set_all_led_scaling(0xFF).unwrap();

/// Finally set the first LED to maximum 16bit brightness. For drivers configured for less than 16bit
/// Only the required bits are used
interface.set(0, 0xFFFF);

// Release the blocking i2c example to regain access to its underlying resources
let (_i2c, en) = color_controller.release();

// Additionally, if you need to integrate this driver with platform specific DMA controllers then
// a flexible callback can be used rather than blocking i2c
static mut DMA_BUFFER: [u8; 3] = [0; 3];
let interface = Is31fl3205::init_with_callback(0x00, en, |addr, data| unsafe {
    // Copy the data from the Is31fl3205 into the DMA buffer for processing
    // NOTE: data can change in size depending on the message, the DMA implementation will
    // need to be able to handle changing slice lengths
    DMA_BUFFER[0..data.len()].copy_from_slice(data);
});

贡献

请随意创建一个工单和一个 MR,以提出您希望在此库中看到的任何更改。

依赖项

~71KB