Compare commits
No commits in common. "feae22b277e62fdeae54aa1f42206e86e2a44c9e" and "53930497e4a9523ac877538346472d9799fc2ca6" have entirely different histories.
feae22b277
...
53930497e4
|
@ -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_low();
|
||||
let _ = sync.set_high();
|
||||
|
||||
Dac {
|
||||
spi,
|
||||
|
@ -34,14 +34,11 @@ impl<SPI: Transfer<u8>, S: OutputPin> Dac<SPI, S> {
|
|||
}
|
||||
|
||||
fn write(&mut self, mut buf: [u8; 3]) -> Result<(), SPI::Error> {
|
||||
// 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();
|
||||
let result = self.spi.transfer(&mut buf);
|
||||
let _ = self.sync.set_high();
|
||||
|
||||
self.spi.transfer(&mut buf)?;
|
||||
Ok(())
|
||||
result.map(|_| ())
|
||||
}
|
||||
|
||||
/// 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=0x{:X}",
|
||||
socket, "t={} raw{}=0x{:06X} ref_adc={}",
|
||||
state.adc_time, channel, adc_data,
|
||||
ref_adc_data
|
||||
);
|
||||
|
|
|
@ -35,7 +35,7 @@ impl ChannelPins for Channel0 {
|
|||
type DacSync = PE4<Output<PushPull>>;
|
||||
type Shdn = PE10<Output<PushPull>>;
|
||||
type RefAdc = Adc<ADC1>;
|
||||
type RefPin = PA4<Analog>;
|
||||
type RefPin = PA0<Analog>;
|
||||
}
|
||||
|
||||
impl ChannelPins for Channel1 {
|
||||
|
@ -43,7 +43,7 @@ impl ChannelPins for Channel1 {
|
|||
type DacSync = PF6<Output<PushPull>>;
|
||||
type Shdn = PE15<Output<PushPull>>;
|
||||
type RefAdc = Adc<ADC2>;
|
||||
type RefPin = PA5<Analog>;
|
||||
type RefPin = PA3<Analog>;
|
||||
}
|
||||
|
||||
/// SPI peripheral used for communication with the ADC
|
||||
|
@ -108,7 +108,7 @@ impl Pins {
|
|||
let _ = shdn0.set_low();
|
||||
let mut ref0_adc = Adc::adc1(adc1, true, Default::default());
|
||||
ref0_adc.enable();
|
||||
let ref0_pin = gpioa.pa4.into_analog();
|
||||
let ref0_pin = gpioa.pa0.into_analog();
|
||||
let channel0 = ChannelPinSet {
|
||||
dac_spi: dac0_spi,
|
||||
dac_sync: dac0_sync,
|
||||
|
@ -125,7 +125,7 @@ impl Pins {
|
|||
let _ = shdn1.set_low();
|
||||
let mut ref1_adc = Adc::adc2(adc2, true, Default::default());
|
||||
ref1_adc.enable();
|
||||
let ref1_pin = gpioa.pa5.into_analog();
|
||||
let ref1_pin = gpioa.pa3.into_analog();
|
||||
let channel1 = ChannelPinSet {
|
||||
dac_spi: dac1_spi,
|
||||
dac_sync: dac1_sync,
|
||||
|
|
Loading…
Reference in New Issue