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 state: ChannelState,
|
||||
/// for `i_set`
|
||||
pub dac: ad5680::Dac<C::DacSpi, C::DacSync>,
|
||||
pub shdn: C::Shdn,
|
||||
pub ref_adc: C::RefAdc,
|
||||
pub ref_pin: C::RefPin,
|
||||
/// feedback from `dac` output
|
||||
pub dac_loopback: C::DacLoopback,
|
||||
pub dac_loopback_pin: C::DacLoopbackPin,
|
||||
}
|
||||
|
||||
impl<C: ChannelPins> Channel<C> {
|
||||
|
@ -27,8 +29,8 @@ impl<C: ChannelPins> Channel<C> {
|
|||
state,
|
||||
dac,
|
||||
shdn: pins.shdn,
|
||||
ref_adc: pins.ref_adc,
|
||||
ref_pin: pins.ref_pin,
|
||||
dac_loopback: pins.dac_loopback,
|
||||
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 {
|
||||
0 => self.channel0.ref_adc.convert(
|
||||
&self.channel0.ref_pin,
|
||||
0 => self.channel0.dac_loopback.convert(
|
||||
&self.channel0.dac_loopback_pin,
|
||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||
),
|
||||
1 => self.channel1.ref_adc.convert(
|
||||
&self.channel1.ref_pin,
|
||||
1 => self.channel1.dac_loopback.convert(
|
||||
&self.channel1.dac_loopback_pin,
|
||||
stm32f4xx_hal::adc::config::SampleTime::Cycles_480
|
||||
),
|
||||
_ => unreachable!(),
|
||||
|
|
|
@ -141,12 +141,12 @@ fn main() -> ! {
|
|||
Command::Show(ShowCommand::Input) => {
|
||||
for channel in 0..CHANNELS {
|
||||
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 _ = 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,
|
||||
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 DacSync: OutputPin;
|
||||
type Shdn: OutputPin;
|
||||
type RefAdc;
|
||||
type RefPin;
|
||||
type DacLoopback;
|
||||
type DacLoopbackPin;
|
||||
}
|
||||
|
||||
impl ChannelPins for Channel0 {
|
||||
type DacSpi = Dac0Spi;
|
||||
type DacSync = PE4<Output<PushPull>>;
|
||||
type Shdn = PE10<Output<PushPull>>;
|
||||
type RefAdc = Adc<ADC1>;
|
||||
type RefPin = PA4<Analog>;
|
||||
type DacLoopback = Adc<ADC1>;
|
||||
type DacLoopbackPin = PA4<Analog>;
|
||||
}
|
||||
|
||||
impl ChannelPins for Channel1 {
|
||||
type DacSpi = Dac1Spi;
|
||||
type DacSync = PF6<Output<PushPull>>;
|
||||
type Shdn = PE15<Output<PushPull>>;
|
||||
type RefAdc = Adc<ADC2>;
|
||||
type RefPin = PA5<Analog>;
|
||||
type DacLoopback = Adc<ADC2>;
|
||||
type DacLoopbackPin = PA5<Analog>;
|
||||
}
|
||||
|
||||
/// SPI peripheral used for communication with the ADC
|
||||
|
@ -57,8 +57,8 @@ pub struct ChannelPinSet<C: ChannelPins> {
|
|||
pub dac_spi: C::DacSpi,
|
||||
pub dac_sync: C::DacSync,
|
||||
pub shdn: C::Shdn,
|
||||
pub ref_adc: C::RefAdc,
|
||||
pub ref_pin: C::RefPin,
|
||||
pub dac_loopback: C::DacLoopback,
|
||||
pub dac_loopback_pin: C::DacLoopbackPin,
|
||||
}
|
||||
|
||||
pub struct Pins {
|
||||
|
@ -106,15 +106,15 @@ impl Pins {
|
|||
);
|
||||
let mut shdn0 = gpioe.pe10.into_push_pull_output();
|
||||
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 mut dac_loopback0 = Adc::adc1(adc1, true, Default::default());
|
||||
dac_loopback0.enable();
|
||||
let dac_loopback0_pin = gpioa.pa4.into_analog();
|
||||
let channel0 = ChannelPinSet {
|
||||
dac_spi: dac0_spi,
|
||||
dac_sync: dac0_sync,
|
||||
shdn: shdn0,
|
||||
ref_adc: ref0_adc,
|
||||
ref_pin: ref0_pin,
|
||||
dac_loopback: dac_loopback0,
|
||||
dac_loopback_pin: dac_loopback0_pin,
|
||||
};
|
||||
|
||||
let (dac1_spi, dac1_sync) = Self::setup_dac1(
|
||||
|
@ -123,15 +123,15 @@ impl Pins {
|
|||
);
|
||||
let mut shdn1 = gpioe.pe15.into_push_pull_output();
|
||||
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 mut dac_loopback1 = Adc::adc2(adc2, true, Default::default());
|
||||
dac_loopback1.enable();
|
||||
let dac_loopback1_pin = gpioa.pa5.into_analog();
|
||||
let channel1 = ChannelPinSet {
|
||||
dac_spi: dac1_spi,
|
||||
dac_sync: dac1_sync,
|
||||
shdn: shdn1,
|
||||
ref_adc: ref1_adc,
|
||||
ref_pin: ref1_pin,
|
||||
dac_loopback: dac_loopback1,
|
||||
dac_loopback_pin: dac_loopback1_pin,
|
||||
};
|
||||
|
||||
Pins {
|
||||
|
|
Loading…
Reference in New Issue