Moving constants to a new file

This commit is contained in:
Ryan Summers 2020-11-24 17:09:36 +01:00
parent 720e0291f5
commit bf8b950fe6
2 changed files with 13 additions and 6 deletions

6
src/design_parameters.rs Normal file
View File

@ -0,0 +1,6 @@
/// The ADC setup time is the number of seconds after the CSn line goes low before the serial clock
/// may begin. This is used for performing the internal ADC conversion.
pub const ADC_SETUP_TIME: f32 = 220e-9;
/// The maximum DAC/ADC serial clock line frequency. This is a hardware limit.
pub const ADC_DAC_SCK_MHZ_MAX: u32 = 50;

View File

@ -63,6 +63,7 @@ static mut DES_RING: ethernet::DesRing = ethernet::DesRing::new();
mod adc; mod adc;
mod afe; mod afe;
mod dac; mod dac;
mod design_parameters;
mod eeprom; mod eeprom;
mod pounder; mod pounder;
mod sampling_timer; mod sampling_timer;
@ -299,12 +300,12 @@ const APP: () = {
}) })
.manage_cs() .manage_cs()
.suspend_when_inactive() .suspend_when_inactive()
.cs_delay(220e-9); .cs_delay(design_parameters::ADC_SETUP_TIME);
let spi: hal::spi::Spi<_, _, u16> = dp.SPI2.spi( let spi: hal::spi::Spi<_, _, u16> = dp.SPI2.spi(
(spi_sck, spi_miso, hal::spi::NoMosi), (spi_sck, spi_miso, hal::spi::NoMosi),
config, config,
50.mhz(), design_parameters::ADC_DAC_SCK_MHZ_MAX.mhz(),
ccdr.peripheral.SPI2, ccdr.peripheral.SPI2,
&ccdr.clocks, &ccdr.clocks,
); );
@ -337,12 +338,12 @@ const APP: () = {
}) })
.manage_cs() .manage_cs()
.suspend_when_inactive() .suspend_when_inactive()
.cs_delay(220e-9); .cs_delay(design_parameters::ADC_SETUP_TIME);
let spi: hal::spi::Spi<_, _, u16> = dp.SPI3.spi( let spi: hal::spi::Spi<_, _, u16> = dp.SPI3.spi(
(spi_sck, spi_miso, hal::spi::NoMosi), (spi_sck, spi_miso, hal::spi::NoMosi),
config, config,
50.mhz(), design_parameters::ADC_DAC_SCK_MHZ_MAX.mhz(),
ccdr.peripheral.SPI3, ccdr.peripheral.SPI3,
&ccdr.clocks, &ccdr.clocks,
); );
@ -392,7 +393,7 @@ const APP: () = {
dp.SPI4.spi( dp.SPI4.spi(
(spi_sck, spi_miso, hal::spi::NoMosi), (spi_sck, spi_miso, hal::spi::NoMosi),
config, config,
50.mhz(), design_parameters::ADC_DAC_SCK_MHZ_MAX.mhz(),
ccdr.peripheral.SPI4, ccdr.peripheral.SPI4,
&ccdr.clocks, &ccdr.clocks,
) )
@ -424,7 +425,7 @@ const APP: () = {
dp.SPI5.spi( dp.SPI5.spi(
(spi_sck, spi_miso, hal::spi::NoMosi), (spi_sck, spi_miso, hal::spi::NoMosi),
config, config,
50.mhz(), design_parameters::ADC_DAC_SCK_MHZ_MAX.mhz(),
ccdr.peripheral.SPI5, ccdr.peripheral.SPI5,
&ccdr.clocks, &ccdr.clocks,
) )