5 个不稳定版本

0.3.0 2024年2月18日
0.2.2 2024年2月11日
0.2.1 2024年2月7日
0.2.0 2024年2月7日
0.1.0 2024年2月4日

982嵌入式开发

MIT 许可证

27KB
504

用于模拟器件 AD57xx 系列双通道和四通道 16/14/12 位 DAC 的驱动程序

crates.io Docs

兼容性仅在 AD5754 上进行过测试。然而,不同芯片之间的唯一区别是通道数和位深。由于我的硬件不支持,读回操作尚未测试。如果您有机会进行测试,请告诉我您的发现。

欢迎对此 crate 的任何贡献,因为它是我第一个发布的 crate,任何反馈都受欢迎。

待办事项

  • 寄存器定义
  • 编写所有寄存器的功能
  • 在 stm32f4xx 上的共享总线上的最小工作示例
  • 双通道芯片支持(未测试)
  • #[tests] 在目标上
  • 测试读回功能
  • 专用设备结构
  • 支持菊花链操作
  • 异步支持

使用示例

// Setup the DAC's SPI bus and SYNC pin
let gpioc = p.GPIOC.split();
let spi3_sclk = gpioc.pc10.into_alternate();
let spi3_miso = gpioc.pc11.into_alternate();
let spi3_mosi = gpioc.pc12.into_alternate();
// We are using the ~SYNC pin as CS with ~LDAC tied to ground this puts
// the device in individual update mode, loading the dac register on each
// write operation
let gpioa = p.GPIOA.split();
let spi3_dac_sync = gpioa
    .pa15
    .into_push_pull_output_in_state(hal::gpio::PinState::High);
// SPI Instance initialization in MODE 2
let spi3 = Spi::new(
    p.SPI3,
    (spi3_sclk, spi3_miso, spi3_mosi),
    Mode {
            phase: hal::spi::Phase::CaptureOnFirstTransition,
            polarity: hal::spi::Polarity::IdleHigh,
    },
    1.MHz(),
    &ccdr,
);
// SPI Bus creation using embedded-hal-bus
let spi_bus = RefCell::new(spi3);

// Creating shared DAC SPI Device
let mut dac = Ad57xxShared::new_ad57x4(RefCellDevice::new(&spi_bus, spi3_dac_sync, NoDelay));

// Setup the DAC as desired.
dac.set_power(ad57xx::ad57x4::Channel::AllDacs, true).unwrap();
dac.set_output_range(ad57xx::ad57x4::Channel::AllDacs, ad57xx::OutputRange::Bipolar5V)
    .unwrap();
// Output a value (left-aligned 16 bit)
dac.set_dac_output(ad57xx::ad57x4::Channel::DacA, 0x9000).unwrap();

依赖项

~0.7–1.2MB
~26K SLoC