From dac6f73d5e3e505c4e5b232fecffd37dc7e86267 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 19 Oct 2020 17:12:02 +0200 Subject: [PATCH 01/13] WIP updates --- Cargo.lock | 44 ++++++------ Cargo.toml | 6 +- ad9959/src/lib.rs | 44 ++++++++++++ src/main.rs | 176 +++++++++++++++++++++++---------------------- src/pounder/mod.rs | 12 ++-- 5 files changed, 164 insertions(+), 118 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 082a02c..3d3e736 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,9 +310,9 @@ dependencies = [ [[package]] name = "paste" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "026c63fe245362be0322bfec5a9656d458d13f9cfb1785d1b38458b9968e8080" +checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" dependencies = [ "paste-impl", "proc-macro-hack", @@ -320,9 +320,9 @@ dependencies = [ [[package]] name = "paste-impl" -version = "0.1.17" +version = "0.1.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b9281a268ec213237dcd2aa3c3d0f46681b04ced37c1616fd36567a9e6954b0" +checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" dependencies = [ "proc-macro-hack", ] @@ -462,7 +462,7 @@ dependencies = [ "serde-json-core", "smoltcp", "stm32h7-ethernet", - "stm32h7xx-hal 0.5.0 (git+https://github.com/quartiq/stm32h7xx-hal.git?branch=feature/pounder-support)", + "stm32h7xx-hal 0.7.1", ] [[package]] @@ -491,23 +491,7 @@ dependencies = [ "cortex-m", "log", "smoltcp", - "stm32h7xx-hal 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "stm32h7xx-hal" -version = "0.5.0" -source = "git+https://github.com/quartiq/stm32h7xx-hal.git?branch=feature/pounder-support#ff00e938f2b226211c178f26c092f36462c44404" -dependencies = [ - "bare-metal", - "cast", - "cortex-m", - "cortex-m-rt", - "embedded-hal", - "nb 0.1.2", - "paste", - "stm32h7", - "void", + "stm32h7xx-hal 0.5.0", ] [[package]] @@ -527,6 +511,22 @@ dependencies = [ "void", ] +[[package]] +name = "stm32h7xx-hal" +version = "0.7.1" +dependencies = [ + "bare-metal", + "cast", + "cortex-m", + "cortex-m-rt", + "embedded-hal", + "nb 0.1.2", + "paste", + "smoltcp", + "stm32h7", + "void", +] + [[package]] name = "syn" version = "1.0.33" diff --git a/Cargo.toml b/Cargo.toml index 0595c33..519fc08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,10 +58,8 @@ branch = "master" features = ["stm32h743v"] [dependencies.stm32h7xx-hal] -features = ["stm32h743v", "rt", "unproven"] - -[patch.crates-io] -stm32h7xx-hal = { git = "https://github.com/quartiq/stm32h7xx-hal.git", branch = "feature/pounder-support" } +features = ["stm32h743v", "rt", "unproven", "ethernet", "phy_lan8742a", "quadspi"] +path = "../stm32h7xx-hal" [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index d12041c..a3d42bf 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -571,4 +571,48 @@ where Ok(tuning_word as f64 * self.system_clock_frequency() / (1u64 << 32) as f64) } + + pub fn write_profile(&mut self, channel: Channel, freq: f64, turns: f32) -> Result<(), Error> { + // The function for channel frequency is `f_out = FTW * f_s / 2^32`, where FTW is the + // frequency tuning word and f_s is the system clock rate. + let tuning_word: u32 = + ((freq as f64 / self.system_clock_frequency()) + * 1u64.wrapping_shl(32) as f64) as u32; + + let phase_offset: u16 = (turns * (1 << 14) as f32) as u16 & 0x3FFFu16; + + self.modify_channel_closure(channel, |interface| { + let mut data: [u8; 7] = [0; 7]; + data[0..2].copy_from_slice(&phase_offset.to_be_bytes()); + data[3] = Register::CFTW0 as u8; + data[4..7].copy_from_slice(&tuning_word.to_be_bytes()); + interface.write(Register::CPOW0 as u8, &data).map_err(|_| Error::Interface) + })?; + + Ok(()) + } + + fn modify_channel_closure(&mut self, channel: Channel, f: F) -> Result<(), Error> + where + F: FnOnce(&mut INTERFACE) -> Result<(), Error>, + { + // Disable all other outputs so that we can update the configuration register of only the + // specified channel. + let mut csr: [u8; 1] = [0]; + self.interface + .read(Register::CSR as u8, &mut csr) + .map_err(|_| Error::Interface)?; + + let mut new_csr = csr; + new_csr[0].set_bits(4..8, 0); + new_csr[0].set_bit(4 + channel as usize, true); + + let result = f(&mut self.interface); + + self.interface + .write(Register::CSR as u8, &new_csr) + .map_err(|_| Error::Interface)?; + + result + } } diff --git a/src/main.rs b/src/main.rs index 9e0c0ff..9be0830 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ use stm32h7xx_hal::prelude::*; use embedded_hal::digital::v2::{InputPin, OutputPin}; use smoltcp as net; -use stm32h7_ethernet as ethernet; +use hal::ethernet as ethernet; use heapless::{consts::*, String}; @@ -160,12 +160,12 @@ macro_rules! route_request { #[rtic::app(device = stm32h7xx_hal::stm32, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)] const APP: () = { struct Resources { - adc0: hal::spi::Spi, - dac0: hal::spi::Spi, + adc0: hal::spi::Spi, + dac0: hal::spi::Spi, afe0: AFE0, - adc1: hal::spi::Spi, - dac1: hal::spi::Spi, + adc1: hal::spi::Spi, + dac1: hal::spi::Spi, afe1: AFE1, eeprom_i2c: hal::i2c::I2c, @@ -208,8 +208,19 @@ const APP: () = { let pwr = dp.PWR.constrain(); let vos = pwr.freeze(); + // Enable SRAM3 for the ethernet descriptor ring. + dp.RCC.ahb2enr.modify(|_, w| w.sram3en().set_bit()); + + // Clear reset flags. + dp.RCC.rsr.write(|w| w.rmvf().set_bit()); + + // Select the PLLs for SPI. + dp.RCC + .d2ccip1r + .modify(|_, w| w.spi123sel().pll2_p().spi45sel().pll2_q()); + let rcc = dp.RCC.constrain(); - let mut clocks = rcc + let clocks = rcc .use_hse(8.mhz()) .sysclk(400.mhz()) .hclk(200.mhz()) @@ -220,25 +231,15 @@ const APP: () = { init_log(); - // Enable SRAM3 for the ethernet descriptor ring. - clocks.rb.ahb2enr.modify(|_, w| w.sram3en().set_bit()); - - clocks.rb.rsr.write(|w| w.rmvf().set_bit()); - - clocks - .rb - .d2ccip1r - .modify(|_, w| w.spi123sel().pll2_p().spi45sel().pll2_q()); - let mut delay = hal::delay::Delay::new(cp.SYST, clocks.clocks); - let gpioa = dp.GPIOA.split(&mut clocks); - let gpiob = dp.GPIOB.split(&mut clocks); - let gpioc = dp.GPIOC.split(&mut clocks); - let gpiod = dp.GPIOD.split(&mut clocks); - let gpioe = dp.GPIOE.split(&mut clocks); - let gpiof = dp.GPIOF.split(&mut clocks); - let gpiog = dp.GPIOG.split(&mut clocks); + let gpioa = dp.GPIOA.split(clocks.peripheral.GPIOA); + let gpiob = dp.GPIOB.split(clocks.peripheral.GPIOB); + let gpioc = dp.GPIOC.split(clocks.peripheral.GPIOC); + let gpiod = dp.GPIOD.split(clocks.peripheral.GPIOD); + let gpioe = dp.GPIOE.split(clocks.peripheral.GPIOE); + let gpiof = dp.GPIOF.split(clocks.peripheral.GPIOF); + let gpiog = dp.GPIOG.split(clocks.peripheral.GPIOG); let afe0 = { let a0_pin = gpiof.pf2.into_push_pull_output(); @@ -274,14 +275,14 @@ const APP: () = { .communication_mode(hal::spi::CommunicationMode::Receiver) .manage_cs() .transfer_size(1) - .frame_size(16) .cs_delay(220e-9); - let mut spi = dp.SPI2.spi( + let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI2.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - &clocks, + clocks.peripheral.SPI2, + &clocks.clocks, ); spi.listen(hal::spi::Event::Eot); @@ -310,14 +311,14 @@ const APP: () = { .communication_mode(hal::spi::CommunicationMode::Receiver) .manage_cs() .transfer_size(1) - .frame_size(16) .cs_delay(220e-9); - let mut spi = dp.SPI3.spi( + let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI3.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - &clocks, + clocks.peripheral.SPI3, + &clocks.clocks, ); spi.listen(hal::spi::Event::Eot); @@ -352,14 +353,14 @@ const APP: () = { .communication_mode(hal::spi::CommunicationMode::Transmitter) .manage_cs() .transfer_size(1) - .frame_size(16) .swap_mosi_miso(); dp.SPI4.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - &clocks, + clocks.peripheral.SPI4, + &clocks.clocks, ) }; @@ -384,14 +385,14 @@ const APP: () = { .communication_mode(hal::spi::CommunicationMode::Transmitter) .manage_cs() .transfer_size(1) - .frame_size(16) .swap_mosi_miso(); dp.SPI5.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - &clocks, + clocks.peripheral.SPI5, + &clocks.clocks, ) }; @@ -412,36 +413,39 @@ const APP: () = { let ad9959 = { let qspi_interface = { // Instantiate the QUADSPI pins and peripheral interface. - // TODO: Place these into a pins structure that is provided to the QSPI - // constructor. - let _qspi_clk = gpiob - .pb2 - .into_alternate_af9() - .set_speed(hal::gpio::Speed::VeryHigh); - let _qspi_ncs = gpioc - .pc11 - .into_alternate_af9() - .set_speed(hal::gpio::Speed::VeryHigh); - let _qspi_io0 = gpioe - .pe7 - .into_alternate_af10() - .set_speed(hal::gpio::Speed::VeryHigh); - let _qspi_io1 = gpioe - .pe8 - .into_alternate_af10() - .set_speed(hal::gpio::Speed::VeryHigh); - let _qspi_io2 = gpioe - .pe9 - .into_alternate_af10() - .set_speed(hal::gpio::Speed::VeryHigh); - let _qspi_io3 = gpioe - .pe10 - .into_alternate_af10() - .set_speed(hal::gpio::Speed::VeryHigh); + let qspi_pins = { - let qspi = - hal::qspi::Qspi::new(dp.QUADSPI, &mut clocks, 10.mhz()) - .unwrap(); + let _qspi_ncs = gpioc + .pc11 + .into_alternate_af9() + .set_speed(hal::gpio::Speed::VeryHigh); + + let clk = gpiob + .pb2 + .into_alternate_af9() + .set_speed(hal::gpio::Speed::VeryHigh); + let io0 = gpioe + .pe7 + .into_alternate_af10() + .set_speed(hal::gpio::Speed::VeryHigh); + let io1 = gpioe + .pe8 + .into_alternate_af10() + .set_speed(hal::gpio::Speed::VeryHigh); + let io2 = gpioe + .pe9 + .into_alternate_af10() + .set_speed(hal::gpio::Speed::VeryHigh); + let io3 = gpioe + .pe10 + .into_alternate_af10() + .set_speed(hal::gpio::Speed::VeryHigh); + + (clk, io0, io1, io2, io3) + }; + + let qspi = hal::qspi::Qspi::bank2(dp.QUADSPI, qspi_pins, 11.mhz(), &clocks.clocks, + clocks.peripheral.QSPI); pounder::QspiInterface::new(qspi).unwrap() }; @@ -470,7 +474,7 @@ const APP: () = { let io_expander = { let sda = gpiob.pb7.into_alternate_af4().set_open_drain(); let scl = gpiob.pb8.into_alternate_af4().set_open_drain(); - let i2c1 = dp.I2C1.i2c((scl, sda), 100.khz(), &clocks); + let i2c1 = dp.I2C1.i2c((scl, sda), 100.khz(), clocks.peripheral.I2C1, &clocks.clocks); mcp23017::MCP23017::default(i2c1).unwrap() }; @@ -491,8 +495,7 @@ const APP: () = { let config = hal::spi::Config::new(hal::spi::Mode { polarity: hal::spi::Polarity::IdleHigh, phase: hal::spi::Phase::CaptureOnSecondTransition, - }) - .frame_size(8); + }); // The maximum frequency of this SPI must be limited due to capacitance on the MISO // line causing a long RC decay. @@ -500,22 +503,25 @@ const APP: () = { (spi_sck, spi_miso, spi_mosi), config, 5.mhz(), - &clocks, + clocks.peripheral.SPI1, + &clocks.clocks, ) }; - let adc1 = { - let mut adc = dp.ADC1.adc(&mut delay, &mut clocks); - adc.calibrate(); + let (adc1, adc2) = { + let (mut adc1, mut adc2) = hal::adc::adc12(dp.ADC1, dp.ADC2, &mut delay, clocks.peripheral.ADC12, &clocks.clocks); - adc.enable() - }; + let adc1 = { + adc1.calibrate(); + adc1.enable() + }; - let adc2 = { - let mut adc = dp.ADC2.adc(&mut delay, &mut clocks); - adc.calibrate(); + let adc2 = { + adc2.calibrate(); + adc2.enable() + }; - adc.enable() + (adc1, adc2) }; let adc1_in_p = gpiof.pf11.into_analog(); @@ -540,16 +546,16 @@ const APP: () = { let mut eeprom_i2c = { let sda = gpiof.pf0.into_alternate_af4().set_open_drain(); let scl = gpiof.pf1.into_alternate_af4().set_open_drain(); - dp.I2C2.i2c((scl, sda), 100.khz(), &clocks) + dp.I2C2.i2c((scl, sda), 100.khz(), clocks.peripheral.I2C2, &clocks.clocks) }; // Configure ethernet pins. { // Reset the PHY before configuring pins. - let mut eth_phy_nrst = gpioe.pe3.into_push_pull_output(); - eth_phy_nrst.set_low().unwrap(); - delay.delay_us(200u8); - eth_phy_nrst.set_high().unwrap(); + //let mut eth_phy_nrst = gpioe.pe3.into_push_pull_output(); + //eth_phy_nrst.set_low().unwrap(); + //delay.delay_ms(200u8); + //eth_phy_nrst.set_high().unwrap(); let _rmii_ref_clk = gpioa .pa1 .into_alternate_af11() @@ -598,8 +604,8 @@ const APP: () = { let (network_interface, eth_mac) = { // Configure the ethernet controller - let (eth_dma, eth_mac) = unsafe { - ethernet::ethernet_init( + let (eth_dma, mut eth_mac) = unsafe { + ethernet::new_unchecked( dp.ETHERNET_MAC, dp.ETHERNET_MTL, dp.ETHERNET_DMA, @@ -608,6 +614,8 @@ const APP: () = { ) }; + eth_mac.block_until_link(); + unsafe { ethernet::enable_interrupt() }; let store = unsafe { &mut NET_STORE }; @@ -638,7 +646,7 @@ const APP: () = { // Utilize the cycle counter for RTIC scheduling. cp.DWT.enable_cycle_counter(); - let mut dma = hal::dma::Dma::dma(dp.DMA1, dp.DMAMUX1, &clocks); + let mut dma = hal::dma::Dma::dma(dp.DMA1, dp.DMAMUX1, clocks.peripheral.DMA1); dma.configure_m2p_stream( hal::dma::Stream::One, &SPI_START_CODE as *const _ as u32, @@ -654,7 +662,7 @@ const APP: () = { ); // Configure timer 2 to trigger conversions for the ADC - let mut timer2 = dp.TIM2.timer(500.khz(), &mut clocks); + let mut timer2 = dp.TIM2.timer(50.khz(), clocks.peripheral.TIM2, &clocks.clocks); timer2.configure_channel(hal::timer::Channel::One, 0.25); timer2.configure_channel(hal::timer::Channel::Two, 0.75); diff --git a/src/pounder/mod.rs b/src/pounder/mod.rs index 1288765..489cc67 100644 --- a/src/pounder/mod.rs +++ b/src/pounder/mod.rs @@ -235,7 +235,7 @@ pub struct PounderDevices { hal::gpio::gpiog::PG7>, >, mcp23017: mcp23017::MCP23017>, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, @@ -262,7 +262,7 @@ where DELAY, hal::gpio::gpiog::PG7>, >, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, @@ -474,12 +474,8 @@ where channel: Channel, state: ChannelState, ) -> Result<(), Error> { - self.ad9959 - .set_frequency(channel.into(), state.parameters.frequency) - .map_err(|_| Error::Dds)?; - self.ad9959 - .set_phase(channel.into(), state.parameters.phase_offset) - .map_err(|_| Error::Dds)?; + self.ad9959.write_profile(channel.into(), state.parameters.frequency, + state.parameters.phase_offset).map_err(|_| Error::Dds)?; self.ad9959 .set_amplitude(channel.into(), state.parameters.amplitude) .map_err(|_| Error::Dds)?; From 17c8e4d2e148299639a5ea4c59e6c30806b311de Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Mon, 26 Oct 2020 16:58:29 +0100 Subject: [PATCH 02/13] Updating to new HAL --- Cargo.lock | 131 +++++++++++++++++++++++++++++++++++----------------- Cargo.toml | 3 +- src/main.rs | 77 +++++++++++++----------------- 3 files changed, 121 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d3e736..fcfc491 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,21 +10,22 @@ dependencies = [ [[package]] name = "aligned" -version = "0.3.2" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb1ce8b3382016136ab1d31a1b5ce807144f8b7eb2d5f16b2108f0f07edceb94" +checksum = "c19796bd8d477f1a9d4ac2465b464a8b1359474f06a96bb3cda650b4fca309bf" dependencies = [ "as-slice", ] [[package]] name = "as-slice" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37dfb65bc03b2bc85ee827004f14a6817e04160e3b1a28931986a666a9290e70" +checksum = "bb4d1c23475b74e3672afa8c2be22040b8b7783ad9b461021144ed10a46bb0e6" dependencies = [ "generic-array 0.12.3", "generic-array 0.13.2", + "generic-array 0.14.4", "stable_deref_trait", ] @@ -41,9 +42,9 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "bare-metal" @@ -55,10 +56,16 @@ dependencies = [ ] [[package]] -name = "bit_field" -version = "0.10.0" +name = "bare-metal" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a165d606cf084741d4ac3a28fb6e9b1eb0bd31f6cd999098cfddb0b2ab381dc0" +checksum = "f8fe8f5a8a398345e52358e18ff07cc17a568fbca5c6f73873d3a62056309603" + +[[package]] +name = "bit_field" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" [[package]] name = "bitfield" @@ -106,7 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2be99930c99669a74d986f7fd2162085498b322e6daae8ef63a97cc9ac1dc73c" dependencies = [ "aligned", - "bare-metal", + "bare-metal 0.2.5", "bitfield", "volatile-register", ] @@ -184,7 +191,7 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa998ce59ec9765d15216393af37a58961ddcefb14c753b4816ba2191d865fcb" dependencies = [ - "nb 0.1.2", + "nb 0.1.3", "void", ] @@ -226,6 +233,16 @@ dependencies = [ "typenum", ] +[[package]] +name = "generic-array" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "501466ecc8a30d1d3b7fc9229b122b2ce8ed6e9d9223f1138d4babb253e51817" +dependencies = [ + "typenum", + "version_check", +] + [[package]] name = "hash32" version = "0.1.1" @@ -236,10 +253,16 @@ dependencies = [ ] [[package]] -name = "heapless" -version = "0.5.5" +name = "hashbrown" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73a8a2391a3bc70b31f60e7a90daa5755a360559c0b6b9c5cfc0fee482362dc0" +checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04" + +[[package]] +name = "heapless" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74911a68a1658cfcfb61bc0ccfbd536e3b6e906f8c2f7883ee50157e3e2184f1" dependencies = [ "as-slice", "generic-array 0.13.2", @@ -250,11 +273,12 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.4.0" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afe" +checksum = "55e2e4c765aa53a0424761bf9f41aa7a6ac1efa87238f59560640e27fca028f2" dependencies = [ "autocfg", + "hashbrown", ] [[package]] @@ -282,9 +306,12 @@ dependencies = [ [[package]] name = "nb" -version = "0.1.2" +version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1411551beb3c11dedfb0a90a0fa256b47d28b9ec2cdff34c25a2fa59e45dbdc" +checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" +dependencies = [ + "nb 1.0.0", +] [[package]] name = "nb" @@ -300,9 +327,9 @@ checksum = "de96540e0ebde571dc55c73d60ef407c653844e6f9a1e2fdbd40c07b9252d812" [[package]] name = "panic-semihosting" -version = "0.5.3" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03864ac862876c16a308f5286f4aa217f1a69ac45df87ad3cd2847f818a642c" +checksum = "aed16eb761d0ee9161dd1319cb38c8007813b20f9720a5a682b283e7b8cdfe58" dependencies = [ "cortex-m", "cortex-m-semihosting", @@ -318,6 +345,12 @@ dependencies = [ "proc-macro-hack", ] +[[package]] +name = "paste" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba7ae1a2180ed02ddfdb5ab70c70d596a26dd642e097bb6fe78b1bde8588ed97" + [[package]] name = "paste-impl" version = "0.1.18" @@ -329,15 +362,15 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.16" +version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e0456befd48169b9f13ef0f0ad46d492cf9d2dbb918bcf38e01eed4ce3ec5e4" +checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" [[package]] name = "proc-macro2" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "beae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fa" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" dependencies = [ "unicode-xid", ] @@ -400,9 +433,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e54c9a88f2da7238af84b5101443f0c0d0a3bbdc455e34a5c9497b1903ed55d5" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" dependencies = [ "serde_derive", ] @@ -419,9 +452,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.115" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "609feed1d0a73cc36a0182a840a9b37b4a82f0b1150369f0536a9e3f2a31dc48" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ "proc-macro2", "quote", @@ -467,9 +500,9 @@ dependencies = [ [[package]] name = "stable_deref_trait" -version = "1.1.1" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dba1a27d3efae4351c8051072d619e3ade2820635c3958d826bfea39d59b54c8" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "stm32h7" @@ -477,7 +510,18 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e9beb5e2a223c82f263c3051bba4614aebc6e98bd40217df3cd8817c83ac7bd8" dependencies = [ - "bare-metal", + "bare-metal 0.2.5", + "cortex-m", + "vcell", +] + +[[package]] +name = "stm32h7" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7571f17d1ed7d67957d0004de6c52bd1ef5e736ed5ddc2bcecf001512269f77c" +dependencies = [ + "bare-metal 0.2.5", "cortex-m", "cortex-m-rt", "vcell", @@ -500,38 +544,39 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "987c66628f30012ed9a41cc738421c5caece03292c0cc8fd1e99956f122735bd" dependencies = [ - "bare-metal", + "bare-metal 0.2.5", "cast", "cortex-m", "cortex-m-rt", "embedded-hal", - "nb 0.1.2", - "paste", - "stm32h7", + "nb 0.1.3", + "paste 0.1.18", + "stm32h7 0.11.0", "void", ] [[package]] name = "stm32h7xx-hal" version = "0.7.1" +source = "git+https://github.com/stm32-rs/stm32h7xx-hal#f28cf3e66c7a7fe2bdd1518f06acbf680e9b9a11" dependencies = [ - "bare-metal", + "bare-metal 1.0.0", "cast", "cortex-m", "cortex-m-rt", "embedded-hal", - "nb 0.1.2", - "paste", + "nb 1.0.0", + "paste 1.0.2", "smoltcp", - "stm32h7", + "stm32h7 0.12.1", "void", ] [[package]] name = "syn" -version = "1.0.33" +version = "1.0.48" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cd" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" dependencies = [ "proc-macro2", "quote", @@ -546,9 +591,9 @@ checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "unicode-xid" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" [[package]] name = "vcell" diff --git a/Cargo.toml b/Cargo.toml index 519fc08..fe4cda3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,7 +59,8 @@ features = ["stm32h743v"] [dependencies.stm32h7xx-hal] features = ["stm32h743v", "rt", "unproven", "ethernet", "phy_lan8742a", "quadspi"] -path = "../stm32h7xx-hal" +git = "https://github.com/stm32-rs/stm32h7xx-hal" +# path = "../stm32h7xx-hal" [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] diff --git a/src/main.rs b/src/main.rs index 9be0830..3b5bfd1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,10 @@ use stm32h7xx_hal::prelude::*; use embedded_hal::digital::v2::{InputPin, OutputPin}; use smoltcp as net; -use hal::ethernet as ethernet; +use hal::{ + ethernet, + dma::{DmaExt, DmaChannel, DmaInternal}, +}; use heapless::{consts::*, String}; @@ -253,6 +256,8 @@ const APP: () = { afe::ProgrammableGainAmplifier::new(a0_pin, a1_pin) }; + let mut dma_channels = dp.DMA1.split(); + // Configure the SPI interfaces to the ADCs and DACs. let adc0_spi = { let spi_miso = gpiob @@ -272,11 +277,18 @@ const APP: () = { polarity: hal::spi::Polarity::IdleHigh, phase: hal::spi::Phase::CaptureOnSecondTransition, }) - .communication_mode(hal::spi::CommunicationMode::Receiver) .manage_cs() - .transfer_size(1) .cs_delay(220e-9); + dma_channels.0.set_peripheral_address(&dp.SPI2.cr1 as *const _ as u32, false); + dma_channels.0.set_memory_address(&SPI_START_CODE as *const _ as u32, false); + dma_channels.0.set_direction(hal::dma::Direction::MemoryToPeripherial); + dma_channels.0.set_transfer_length(1); + dma_channels.0.cr().modify(|_, w| w.circ().enabled()); + dma_channels.0.dmamux().modify(|_, w| + w.dmareq_id().variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP)); + dma_channels.0.start(); + let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI2.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, @@ -285,7 +297,7 @@ const APP: () = { &clocks.clocks, ); - spi.listen(hal::spi::Event::Eot); + spi.listen(hal::spi::Event::Rxp); spi }; @@ -308,11 +320,18 @@ const APP: () = { polarity: hal::spi::Polarity::IdleHigh, phase: hal::spi::Phase::CaptureOnSecondTransition, }) - .communication_mode(hal::spi::CommunicationMode::Receiver) .manage_cs() - .transfer_size(1) .cs_delay(220e-9); + dma_channels.1.set_peripheral_address(&dp.SPI3.cr1 as *const _ as u32, false); + dma_channels.1.set_memory_address(&SPI_START_CODE as *const _ as u32, false); + dma_channels.1.set_direction(hal::dma::Direction::MemoryToPeripherial); + dma_channels.1.dmamux().modify(|_, w| + w.dmareq_id().variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP)); + dma_channels.1.set_transfer_length(1); + dma_channels.1.cr().modify(|_, w| w.circ().enabled()); + dma_channels.1.start(); + let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI3.spi( (spi_sck, spi_miso, hal::spi::NoMosi), config, @@ -321,7 +340,7 @@ const APP: () = { &clocks.clocks, ); - spi.listen(hal::spi::Event::Eot); + spi.listen(hal::spi::Event::Rxp); spi }; @@ -350,9 +369,7 @@ const APP: () = { polarity: hal::spi::Polarity::IdleHigh, phase: hal::spi::Phase::CaptureOnSecondTransition, }) - .communication_mode(hal::spi::CommunicationMode::Transmitter) .manage_cs() - .transfer_size(1) .swap_mosi_miso(); dp.SPI4.spi( @@ -382,9 +399,7 @@ const APP: () = { polarity: hal::spi::Polarity::IdleHigh, phase: hal::spi::Phase::CaptureOnSecondTransition, }) - .communication_mode(hal::spi::CommunicationMode::Transmitter) .manage_cs() - .transfer_size(1) .swap_mosi_miso(); dp.SPI5.spi( @@ -646,28 +661,12 @@ const APP: () = { // Utilize the cycle counter for RTIC scheduling. cp.DWT.enable_cycle_counter(); - let mut dma = hal::dma::Dma::dma(dp.DMA1, dp.DMAMUX1, clocks.peripheral.DMA1); - dma.configure_m2p_stream( - hal::dma::Stream::One, - &SPI_START_CODE as *const _ as u32, - &adc0_spi.spi.cr1 as *const _ as u32, - hal::dma::DMAREQ_ID::TIM2_CH1, - ); - - dma.configure_m2p_stream( - hal::dma::Stream::Two, - &SPI_START_CODE as *const _ as u32, - &adc1_spi.spi.cr1 as *const _ as u32, - hal::dma::DMAREQ_ID::TIM2_CH2, - ); - // Configure timer 2 to trigger conversions for the ADC - let mut timer2 = dp.TIM2.timer(50.khz(), clocks.peripheral.TIM2, &clocks.clocks); - timer2.configure_channel(hal::timer::Channel::One, 0.25); - timer2.configure_channel(hal::timer::Channel::Two, 0.75); - - timer2.listen(hal::timer::Event::ChannelOneDma); - timer2.listen(hal::timer::Event::ChannelTwoDma); + let timer2 = dp.TIM2.timer(500.khz(), clocks.peripheral.TIM2, &clocks.clocks); + { + let t2_regs = unsafe { &*hal::stm32::TIM2::ptr() }; + t2_regs.dier.modify(|_, w| w.ude().set_bit()); + } init::LateResources { afe0: afe0, @@ -690,8 +689,6 @@ const APP: () = { #[task(binds = SPI3, resources = [adc1, dac1, iir_state, iir_ch], priority = 2)] fn spi3(c: spi3::Context) { - c.resources.adc1.spi.ifcr.write(|w| w.eotc().set_bit()); - let output: u16 = { let a: u16 = c.resources.adc1.read().unwrap(); let x0 = f32::from(a as i16); @@ -700,18 +697,11 @@ const APP: () = { y0 as i16 as u16 ^ 0x8000 }; - c.resources - .dac1 - .spi - .ifcr - .write(|w| w.eotc().set_bit().txtfc().set_bit()); c.resources.dac1.send(output).unwrap(); } #[task(binds = SPI2, resources = [adc0, dac0, iir_state, iir_ch], priority = 2)] fn spi2(c: spi2::Context) { - c.resources.adc0.spi.ifcr.write(|w| w.eotc().set_bit()); - let output: u16 = { let a: u16 = c.resources.adc0.read().unwrap(); let x0 = f32::from(a as i16); @@ -720,11 +710,6 @@ const APP: () = { y0 as i16 as u16 ^ 0x8000 }; - c.resources - .dac0 - .spi - .ifcr - .write(|w| w.eotc().set_bit().txtfc().set_bit()); c.resources.dac0.send(output).unwrap(); } From c058d4bcdee2f42d5fc9d21119edf4792a1c820e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 28 Oct 2020 15:41:27 +0100 Subject: [PATCH 03/13] Adding updates for 0.8.0 of the HAL --- Cargo.lock | 14 ++--- Cargo.toml | 6 +- ad9959/src/lib.rs | 23 +++++-- src/main.rs | 145 ++++++++++++++++++++++++++++++++------------- src/pounder/mod.rs | 9 ++- 5 files changed, 139 insertions(+), 58 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fcfc491..998e749 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -108,9 +108,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" [[package]] name = "cortex-m" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2be99930c99669a74d986f7fd2162085498b322e6daae8ef63a97cc9ac1dc73c" +checksum = "88cdafeafba636c00c467ded7f1587210725a1adfab0c24028a7844b87738263" dependencies = [ "aligned", "bare-metal 0.2.5", @@ -362,9 +362,9 @@ dependencies = [ [[package]] name = "proc-macro-hack" -version = "0.5.18" +version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c605b9a0adc77b7211c6b1f722dcb613d68d66859a44f3d485a6da332b0598" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" [[package]] name = "proc-macro2" @@ -495,7 +495,7 @@ dependencies = [ "serde-json-core", "smoltcp", "stm32h7-ethernet", - "stm32h7xx-hal 0.7.1", + "stm32h7xx-hal 0.8.0", ] [[package]] @@ -557,8 +557,8 @@ dependencies = [ [[package]] name = "stm32h7xx-hal" -version = "0.7.1" -source = "git+https://github.com/stm32-rs/stm32h7xx-hal#f28cf3e66c7a7fe2bdd1518f06acbf680e9b9a11" +version = "0.8.0" +source = "git+https://github.com/quartiq/stm32h7xx-hal?branch=rs/issue-158/managed-spi#cc36bbbaa1bf21e53732cfc0f3dd7175c3ed6d44" dependencies = [ "bare-metal 1.0.0", "cast", diff --git a/Cargo.toml b/Cargo.toml index fe4cda3..0f2df5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,9 +58,9 @@ branch = "master" features = ["stm32h743v"] [dependencies.stm32h7xx-hal] -features = ["stm32h743v", "rt", "unproven", "ethernet", "phy_lan8742a", "quadspi"] -git = "https://github.com/stm32-rs/stm32h7xx-hal" -# path = "../stm32h7xx-hal" +features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"] +git = "https://github.com/quartiq/stm32h7xx-hal" +branch = "rs/issue-158/managed-spi" [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index a3d42bf..6fdcefd 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -572,12 +572,17 @@ where / (1u64 << 32) as f64) } - pub fn write_profile(&mut self, channel: Channel, freq: f64, turns: f32) -> Result<(), Error> { + pub fn write_profile( + &mut self, + channel: Channel, + freq: f64, + turns: f32, + ) -> Result<(), Error> { // The function for channel frequency is `f_out = FTW * f_s / 2^32`, where FTW is the // frequency tuning word and f_s is the system clock rate. - let tuning_word: u32 = - ((freq as f64 / self.system_clock_frequency()) - * 1u64.wrapping_shl(32) as f64) as u32; + let tuning_word: u32 = ((freq as f64 / self.system_clock_frequency()) + * 1u64.wrapping_shl(32) as f64) + as u32; let phase_offset: u16 = (turns * (1 << 14) as f32) as u16 & 0x3FFFu16; @@ -586,13 +591,19 @@ where data[0..2].copy_from_slice(&phase_offset.to_be_bytes()); data[3] = Register::CFTW0 as u8; data[4..7].copy_from_slice(&tuning_word.to_be_bytes()); - interface.write(Register::CPOW0 as u8, &data).map_err(|_| Error::Interface) + interface + .write(Register::CPOW0 as u8, &data) + .map_err(|_| Error::Interface) })?; Ok(()) } - fn modify_channel_closure(&mut self, channel: Channel, f: F) -> Result<(), Error> + fn modify_channel_closure( + &mut self, + channel: Channel, + f: F, + ) -> Result<(), Error> where F: FnOnce(&mut INTERFACE) -> Result<(), Error>, { diff --git a/src/main.rs b/src/main.rs index 3b5bfd1..61dcb7e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -#![deny(warnings)] #![allow(clippy::missing_safety_doc)] #![no_std] #![no_main] @@ -35,11 +34,12 @@ use stm32h7xx_hal::prelude::*; use embedded_hal::digital::v2::{InputPin, OutputPin}; -use smoltcp as net; use hal::{ + dma::{DmaChannel, DmaExt, DmaInternal}, ethernet, - dma::{DmaExt, DmaChannel, DmaInternal}, + rcc::rec::ResetEnable, }; +use smoltcp as net; use heapless::{consts::*, String}; @@ -92,7 +92,7 @@ static mut NET_STORE: NetStorage = NetStorage { const SCALE: f32 = ((1 << 15) - 1) as f32; -const SPI_START_CODE: u32 = 0x201; +const SPI_START: u32 = 0x00; // static ETHERNET_PENDING: AtomicBool = AtomicBool::new(true); @@ -176,22 +176,13 @@ const APP: () = { timer: hal::timer::Timer, // Note: It appears that rustfmt generates a format that GDB cannot recognize, which - // results in GDB breakpoints being set improperly. To debug, redefine the following - // definition to: - // - // ```rust - // net_interface: net::iface::EthernetInterface< - // 'static, - // 'static, - // 'static, - // ethernet::EthernetDMA<'static>>, - // ``` + // results in GDB breakpoints being set improperly. + #[rustfmt::skip] net_interface: net::iface::EthernetInterface< 'static, 'static, 'static, - ethernet::EthernetDMA<'static>, - >, + ethernet::EthernetDMA<'static>>, eth_mac: ethernet::EthernetMAC, mac_addr: net::wire::EthernetAddress, @@ -256,6 +247,7 @@ const APP: () = { afe::ProgrammableGainAmplifier::new(a0_pin, a1_pin) }; + clocks.peripheral.DMA1.reset().enable(); let mut dma_channels = dp.DMA1.split(); // Configure the SPI interfaces to the ADCs and DACs. @@ -278,16 +270,34 @@ const APP: () = { phase: hal::spi::Phase::CaptureOnSecondTransition, }) .manage_cs() + .suspend_when_inactive() .cs_delay(220e-9); - dma_channels.0.set_peripheral_address(&dp.SPI2.cr1 as *const _ as u32, false); - dma_channels.0.set_memory_address(&SPI_START_CODE as *const _ as u32, false); - dma_channels.0.set_direction(hal::dma::Direction::MemoryToPeripherial); + dma_channels.0.set_peripheral_address( + &dp.SPI2.txdr as *const _ as u32, + false, + ); + dma_channels + .0 + .set_memory_address(&SPI_START as *const _ as u32, false); + dma_channels + .0 + .set_direction(hal::dma::Direction::MemoryToPeripherial); dma_channels.0.set_transfer_length(1); - dma_channels.0.cr().modify(|_, w| w.circ().enabled()); - dma_channels.0.dmamux().modify(|_, w| - w.dmareq_id().variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP)); - dma_channels.0.start(); + dma_channels.0.cr().modify(|_, w| { + w.circ() + .enabled() + .psize() + .bits16() + .msize() + .bits16() + .pfctrl() + .dma() + }); + dma_channels.0.dmamux().modify(|_, w| { + w.dmareq_id() + .variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP) + }); let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI2.spi( (spi_sck, spi_miso, hal::spi::NoMosi), @@ -297,6 +307,10 @@ const APP: () = { &clocks.clocks, ); + // Kick-start the SPI transaction - we will add data to the TXFIFO to read from the ADC. + let spi_regs = unsafe { &*hal::stm32::SPI2::ptr() }; + spi_regs.cr1.modify(|_, w| w.cstart().started()); + spi.listen(hal::spi::Event::Rxp); spi @@ -321,16 +335,34 @@ const APP: () = { phase: hal::spi::Phase::CaptureOnSecondTransition, }) .manage_cs() + .suspend_when_inactive() .cs_delay(220e-9); - dma_channels.1.set_peripheral_address(&dp.SPI3.cr1 as *const _ as u32, false); - dma_channels.1.set_memory_address(&SPI_START_CODE as *const _ as u32, false); - dma_channels.1.set_direction(hal::dma::Direction::MemoryToPeripherial); - dma_channels.1.dmamux().modify(|_, w| - w.dmareq_id().variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP)); + dma_channels.1.set_peripheral_address( + &dp.SPI3.txdr as *const _ as u32, + false, + ); + dma_channels + .1 + .set_memory_address(&SPI_START as *const _ as u32, false); + dma_channels + .1 + .set_direction(hal::dma::Direction::MemoryToPeripherial); + dma_channels.1.dmamux().modify(|_, w| { + w.dmareq_id() + .variant(hal::stm32::dmamux1::ccr::DMAREQ_ID_A::TIM2_UP) + }); dma_channels.1.set_transfer_length(1); - dma_channels.1.cr().modify(|_, w| w.circ().enabled()); - dma_channels.1.start(); + dma_channels.1.cr().modify(|_, w| { + w.circ() + .enabled() + .psize() + .bits16() + .msize() + .bits16() + .pfctrl() + .dma() + }); let mut spi: hal::spi::Spi<_, _, u16> = dp.SPI3.spi( (spi_sck, spi_miso, hal::spi::NoMosi), @@ -340,6 +372,9 @@ const APP: () = { &clocks.clocks, ); + let spi_regs = unsafe { &*hal::stm32::SPI3::ptr() }; + spi_regs.cr1.modify(|_, w| w.cstart().started()); + spi.listen(hal::spi::Event::Rxp); spi @@ -370,6 +405,8 @@ const APP: () = { phase: hal::spi::Phase::CaptureOnSecondTransition, }) .manage_cs() + .suspend_when_inactive() + .communication_mode(hal::spi::CommunicationMode::Transmitter) .swap_mosi_miso(); dp.SPI4.spi( @@ -400,6 +437,8 @@ const APP: () = { phase: hal::spi::Phase::CaptureOnSecondTransition, }) .manage_cs() + .suspend_when_inactive() + .communication_mode(hal::spi::CommunicationMode::Transmitter) .swap_mosi_miso(); dp.SPI5.spi( @@ -429,7 +468,6 @@ const APP: () = { let qspi_interface = { // Instantiate the QUADSPI pins and peripheral interface. let qspi_pins = { - let _qspi_ncs = gpioc .pc11 .into_alternate_af9() @@ -459,8 +497,13 @@ const APP: () = { (clk, io0, io1, io2, io3) }; - let qspi = hal::qspi::Qspi::bank2(dp.QUADSPI, qspi_pins, 11.mhz(), &clocks.clocks, - clocks.peripheral.QSPI); + let qspi = hal::qspi::Qspi::bank2( + dp.QUADSPI, + qspi_pins, + 11.mhz(), + &clocks.clocks, + clocks.peripheral.QSPI, + ); pounder::QspiInterface::new(qspi).unwrap() }; @@ -489,7 +532,12 @@ const APP: () = { let io_expander = { let sda = gpiob.pb7.into_alternate_af4().set_open_drain(); let scl = gpiob.pb8.into_alternate_af4().set_open_drain(); - let i2c1 = dp.I2C1.i2c((scl, sda), 100.khz(), clocks.peripheral.I2C1, &clocks.clocks); + let i2c1 = dp.I2C1.i2c( + (scl, sda), + 100.khz(), + clocks.peripheral.I2C1, + &clocks.clocks, + ); mcp23017::MCP23017::default(i2c1).unwrap() }; @@ -524,7 +572,13 @@ const APP: () = { }; let (adc1, adc2) = { - let (mut adc1, mut adc2) = hal::adc::adc12(dp.ADC1, dp.ADC2, &mut delay, clocks.peripheral.ADC12, &clocks.clocks); + let (mut adc1, mut adc2) = hal::adc::adc12( + dp.ADC1, + dp.ADC2, + &mut delay, + clocks.peripheral.ADC12, + &clocks.clocks, + ); let adc1 = { adc1.calibrate(); @@ -561,7 +615,12 @@ const APP: () = { let mut eeprom_i2c = { let sda = gpiof.pf0.into_alternate_af4().set_open_drain(); let scl = gpiof.pf1.into_alternate_af4().set_open_drain(); - dp.I2C2.i2c((scl, sda), 100.khz(), clocks.peripheral.I2C2, &clocks.clocks) + dp.I2C2.i2c( + (scl, sda), + 100.khz(), + clocks.peripheral.I2C2, + &clocks.clocks, + ) }; // Configure ethernet pins. @@ -619,18 +678,18 @@ const APP: () = { let (network_interface, eth_mac) = { // Configure the ethernet controller - let (eth_dma, mut eth_mac) = unsafe { + let (eth_dma, eth_mac) = unsafe { ethernet::new_unchecked( dp.ETHERNET_MAC, dp.ETHERNET_MTL, dp.ETHERNET_DMA, &mut DES_RING, mac_addr.clone(), + clocks.peripheral.ETH1MAC, + &clocks.clocks, ) }; - eth_mac.block_until_link(); - unsafe { ethernet::enable_interrupt() }; let store = unsafe { &mut NET_STORE }; @@ -662,12 +721,18 @@ const APP: () = { cp.DWT.enable_cycle_counter(); // Configure timer 2 to trigger conversions for the ADC - let timer2 = dp.TIM2.timer(500.khz(), clocks.peripheral.TIM2, &clocks.clocks); + let timer2 = + dp.TIM2 + .timer(500.khz(), clocks.peripheral.TIM2, &clocks.clocks); { let t2_regs = unsafe { &*hal::stm32::TIM2::ptr() }; t2_regs.dier.modify(|_, w| w.ude().set_bit()); } + // Start the SPI transfers. + dma_channels.0.start(); + dma_channels.1.start(); + init::LateResources { afe0: afe0, adc0: adc0_spi, diff --git a/src/pounder/mod.rs b/src/pounder/mod.rs index 489cc67..032b209 100644 --- a/src/pounder/mod.rs +++ b/src/pounder/mod.rs @@ -474,8 +474,13 @@ where channel: Channel, state: ChannelState, ) -> Result<(), Error> { - self.ad9959.write_profile(channel.into(), state.parameters.frequency, - state.parameters.phase_offset).map_err(|_| Error::Dds)?; + self.ad9959 + .write_profile( + channel.into(), + state.parameters.frequency, + state.parameters.phase_offset, + ) + .map_err(|_| Error::Dds)?; self.ad9959 .set_amplitude(channel.into(), state.parameters.amplitude) .map_err(|_| Error::Dds)?; From b4eeeb20423ff46c8d6b622ecbb7a0886b50d227 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 28 Oct 2020 15:44:52 +0100 Subject: [PATCH 04/13] Reverting unneeded changes --- ad9959/src/lib.rs | 55 ---------------------------------------------- src/main.rs | 8 +++---- src/pounder/mod.rs | 13 +++++------ 3 files changed, 10 insertions(+), 66 deletions(-) diff --git a/ad9959/src/lib.rs b/ad9959/src/lib.rs index 6fdcefd..d12041c 100644 --- a/ad9959/src/lib.rs +++ b/ad9959/src/lib.rs @@ -571,59 +571,4 @@ where Ok(tuning_word as f64 * self.system_clock_frequency() / (1u64 << 32) as f64) } - - pub fn write_profile( - &mut self, - channel: Channel, - freq: f64, - turns: f32, - ) -> Result<(), Error> { - // The function for channel frequency is `f_out = FTW * f_s / 2^32`, where FTW is the - // frequency tuning word and f_s is the system clock rate. - let tuning_word: u32 = ((freq as f64 / self.system_clock_frequency()) - * 1u64.wrapping_shl(32) as f64) - as u32; - - let phase_offset: u16 = (turns * (1 << 14) as f32) as u16 & 0x3FFFu16; - - self.modify_channel_closure(channel, |interface| { - let mut data: [u8; 7] = [0; 7]; - data[0..2].copy_from_slice(&phase_offset.to_be_bytes()); - data[3] = Register::CFTW0 as u8; - data[4..7].copy_from_slice(&tuning_word.to_be_bytes()); - interface - .write(Register::CPOW0 as u8, &data) - .map_err(|_| Error::Interface) - })?; - - Ok(()) - } - - fn modify_channel_closure( - &mut self, - channel: Channel, - f: F, - ) -> Result<(), Error> - where - F: FnOnce(&mut INTERFACE) -> Result<(), Error>, - { - // Disable all other outputs so that we can update the configuration register of only the - // specified channel. - let mut csr: [u8; 1] = [0]; - self.interface - .read(Register::CSR as u8, &mut csr) - .map_err(|_| Error::Interface)?; - - let mut new_csr = csr; - new_csr[0].set_bits(4..8, 0); - new_csr[0].set_bit(4 + channel as usize, true); - - let result = f(&mut self.interface); - - self.interface - .write(Register::CSR as u8, &new_csr) - .map_err(|_| Error::Interface)?; - - result - } } diff --git a/src/main.rs b/src/main.rs index 61dcb7e..2b0e240 100644 --- a/src/main.rs +++ b/src/main.rs @@ -626,10 +626,10 @@ const APP: () = { // Configure ethernet pins. { // Reset the PHY before configuring pins. - //let mut eth_phy_nrst = gpioe.pe3.into_push_pull_output(); - //eth_phy_nrst.set_low().unwrap(); - //delay.delay_ms(200u8); - //eth_phy_nrst.set_high().unwrap(); + let mut eth_phy_nrst = gpioe.pe3.into_push_pull_output(); + eth_phy_nrst.set_low().unwrap(); + delay.delay_us(200u8); + eth_phy_nrst.set_high().unwrap(); let _rmii_ref_clk = gpioa .pa1 .into_alternate_af11() diff --git a/src/pounder/mod.rs b/src/pounder/mod.rs index 032b209..1288765 100644 --- a/src/pounder/mod.rs +++ b/src/pounder/mod.rs @@ -235,7 +235,7 @@ pub struct PounderDevices { hal::gpio::gpiog::PG7>, >, mcp23017: mcp23017::MCP23017>, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, @@ -262,7 +262,7 @@ where DELAY, hal::gpio::gpiog::PG7>, >, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, @@ -475,11 +475,10 @@ where state: ChannelState, ) -> Result<(), Error> { self.ad9959 - .write_profile( - channel.into(), - state.parameters.frequency, - state.parameters.phase_offset, - ) + .set_frequency(channel.into(), state.parameters.frequency) + .map_err(|_| Error::Dds)?; + self.ad9959 + .set_phase(channel.into(), state.parameters.phase_offset) .map_err(|_| Error::Dds)?; self.ad9959 .set_amplitude(channel.into(), state.parameters.amplitude) From e36b853dc8d3fea5c44ae4ca126632c54b9b5cc5 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 28 Oct 2020 15:51:08 +0100 Subject: [PATCH 05/13] Renaming clocks to ccdr --- src/main.rs | 65 ++++++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2b0e240..a791457 100644 --- a/src/main.rs +++ b/src/main.rs @@ -214,7 +214,7 @@ const APP: () = { .modify(|_, w| w.spi123sel().pll2_p().spi45sel().pll2_q()); let rcc = dp.RCC.constrain(); - let clocks = rcc + let ccdr = rcc .use_hse(8.mhz()) .sysclk(400.mhz()) .hclk(200.mhz()) @@ -225,15 +225,15 @@ const APP: () = { init_log(); - let mut delay = hal::delay::Delay::new(cp.SYST, clocks.clocks); + let mut delay = hal::delay::Delay::new(cp.SYST, ccdr.clocks); - let gpioa = dp.GPIOA.split(clocks.peripheral.GPIOA); - let gpiob = dp.GPIOB.split(clocks.peripheral.GPIOB); - let gpioc = dp.GPIOC.split(clocks.peripheral.GPIOC); - let gpiod = dp.GPIOD.split(clocks.peripheral.GPIOD); - let gpioe = dp.GPIOE.split(clocks.peripheral.GPIOE); - let gpiof = dp.GPIOF.split(clocks.peripheral.GPIOF); - let gpiog = dp.GPIOG.split(clocks.peripheral.GPIOG); + let gpioa = dp.GPIOA.split(ccdr.peripheral.GPIOA); + let gpiob = dp.GPIOB.split(ccdr.peripheral.GPIOB); + let gpioc = dp.GPIOC.split(ccdr.peripheral.GPIOC); + let gpiod = dp.GPIOD.split(ccdr.peripheral.GPIOD); + let gpioe = dp.GPIOE.split(ccdr.peripheral.GPIOE); + let gpiof = dp.GPIOF.split(ccdr.peripheral.GPIOF); + let gpiog = dp.GPIOG.split(ccdr.peripheral.GPIOG); let afe0 = { let a0_pin = gpiof.pf2.into_push_pull_output(); @@ -247,7 +247,7 @@ const APP: () = { afe::ProgrammableGainAmplifier::new(a0_pin, a1_pin) }; - clocks.peripheral.DMA1.reset().enable(); + ccdr.peripheral.DMA1.reset().enable(); let mut dma_channels = dp.DMA1.split(); // Configure the SPI interfaces to the ADCs and DACs. @@ -303,8 +303,8 @@ const APP: () = { (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - clocks.peripheral.SPI2, - &clocks.clocks, + ccdr.peripheral.SPI2, + &ccdr.clocks, ); // Kick-start the SPI transaction - we will add data to the TXFIFO to read from the ADC. @@ -368,8 +368,8 @@ const APP: () = { (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - clocks.peripheral.SPI3, - &clocks.clocks, + ccdr.peripheral.SPI3, + &ccdr.clocks, ); let spi_regs = unsafe { &*hal::stm32::SPI3::ptr() }; @@ -413,8 +413,8 @@ const APP: () = { (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - clocks.peripheral.SPI4, - &clocks.clocks, + ccdr.peripheral.SPI4, + &ccdr.clocks, ) }; @@ -445,8 +445,8 @@ const APP: () = { (spi_sck, spi_miso, hal::spi::NoMosi), config, 50.mhz(), - clocks.peripheral.SPI5, - &clocks.clocks, + ccdr.peripheral.SPI5, + &ccdr.clocks, ) }; @@ -501,8 +501,8 @@ const APP: () = { dp.QUADSPI, qspi_pins, 11.mhz(), - &clocks.clocks, - clocks.peripheral.QSPI, + &ccdr.clocks, + ccdr.peripheral.QSPI, ); pounder::QspiInterface::new(qspi).unwrap() }; @@ -511,7 +511,7 @@ const APP: () = { let io_update = gpiog.pg7.into_push_pull_output(); let asm_delay = { - let frequency_hz = clocks.clocks.c_ck().0; + let frequency_hz = ccdr.ccdr.c_ck().0; asm_delay::AsmDelay::new(asm_delay::bitrate::Hertz( frequency_hz, )) @@ -535,8 +535,8 @@ const APP: () = { let i2c1 = dp.I2C1.i2c( (scl, sda), 100.khz(), - clocks.peripheral.I2C1, - &clocks.clocks, + ccdr.peripheral.I2C1, + &ccdr.clocks, ); mcp23017::MCP23017::default(i2c1).unwrap() }; @@ -566,8 +566,8 @@ const APP: () = { (spi_sck, spi_miso, spi_mosi), config, 5.mhz(), - clocks.peripheral.SPI1, - &clocks.clocks, + ccdr.peripheral.SPI1, + &ccdr.clocks, ) }; @@ -576,8 +576,8 @@ const APP: () = { dp.ADC1, dp.ADC2, &mut delay, - clocks.peripheral.ADC12, - &clocks.clocks, + ccdr.peripheral.ADC12, + &ccdr.clocks, ); let adc1 = { @@ -618,8 +618,8 @@ const APP: () = { dp.I2C2.i2c( (scl, sda), 100.khz(), - clocks.peripheral.I2C2, - &clocks.clocks, + ccdr.peripheral.I2C2, + &ccdr.clocks, ) }; @@ -685,8 +685,8 @@ const APP: () = { dp.ETHERNET_DMA, &mut DES_RING, mac_addr.clone(), - clocks.peripheral.ETH1MAC, - &clocks.clocks, + ccdr.peripheral.ETH1MAC, + &ccdr.clocks, ) }; @@ -722,8 +722,7 @@ const APP: () = { // Configure timer 2 to trigger conversions for the ADC let timer2 = - dp.TIM2 - .timer(500.khz(), clocks.peripheral.TIM2, &clocks.clocks); + dp.TIM2.timer(500.khz(), ccdr.peripheral.TIM2, &ccdr.clocks); { let t2_regs = unsafe { &*hal::stm32::TIM2::ptr() }; t2_regs.dier.modify(|_, w| w.ude().set_bit()); From 11ff93e6f0a080a1239de0d44bf3fd5040cab11c Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 28 Oct 2020 15:57:14 +0100 Subject: [PATCH 06/13] Fixing diff --- src/main.rs | 4 ++-- src/pounder/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index a791457..c7d0eaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -500,7 +500,7 @@ const APP: () = { let qspi = hal::qspi::Qspi::bank2( dp.QUADSPI, qspi_pins, - 11.mhz(), + 10.mhz(), &ccdr.clocks, ccdr.peripheral.QSPI, ); @@ -511,7 +511,7 @@ const APP: () = { let io_update = gpiog.pg7.into_push_pull_output(); let asm_delay = { - let frequency_hz = ccdr.ccdr.c_ck().0; + let frequency_hz = ccdr.clocks.c_ck().0; asm_delay::AsmDelay::new(asm_delay::bitrate::Hertz( frequency_hz, )) diff --git a/src/pounder/mod.rs b/src/pounder/mod.rs index 1288765..6940e0e 100644 --- a/src/pounder/mod.rs +++ b/src/pounder/mod.rs @@ -235,7 +235,7 @@ pub struct PounderDevices { hal::gpio::gpiog::PG7>, >, mcp23017: mcp23017::MCP23017>, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, @@ -262,7 +262,7 @@ where DELAY, hal::gpio::gpiog::PG7>, >, - attenuator_spi: hal::spi::Spi, + attenuator_spi: hal::spi::Spi, adc1: hal::adc::Adc, adc2: hal::adc::Adc, adc1_in_p: hal::gpio::gpiof::PF11, From f56487401c8314cfc2b21512d3de8d008a25e63d Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Wed, 28 Oct 2020 16:14:48 +0100 Subject: [PATCH 07/13] Adding updates for PHY support --- src/main.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index c7d0eaa..58d879e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,7 +36,7 @@ use embedded_hal::digital::v2::{InputPin, OutputPin}; use hal::{ dma::{DmaChannel, DmaExt, DmaInternal}, - ethernet, + ethernet::{self, PHY}, rcc::rec::ResetEnable, }; use smoltcp as net; @@ -183,7 +183,7 @@ const APP: () = { 'static, 'static, ethernet::EthernetDMA<'static>>, - eth_mac: ethernet::EthernetMAC, + eth_mac: ethernet::phy::LAN8742A, mac_addr: net::wire::EthernetAddress, pounder: Option>, @@ -690,6 +690,12 @@ const APP: () = { ) }; + // Reset and initialize the ethernet phy. + let mut lan8742a = + ethernet::phy::LAN8742A::new(eth_mac.set_phy_addr(0)); + lan8742a.phy_reset(); + lan8742a.phy_init(); + unsafe { ethernet::enable_interrupt() }; let store = unsafe { &mut NET_STORE }; @@ -708,7 +714,7 @@ const APP: () = { .ip_addrs(&mut store.ip_addrs[..]) .finalize(); - (interface, eth_mac) + (interface, lan8742a) }; cp.SCB.enable_icache(); From 2e9fdd9d4d0ae44059461ee0ef40274a8933ad66 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Thu, 5 Nov 2020 08:06:42 +0100 Subject: [PATCH 08/13] Updating stm32h7xx-hal --- Cargo.lock | 74 +++--------------------------------------------------- Cargo.toml | 8 +----- 2 files changed, 5 insertions(+), 77 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 998e749..014b427 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -335,37 +335,12 @@ dependencies = [ "cortex-m-semihosting", ] -[[package]] -name = "paste" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45ca20c77d80be666aef2b45486da86238fabe33e38306bd3118fe4af33fa880" -dependencies = [ - "paste-impl", - "proc-macro-hack", -] - [[package]] name = "paste" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba7ae1a2180ed02ddfdb5ab70c70d596a26dd642e097bb6fe78b1bde8588ed97" -[[package]] -name = "paste-impl" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d95a7db200b97ef370c8e6de0088252f7e0dfff7d047a28528e47456c0fc98b6" -dependencies = [ - "proc-macro-hack", -] - -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" version = "1.0.24" @@ -469,7 +444,6 @@ checksum = "0fe46639fd2ec79eadf8fe719f237a7a0bd4dac5d957f1ca5bbdbc1c3c39e53a" dependencies = [ "bitflags", "byteorder", - "log", "managed", ] @@ -494,8 +468,7 @@ dependencies = [ "serde", "serde-json-core", "smoltcp", - "stm32h7-ethernet", - "stm32h7xx-hal 0.8.0", + "stm32h7xx-hal", ] [[package]] @@ -504,17 +477,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" -[[package]] -name = "stm32h7" -version = "0.11.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9beb5e2a223c82f263c3051bba4614aebc6e98bd40217df3cd8817c83ac7bd8" -dependencies = [ - "bare-metal 0.2.5", - "cortex-m", - "vcell", -] - [[package]] name = "stm32h7" version = "0.12.1" @@ -527,38 +489,10 @@ dependencies = [ "vcell", ] -[[package]] -name = "stm32h7-ethernet" -version = "0.1.1" -source = "git+https://github.com/quartiq/stm32h7-ethernet.git#cf9b8bb2e1b440d8ada6ac6048f48dc4ed9c269a" -dependencies = [ - "cortex-m", - "log", - "smoltcp", - "stm32h7xx-hal 0.5.0", -] - -[[package]] -name = "stm32h7xx-hal" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "987c66628f30012ed9a41cc738421c5caece03292c0cc8fd1e99956f122735bd" -dependencies = [ - "bare-metal 0.2.5", - "cast", - "cortex-m", - "cortex-m-rt", - "embedded-hal", - "nb 0.1.3", - "paste 0.1.18", - "stm32h7 0.11.0", - "void", -] - [[package]] name = "stm32h7xx-hal" version = "0.8.0" -source = "git+https://github.com/quartiq/stm32h7xx-hal?branch=rs/issue-158/managed-spi#cc36bbbaa1bf21e53732cfc0f3dd7175c3ed6d44" +source = "git+https://github.com/stm32-rs/stm32h7xx-hal#cbb31d0b6d0c8530437367032a600a4ff74657f7" dependencies = [ "bare-metal 1.0.0", "cast", @@ -566,9 +500,9 @@ dependencies = [ "cortex-m-rt", "embedded-hal", "nb 1.0.0", - "paste 1.0.2", + "paste", "smoltcp", - "stm32h7 0.12.1", + "stm32h7", "void", ] diff --git a/Cargo.toml b/Cargo.toml index 0f2df5c..a57745e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,15 +52,9 @@ default-features = false [dependencies.ad9959] path = "ad9959" -[dependencies.stm32h7-ethernet] -git = "https://github.com/quartiq/stm32h7-ethernet.git" -branch = "master" -features = ["stm32h743v"] - [dependencies.stm32h7xx-hal] features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"] -git = "https://github.com/quartiq/stm32h7xx-hal" -branch = "rs/issue-158/managed-spi" +git = "https://github.com/stm32-rs/stm32h7xx-hal" [features] semihosting = ["panic-semihosting", "cortex-m-log/semihosting"] From c804312e605cd83c7fa526ca1ebaf4835c81dd98 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 10 Nov 2020 15:13:57 +0100 Subject: [PATCH 09/13] Fixing deprecation warnings --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index d75a16e..1c29522 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![deny(warnings)] +#![allow(deprecated)] #![allow(clippy::missing_safety_doc)] #![no_std] #![no_main] From 7b86a2bc4218e4204303cd1f03f9d21bb811f2c0 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 10 Nov 2020 15:14:49 +0100 Subject: [PATCH 10/13] Adding comment about deprecation allowance --- src/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1c29522..f453a49 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ #![deny(warnings)] -#![allow(deprecated)] #![allow(clippy::missing_safety_doc)] #![no_std] #![no_main] @@ -19,6 +18,9 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { } } +// Deprecation warnings are temporarily allowed as the HAL DMA goes through updates. +#![allow(deprecated)] + #[cfg(feature = "semihosting")] extern crate panic_semihosting; From 84e31ef03640e279f787b3bb79c66258c50b935e Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 10 Nov 2020 15:16:37 +0100 Subject: [PATCH 11/13] Fixing directive position --- src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index f453a49..642bd70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,9 @@ #![deny(warnings)] #![allow(clippy::missing_safety_doc)] + +// Deprecation warnings are temporarily allowed as the HAL DMA goes through updates. +#![allow(deprecated)] + #![no_std] #![no_main] #![cfg_attr(feature = "nightly", feature(asm))] @@ -18,9 +22,6 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { } } -// Deprecation warnings are temporarily allowed as the HAL DMA goes through updates. -#![allow(deprecated)] - #[cfg(feature = "semihosting")] extern crate panic_semihosting; From a32ca39ca059d090669ddfd839b4233a79bb8d69 Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 10 Nov 2020 15:19:44 +0100 Subject: [PATCH 12/13] Removing spaces --- src/main.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 642bd70..e628c31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,7 @@ #![deny(warnings)] #![allow(clippy::missing_safety_doc)] - // Deprecation warnings are temporarily allowed as the HAL DMA goes through updates. #![allow(deprecated)] - #![no_std] #![no_main] #![cfg_attr(feature = "nightly", feature(asm))] From f164a1a89e2ea54c06bacde5c64f988d6f9a92fb Mon Sep 17 00:00:00 2001 From: Ryan Summers Date: Tue, 10 Nov 2020 15:31:19 +0100 Subject: [PATCH 13/13] Update PR --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e628c31..a7d3d73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ #![deny(warnings)] -#![allow(clippy::missing_safety_doc)] // Deprecation warnings are temporarily allowed as the HAL DMA goes through updates. #![allow(deprecated)] +#![allow(clippy::missing_safety_doc)] #![no_std] #![no_main] #![cfg_attr(feature = "nightly", feature(asm))]