From c5a2704c41ec5f7089c705effe5af14d1a064cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Tue, 1 Jun 2021 13:11:16 +0200 Subject: [PATCH] dma: implement overflow checking --- Cargo.lock | 2 +- Cargo.toml | 3 ++- src/bin/dual-iir.rs | 4 ++-- src/hardware/adc.rs | 4 ++-- src/hardware/dac.rs | 4 ++-- src/hardware/pounder/dds_output.rs | 4 +++- src/net/miniconf_client.rs | 1 + 7 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9fbbe91..de1f22f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -810,7 +810,7 @@ dependencies = [ [[package]] name = "stm32h7xx-hal" version = "0.9.0" -source = "git+https://github.com/quartiq/stm32h7xx-hal.git?rev=cca4ecc#cca4ecc3e0cc8cb2f7a9652c4099d50b44977493" +source = "git+https://github.com/quartiq/stm32h7xx-hal.git?rev=b0b8a93#b0b8a930b2c3bc5fcebc2e905b4c5e13360111a5" dependencies = [ "bare-metal 1.0.0", "cast", diff --git a/Cargo.toml b/Cargo.toml index 93eaa9a..99b390e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,11 +52,12 @@ mcp23017 = "1.0" git = "https://github.com/quartiq/rtt-logger.git" rev = "70b0eb5" +# fast double buffered DMA without poisoning and buffer swapping [dependencies.stm32h7xx-hal] features = ["stm32h743v", "rt", "unproven", "ethernet", "quadspi"] # version = "0.9.0" git = "https://github.com/quartiq/stm32h7xx-hal.git" -rev = "cca4ecc" +rev = "b0b8a93" # link.x section start/end [patch.crates-io.cortex-m-rt] diff --git a/src/bin/dual-iir.rs b/src/bin/dual-iir.rs index a45d603..ab965ee 100644 --- a/src/bin/dual-iir.rs +++ b/src/bin/dual-iir.rs @@ -54,10 +54,10 @@ impl Default for Settings { macro_rules! flatten_closures { ($fn:ident, $e:ident, $fun:block) => { - $e.$fn(|$e| $fun ) + $e.$fn(|$e| $fun ).unwrap() }; ($fn:ident, $e:ident, $($es:ident),+, $fun:block) => { - $e.$fn(|$e| flatten_closures!($fn, $($es),*, $fun)) + $e.$fn(|$e| flatten_closures!($fn, $($es),*, $fun)).unwrap() }; } diff --git a/src/hardware/adc.rs b/src/hardware/adc.rs index 101d762..8919479 100644 --- a/src/hardware/adc.rs +++ b/src/hardware/adc.rs @@ -74,7 +74,7 @@ use hal::dma::{ config::Priority, dma::{DMAReq, DmaConfig}, traits::TargetAddress, - MemoryToPeripheral, PeripheralToMemory, Transfer, + DMAError, MemoryToPeripheral, PeripheralToMemory, Transfer, }; /// A type representing an ADC sample. @@ -359,7 +359,7 @@ macro_rules! adc_input { /// /// NOTE(unsafe): Memory safety and access ordering is not guaranteed /// (see the HAL DMA docs). - pub fn with_buffer(&mut self, f: F) -> R + pub fn with_buffer(&mut self, f: F) -> Result where F: FnOnce(&mut SampleBuffer) -> R, { diff --git a/src/hardware/dac.rs b/src/hardware/dac.rs index 91f8610..013c43a 100644 --- a/src/hardware/dac.rs +++ b/src/hardware/dac.rs @@ -58,7 +58,7 @@ use super::timers; use hal::dma::{ dma::{DMAReq, DmaConfig}, traits::TargetAddress, - MemoryToPeripheral, Transfer, + DMAError, MemoryToPeripheral, Transfer, }; // The following global buffers are used for the DAC code DMA transfers. Two buffers are used for @@ -209,7 +209,7 @@ macro_rules! dac_output { /// /// NOTE(unsafe): Memory safety and access ordering is not guaranteed /// (see the HAL DMA docs). - pub fn with_buffer(&mut self, f: F) -> R + pub fn with_buffer(&mut self, f: F) -> Result where F: FnOnce(&mut SampleBuffer) -> R, { diff --git a/src/hardware/pounder/dds_output.rs b/src/hardware/pounder/dds_output.rs index e755482..bf7acc0 100644 --- a/src/hardware/pounder/dds_output.rs +++ b/src/hardware/pounder/dds_output.rs @@ -52,9 +52,11 @@ ///! compile-time-known register update sequence needed for the application, the serialization ///! process can be done once and then register values can be written into a pre-computed serialized ///! buffer to avoid the software overhead of much of the serialization process. +use log::warn; +use stm32h7xx_hal as hal; + use super::{hrtimer::HighResTimerE, QspiInterface}; use ad9959::{Channel, DdsConfig, ProfileSerializer}; -use stm32h7xx_hal as hal; /// The DDS profile update stream. pub struct DdsOutput { diff --git a/src/net/miniconf_client.rs b/src/net/miniconf_client.rs index cc838f6..e5f328a 100644 --- a/src/net/miniconf_client.rs +++ b/src/net/miniconf_client.rs @@ -11,6 +11,7 @@ ///! Respones to settings updates are sent without quality-of-service guarantees, so there's no ///! guarantee that the requestee will be informed that settings have been applied. use heapless::String; +use log::info; use super::{MqttMessage, NetworkReference, SettingsResponse, UpdateState}; use crate::hardware::design_parameters::MQTT_BROKER;