Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable CCM demo to work on nrf51 #223

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/ccm-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -22,6 +23,7 @@ doc = false
test = false

[features]
51 = ["nrf51-hal"]
52810 = ["nrf52810-hal"]
52832 = ["nrf52832-hal"]
52840 = ["nrf52840-hal"]
Expand Down
1 change: 1 addition & 0 deletions examples/ccm-demo/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# AES-CCM demo

Choose the microcontroller with one of the following features:
- 51
- 52810
- 52832
- 52840
Expand Down
6 changes: 6 additions & 0 deletions examples/ccm-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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];
Expand Down