rename ref_adc to dac_loopback
This commit is contained in:
parent
feae22b277
commit
a317eb60fd
@ -11,10 +11,12 @@ pub struct Channel1;
|
|||||||
|
|
||||||
pub struct Channel<C: ChannelPins> {
|
pub struct Channel<C: ChannelPins> {
|
||||||
pub state: ChannelState,
|
pub state: ChannelState,
|
||||||
|
/// for `i_set`
|
||||||
pub dac: ad5680::Dac<C::DacSpi, C::DacSync>,
|
pub dac: ad5680::Dac<C::DacSpi, C::DacSync>,
|
||||||
pub shdn: C::Shdn,
|
pub shdn: C::Shdn,
|
||||||
pub ref_adc: C::RefAdc,
|
/// feedback from `dac` output
|
||||||
pub ref_pin: C::RefPin,
|
pub dac_loopback: C::DacLoopback,
|
||||||
|
pub dac_loopback_pin: C::DacLoopbackPin,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: ChannelPins> Channel<C> {
|
impl<C: ChannelPins> Channel<C> {
|
||||||
@ -27,8 +29,8 @@ impl<C: ChannelPins> Channel<C> {
|
|||||||
state,
|
state,
|
||||||
dac,
|
dac,
|
||||||
shdn: pins.shdn,
|
shdn: pins.shdn,
|
||||||
ref_adc: pins.ref_adc,
|
dac_loopback: pins.dac_loopback,
|
||||||
ref_pin: pins.ref_pin,
|
dac_loopback_pin: pins.dac_loopback_pin,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,14 @@ impl Channels {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_ref_adc(&mut self, channel: usize) -> u16 {
|
pub fn read_dac_loopback(&mut self, channel: usize) -> u16 {
|
||||||
match channel {
|
match channel {
|
||||||
0 => self.channel0.ref_adc.convert(
|
0 => self.channel0.dac_loopback.convert(
|
||||||
&self.channel0.ref_pin,
|
&self.channel0.dac_loopback_pin,
|
||||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||||
),
|
),
|
||||||
1 => self.channel1.ref_adc.convert(
|
1 => self.channel1.dac_loopback.convert(
|
||||||
&self.channel1.ref_pin,
|
&self.channel1.dac_loopback_pin,
|
||||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||||
),
|
),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
@ -141,12 +141,12 @@ fn main() -> ! {
|
|||||||
Command::Show(ShowCommand::Input) => {
|
Command::Show(ShowCommand::Input) => {
|
||||||
for channel in 0..CHANNELS {
|
for channel in 0..CHANNELS {
|
||||||
if let Some(adc_data) = channels.channel_state(channel).adc_data {
|
if let Some(adc_data) = channels.channel_state(channel).adc_data {
|
||||||
let ref_adc_data = channels.read_ref_adc(channel);
|
let dac_loopback = channels.read_dac_loopback(channel);
|
||||||
let state = channels.channel_state(channel);
|
let state = channels.channel_state(channel);
|
||||||
let _ = writeln!(
|
let _ = writeln!(
|
||||||
socket, "t={} raw{}=0x{:06X} ref_adc=0x{:X}",
|
socket, "t={} raw{}=0x{:06X} dac_loopback=0x{:X}",
|
||||||
state.adc_time, channel, adc_data,
|
state.adc_time, channel, adc_data,
|
||||||
ref_adc_data
|
dac_loopback
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
36
src/pins.rs
36
src/pins.rs
@ -26,24 +26,24 @@ pub trait ChannelPins {
|
|||||||
type DacSpi: Transfer<u8>;
|
type DacSpi: Transfer<u8>;
|
||||||
type DacSync: OutputPin;
|
type DacSync: OutputPin;
|
||||||
type Shdn: OutputPin;
|
type Shdn: OutputPin;
|
||||||
type RefAdc;
|
type DacLoopback;
|
||||||
type RefPin;
|
type DacLoopbackPin;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelPins for Channel0 {
|
impl ChannelPins for Channel0 {
|
||||||
type DacSpi = Dac0Spi;
|
type DacSpi = Dac0Spi;
|
||||||
type DacSync = PE4<Output<PushPull>>;
|
type DacSync = PE4<Output<PushPull>>;
|
||||||
type Shdn = PE10<Output<PushPull>>;
|
type Shdn = PE10<Output<PushPull>>;
|
||||||
type RefAdc = Adc<ADC1>;
|
type DacLoopback = Adc<ADC1>;
|
||||||
type RefPin = PA4<Analog>;
|
type DacLoopbackPin = PA4<Analog>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChannelPins for Channel1 {
|
impl ChannelPins for Channel1 {
|
||||||
type DacSpi = Dac1Spi;
|
type DacSpi = Dac1Spi;
|
||||||
type DacSync = PF6<Output<PushPull>>;
|
type DacSync = PF6<Output<PushPull>>;
|
||||||
type Shdn = PE15<Output<PushPull>>;
|
type Shdn = PE15<Output<PushPull>>;
|
||||||
type RefAdc = Adc<ADC2>;
|
type DacLoopback = Adc<ADC2>;
|
||||||
type RefPin = PA5<Analog>;
|
type DacLoopbackPin = PA5<Analog>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// SPI peripheral used for communication with the ADC
|
/// SPI peripheral used for communication with the ADC
|
||||||
@ -57,8 +57,8 @@ pub struct ChannelPinSet<C: ChannelPins> {
|
|||||||
pub dac_spi: C::DacSpi,
|
pub dac_spi: C::DacSpi,
|
||||||
pub dac_sync: C::DacSync,
|
pub dac_sync: C::DacSync,
|
||||||
pub shdn: C::Shdn,
|
pub shdn: C::Shdn,
|
||||||
pub ref_adc: C::RefAdc,
|
pub dac_loopback: C::DacLoopback,
|
||||||
pub ref_pin: C::RefPin,
|
pub dac_loopback_pin: C::DacLoopbackPin,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Pins {
|
pub struct Pins {
|
||||||
@ -106,15 +106,15 @@ impl Pins {
|
|||||||
);
|
);
|
||||||
let mut shdn0 = gpioe.pe10.into_push_pull_output();
|
let mut shdn0 = gpioe.pe10.into_push_pull_output();
|
||||||
let _ = shdn0.set_low();
|
let _ = shdn0.set_low();
|
||||||
let mut ref0_adc = Adc::adc1(adc1, true, Default::default());
|
let mut dac_loopback0 = Adc::adc1(adc1, true, Default::default());
|
||||||
ref0_adc.enable();
|
dac_loopback0.enable();
|
||||||
let ref0_pin = gpioa.pa4.into_analog();
|
let dac_loopback0_pin = gpioa.pa4.into_analog();
|
||||||
let channel0 = ChannelPinSet {
|
let channel0 = ChannelPinSet {
|
||||||
dac_spi: dac0_spi,
|
dac_spi: dac0_spi,
|
||||||
dac_sync: dac0_sync,
|
dac_sync: dac0_sync,
|
||||||
shdn: shdn0,
|
shdn: shdn0,
|
||||||
ref_adc: ref0_adc,
|
dac_loopback: dac_loopback0,
|
||||||
ref_pin: ref0_pin,
|
dac_loopback_pin: dac_loopback0_pin,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (dac1_spi, dac1_sync) = Self::setup_dac1(
|
let (dac1_spi, dac1_sync) = Self::setup_dac1(
|
||||||
@ -123,15 +123,15 @@ impl Pins {
|
|||||||
);
|
);
|
||||||
let mut shdn1 = gpioe.pe15.into_push_pull_output();
|
let mut shdn1 = gpioe.pe15.into_push_pull_output();
|
||||||
let _ = shdn1.set_low();
|
let _ = shdn1.set_low();
|
||||||
let mut ref1_adc = Adc::adc2(adc2, true, Default::default());
|
let mut dac_loopback1 = Adc::adc2(adc2, true, Default::default());
|
||||||
ref1_adc.enable();
|
dac_loopback1.enable();
|
||||||
let ref1_pin = gpioa.pa5.into_analog();
|
let dac_loopback1_pin = gpioa.pa5.into_analog();
|
||||||
let channel1 = ChannelPinSet {
|
let channel1 = ChannelPinSet {
|
||||||
dac_spi: dac1_spi,
|
dac_spi: dac1_spi,
|
||||||
dac_sync: dac1_sync,
|
dac_sync: dac1_sync,
|
||||||
shdn: shdn1,
|
shdn: shdn1,
|
||||||
ref_adc: ref1_adc,
|
dac_loopback: dac_loopback1,
|
||||||
ref_pin: ref1_pin,
|
dac_loopback_pin: dac_loopback1_pin,
|
||||||
};
|
};
|
||||||
|
|
||||||
Pins {
|
Pins {
|
||||||
|
Loading…
Reference in New Issue
Block a user