From c06be3b28978db7cbe8653419d3c7df795c752fd Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 29 Sep 2020 03:03:14 +0200 Subject: [PATCH 1/2] Start adding embedded-dma support --- core/Cargo.toml | 2 +- core/src/framed.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 273b291..779df93 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -17,6 +17,7 @@ license = "MIT OR Apache-2.0" [dependencies] generic-array = "0.13" cortex-m = { version = "0.6.0", optional = true } +embedded-dma = "0.1.1" [features] thumbv6 = ["cortex-m"] @@ -25,6 +26,5 @@ thumbv6 = ["cortex-m"] atomic = [] std = [] - [package.metadata.docs.rs] all-features = true diff --git a/core/src/framed.rs b/core/src/framed.rs index 0e82b86..49a05a6 100644 --- a/core/src/framed.rs +++ b/core/src/framed.rs @@ -310,3 +310,32 @@ where self } } + +use embedded_dma::{ + WriteBuffer, + ReadBuffer, +}; + +unsafe impl<'a, N> WriteBuffer for FrameGrantW<'a, N> +where + N: ArrayLength, +{ + type Word = u8; + unsafe fn write_buffer(&mut self) -> (*mut Self::Word, usize) { + let buf = self.deref_mut(); + let len = buf.len(); + (buf.as_mut_ptr(), len) + } +} + +unsafe impl<'a, N> ReadBuffer for FrameGrantW<'a, N> +where + N: ArrayLength, +{ + type Word = u8; + unsafe fn read_buffer(&self) -> (*const Self::Word, usize) { + let buf = self.deref(); + let len = buf.len(); + (buf.as_ptr(), len) + } +} From 7e907aab7a00b1e0bb1e4d1ed1ebed407837c416 Mon Sep 17 00:00:00 2001 From: James Munns Date: Tue, 6 Oct 2020 20:50:45 +0200 Subject: [PATCH 2/2] Add defmt support --- core/Cargo.toml | 15 +++++++++++++++ core/src/lib.rs | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/Cargo.toml b/core/Cargo.toml index 779df93..66124b2 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -19,6 +19,11 @@ generic-array = "0.13" cortex-m = { version = "0.6.0", optional = true } embedded-dma = "0.1.1" +[dependencies.defmt] +git = "https://github.com/knurling-rs/defmt" +branch = "main" +optional = true + [features] thumbv6 = ["cortex-m"] @@ -26,5 +31,15 @@ thumbv6 = ["cortex-m"] atomic = [] std = [] +enable-defmt = ["defmt"] + +# do NOT modify these features +defmt-default = [] +defmt-trace = [] +defmt-debug = [] +defmt-info = [] +defmt-warn = [] +defmt-error = [] + [package.metadata.docs.rs] all-features = true diff --git a/core/src/lib.rs b/core/src/lib.rs index ed7048e..82c0c3e 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -136,8 +136,10 @@ pub use generic_array::ArrayLength; /// Result type used by the `BBQueue` interfaces pub type Result = CoreResult; +use defmt::Format; + /// Error type used by the `BBQueue` interfaces -#[derive(Debug, PartialEq, Eq, Copy, Clone)] +#[derive(Debug, PartialEq, Eq, Copy, Clone, Format)] pub enum Error { /// The buffer does not contain sufficient size for the requested action InsufficientSize,