Renaming variables, fixing pounder builds
This commit is contained in:
parent
c4c3593bae
commit
9d3513d4d1
@ -259,7 +259,7 @@ macro_rules! adc_input {
|
||||
clear_stream: hal::dma::dma::$clear_stream<hal::stm32::DMA1>,
|
||||
trigger_channel: timers::tim2::$trigger_channel,
|
||||
clear_channel: timers::tim3::$clear_channel,
|
||||
sample_buffer_size: usize,
|
||||
batch_size: usize,
|
||||
) -> Self {
|
||||
// The flag clear DMA transfer always clears the EOT flag in the SPI
|
||||
// peripheral. It has the highest priority to ensure it is completed before the
|
||||
@ -359,8 +359,8 @@ macro_rules! adc_input {
|
||||
spi,
|
||||
// Note(unsafe): The ADC_BUF[$index] is "owned" by this peripheral.
|
||||
// It shall not be used anywhere else in the module.
|
||||
unsafe { &mut ADC_BUF[$index][0][..sample_buffer_size] },
|
||||
unsafe { Some(&mut ADC_BUF[$index][1][..sample_buffer_size]) },
|
||||
unsafe { &mut ADC_BUF[$index][0][..batch_size] },
|
||||
unsafe { Some(&mut ADC_BUF[$index][1][..batch_size]) },
|
||||
data_config,
|
||||
);
|
||||
|
||||
|
@ -193,7 +193,7 @@ macro_rules! dac_output {
|
||||
spi: hal::spi::Spi<hal::stm32::$spi, hal::spi::Enabled, u16>,
|
||||
stream: hal::dma::dma::$data_stream<hal::stm32::DMA1>,
|
||||
trigger_channel: timers::tim2::$trigger_channel,
|
||||
sample_buffer_size: usize,
|
||||
batch_size: usize,
|
||||
) -> Self {
|
||||
// Generate DMA events when an output compare of the timer hitting zero (timer roll over)
|
||||
// occurs.
|
||||
@ -227,13 +227,9 @@ macro_rules! dac_output {
|
||||
stream,
|
||||
$spi::new(trigger_channel, spi),
|
||||
// Note(unsafe): This buffer is only used once and provided for the DMA transfer.
|
||||
unsafe {
|
||||
&mut DAC_BUF[$index][0][..sample_buffer_size]
|
||||
},
|
||||
unsafe { &mut DAC_BUF[$index][0][..batch_size] },
|
||||
// Note(unsafe): This buffer is only used once and provided for the DMA transfer.
|
||||
unsafe {
|
||||
Some(&mut DAC_BUF[$index][1][..sample_buffer_size])
|
||||
},
|
||||
unsafe { Some(&mut DAC_BUF[$index][1][..batch_size]) },
|
||||
trigger_config,
|
||||
);
|
||||
|
||||
|
@ -16,8 +16,7 @@
|
||||
///! capture is simultaneously triggered. That trigger is prescaled (its rate is divided) by the
|
||||
///! batch size. This results in the input capture triggering identically to when the ADC samples
|
||||
///! the last sample of the batch. That sample is then available for processing by the user.
|
||||
use crate::{configuration, hardware::timers};
|
||||
use core::convert::TryFrom;
|
||||
use crate::hardware::timers;
|
||||
use stm32h7xx_hal as hal;
|
||||
|
||||
/// Software unit to timestamp stabilizer ADC samples using an external pounder reference clock.
|
||||
@ -34,6 +33,7 @@ impl Timestamper {
|
||||
/// * `capture_channel` - The input capture channel for collecting timestamps.
|
||||
/// * `sampling_timer` - The stabilizer ADC sampling timer.
|
||||
/// * `_clock_input` - The input pin for the external clock from Pounder.
|
||||
/// * `batch_size` - The number of seamples in each batch.
|
||||
///
|
||||
/// # Returns
|
||||
/// The new pounder timestamper in an operational state.
|
||||
@ -44,6 +44,7 @@ impl Timestamper {
|
||||
_clock_input: hal::gpio::gpioa::PA0<
|
||||
hal::gpio::Alternate<hal::gpio::AF3>,
|
||||
>,
|
||||
batch_size: usize,
|
||||
) -> Self {
|
||||
// The sampling timer should generate a trigger output when CH1 comparison occurs.
|
||||
sampling_timer.generate_trigger(timers::TriggerGenerator::ComparePulse);
|
||||
@ -56,11 +57,16 @@ impl Timestamper {
|
||||
let mut input_capture = capture_channel
|
||||
.into_input_capture(timers::tim8::CaptureSource1::TRC);
|
||||
|
||||
let prescaler = match batch_size {
|
||||
1 => timers::Prescaler::Div1,
|
||||
2 => timers::Prescaler::Div2,
|
||||
4 => timers::Prescaler::Div4,
|
||||
8 => timers::Prescaler::Div8,
|
||||
_ => panic!("Batch size does not support DDS timestamping"),
|
||||
};
|
||||
|
||||
// Capture at the batch period.
|
||||
input_capture.configure_prescaler(
|
||||
timers::Prescaler::try_from(configuration::SAMPLE_BUFFER_SIZE_LOG2)
|
||||
.unwrap(),
|
||||
);
|
||||
input_capture.configure_prescaler(prescaler);
|
||||
|
||||
Self {
|
||||
timer: timestamp_timer,
|
||||
|
@ -178,7 +178,7 @@ fn load_itcm() {
|
||||
/// # Args
|
||||
/// * `core` - The RTIC core for configuring the cortex-M core of the device.
|
||||
/// * `device` - The microcontroller peripherals to be configured.
|
||||
/// * `sample_buffer_size` - The size of the ADC/DAC sample buffer.
|
||||
/// * `batch_size` - The size of each ADC/DAC batch.
|
||||
/// * `sample_ticks` - The number of timer ticks between each sample.
|
||||
///
|
||||
/// # Returns
|
||||
@ -189,7 +189,7 @@ fn load_itcm() {
|
||||
pub fn setup(
|
||||
mut core: rtic::Peripherals,
|
||||
device: stm32h7xx_hal::stm32::Peripherals,
|
||||
sample_buffer_size: usize,
|
||||
batch_size: usize,
|
||||
sample_ticks: u32,
|
||||
) -> (StabilizerDevices, Option<PounderDevices>) {
|
||||
let pwr = device.PWR.constrain();
|
||||
@ -414,7 +414,7 @@ pub fn setup(
|
||||
dma_streams.2,
|
||||
sampling_timer_channels.ch1,
|
||||
shadow_sampling_timer_channels.ch1,
|
||||
sample_buffer_size,
|
||||
batch_size,
|
||||
)
|
||||
};
|
||||
|
||||
@ -458,7 +458,7 @@ pub fn setup(
|
||||
dma_streams.5,
|
||||
sampling_timer_channels.ch2,
|
||||
shadow_sampling_timer_channels.ch2,
|
||||
sample_buffer_size,
|
||||
batch_size,
|
||||
)
|
||||
};
|
||||
|
||||
@ -546,13 +546,13 @@ pub fn setup(
|
||||
dac0_spi,
|
||||
dma_streams.6,
|
||||
sampling_timer_channels.ch3,
|
||||
sample_buffer_size,
|
||||
batch_size,
|
||||
);
|
||||
let dac1 = dac::Dac1Output::new(
|
||||
dac1_spi,
|
||||
dma_streams.7,
|
||||
sampling_timer_channels.ch4,
|
||||
sample_buffer_size,
|
||||
batch_size,
|
||||
);
|
||||
(dac0, dac1)
|
||||
};
|
||||
@ -994,6 +994,7 @@ pub fn setup(
|
||||
tim8_channels.ch1,
|
||||
&mut sampling_timer,
|
||||
etr_pin,
|
||||
batch_size,
|
||||
)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user