From eb0f13f0113460c9632203351d5db6328535df70 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Wed, 16 Sep 2020 10:58:43 +0200 Subject: [PATCH] Enable CCM demo to work on nrf51 Signed-off-by: Daniel Egger --- examples/ccm-demo/Cargo.toml | 2 ++ examples/ccm-demo/README.md | 1 + examples/ccm-demo/src/main.rs | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/examples/ccm-demo/Cargo.toml b/examples/ccm-demo/Cargo.toml index 2c6d6050..1af06249 100644 --- a/examples/ccm-demo/Cargo.toml +++ b/examples/ccm-demo/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.6.12" rtt-target = {version = "0.2.0", features = ["cortex-m"] } rand_core = "0.5.1" +nrf51-hal = { path = "../../nrf51-hal", features = ["rt"], optional = true } nrf52810-hal = { path = "../../nrf52810-hal", features = ["rt"], optional = true } nrf52832-hal = { path = "../../nrf52832-hal", features = ["rt"], optional = true } nrf52840-hal = { path = "../../nrf52840-hal", features = ["rt"], optional = true } @@ -22,6 +23,7 @@ doc = false test = false [features] +51 = ["nrf51-hal"] 52810 = ["nrf52810-hal"] 52832 = ["nrf52832-hal"] 52840 = ["nrf52840-hal"] diff --git a/examples/ccm-demo/README.md b/examples/ccm-demo/README.md index 6c7f68cd..7651c3bd 100644 --- a/examples/ccm-demo/README.md +++ b/examples/ccm-demo/README.md @@ -1,6 +1,7 @@ # AES-CCM demo Choose the microcontroller with one of the following features: +- 51 - 52810 - 52832 - 52840 diff --git a/examples/ccm-demo/src/main.rs b/examples/ccm-demo/src/main.rs index ebbd4aee..b3ee49e5 100644 --- a/examples/ccm-demo/src/main.rs +++ b/examples/ccm-demo/src/main.rs @@ -2,6 +2,8 @@ #![no_main] // Import the right HAL/PAC crate, depending on the target chip +#[cfg(feature = "51")] +pub use nrf51_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; #[cfg(feature = "52832")] @@ -51,6 +53,10 @@ fn main() -> ! { let mut ccm_data_enc = CcmData::new(KEY, iv); let mut ccm_data_dec = CcmData::new(KEY, iv); + + #[cfg(feature = "51")] + let mut ccm = Ccm::init(p.CCM, p.AAR, DataRate::_1Mbit); + #[cfg(not(feature = "51"))] let mut ccm = Ccm::init(p.CCM, p.AAR, DataRate::_2Mbit); let mut clear_buffer = [0u8; 254];