ad5680: idle low for powersaving
This commit is contained in:
parent
c53c9a289f
commit
feae22b277
@ -25,7 +25,7 @@ pub struct Dac<SPI: Transfer<u8>, S: OutputPin> {
|
||||
|
||||
impl<SPI: Transfer<u8>, S: OutputPin> Dac<SPI, S> {
|
||||
pub fn new(spi: SPI, mut sync: S) -> Self {
|
||||
let _ = sync.set_high();
|
||||
let _ = sync.set_low();
|
||||
|
||||
Dac {
|
||||
spi,
|
||||
@ -34,11 +34,14 @@ impl<SPI: Transfer<u8>, S: OutputPin> Dac<SPI, S> {
|
||||
}
|
||||
|
||||
fn write(&mut self, mut buf: [u8; 3]) -> Result<(), SPI::Error> {
|
||||
let _ = self.sync.set_low();
|
||||
let result = self.spi.transfer(&mut buf);
|
||||
// pulse sync to start a new transfer. leave sync idle low
|
||||
// afterwards to save power as recommended per datasheet.
|
||||
let _ = self.sync.set_high();
|
||||
cortex_m::asm::nop();
|
||||
let _ = self.sync.set_low();
|
||||
|
||||
result.map(|_| ())
|
||||
self.spi.transfer(&mut buf)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// value: `0..0x20_000`
|
||||
|
@ -144,7 +144,7 @@ fn main() -> ! {
|
||||
let ref_adc_data = channels.read_ref_adc(channel);
|
||||
let state = channels.channel_state(channel);
|
||||
let _ = writeln!(
|
||||
socket, "t={} raw{}=0x{:06X} ref_adc={}",
|
||||
socket, "t={} raw{}=0x{:06X} ref_adc=0x{:X}",
|
||||
state.adc_time, channel, adc_data,
|
||||
ref_adc_data
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user