Skip to content

Commit 512a873

Browse files
committed
Rename to lpc55-hal
1 parent b861076 commit 512a873

24 files changed

+211
-40
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
55

66
## [Unreleased]
77

8+
## [v0.0.3] - 2019-11-09
9+
Rename to `lpc55-hal`.
10+
11+
Some work towards Flash.
12+
813
## [v0.0.2] - 2019-11-09
914

1015
Several serial peripheral drivers:

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
2-
name = "lpc55s6x-hal"
3-
version = "0.0.2"
2+
name = "lpc55-hal"
3+
version = "0.0.3"
44
edition = "2018"
55
description = "Hardware Abstraction Layer (HAL) for the NXP LPC55S6x ARM Cortex-33 microcontrollers"
6-
repository = "https://github.com/nickray/lpc55s6x-hal"
6+
repository = "https://github.com/nickray/lpc55-hal"
77
license = "Apache-2.0 OR MIT"
88
readme = "README.md"
9-
documentation = "https://docs.rs/lpc55s6x-hal"
9+
documentation = "https://docs.rs/lpc55-hal"
1010
keywords = ["no-std", "cortex-m", "nxp", "lpc", "embedded-hal-impl"]
1111
categories = ["embedded", "no-std"]
1212
authors = ["Nicolas Stalder <[email protected]>", "Hanno Braun <[email protected]>"]
1313
build = "build.rs"
1414

1515
[badges]
16-
circle-ci = { repository = "nickray/lpc55s6x-hal" }
16+
circle-ci = { repository = "nickray/lpc55-hal" }
1717

1818
[dependencies]
1919
bare-metal = "0.2"

README.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Hardware Abstraction Layer (HAL) for [NXP LPC55S6x][nxp-lpc55s6x] [Cortex-M33][cortex-m33] microcontrollers,
2+
Hardware Abstraction Layer (HAL) for [NXP LPC55][nxp-lpc55] series [Cortex-M33][cortex-m33] microcontrollers,
33
written in Rust.
44

55
[![Build Status][build-image]][build-link]
@@ -8,7 +8,7 @@ written in Rust.
88
[![Documentation][docs-image]][docs-link]
99
[![Documentation (master)][docs-master-image]][docs-master-link]
1010

11-
LPC55S6x HAL provides a high-level interface to the features of these LPC55S6x MCUs, which is safe,
11+
LPC55 HAL provides a high-level interface to the features of these LPC55 family of MCUs, which is safe,
1212
convenient and efficient. It leverages Rust's type system to prevent common mistakes, such as attempting
1313
to use an uninitialized peripheral; these will be caught by compile-time errors.
1414

@@ -38,12 +38,12 @@ This HAL is intended to work with `cortex-m-rtfm` v0.5.
3838

3939
## Documentation
4040

41-
The API documentation is located at <https://docs.rs/lpc55s6x-hal>.
41+
The API documentation is located at <https://docs.rs/lpc55-hal>.
4242

4343
In addition, `make fetch-docs` downloads various vendor-supplied documentation:
4444

4545
- [LPC55S6x Data Sheet][datasheet]
46-
- [LPC55S6x User Manual][usermanual] (requires an NXP account)
46+
- [LPC55 User Manual UM11126][usermanual] (requires an NXP account)
4747
- [LPC55S6x Errata][errata]
4848
- [Cortex-M33 Generic User Guide][genericuserguide]
4949
- [LPCXpresso55S69 Development Board User Manual][evkusermanual] (requires an NXP account)
@@ -73,7 +73,7 @@ from the various [STM32 HALs][stm32-rs].
7373

7474
[//]: # "links"
7575

76-
[nxp-lpc55s6x]: https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc5500-cortex-m33:LPC5500_SERIES
76+
[nxp-lpc55]: https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc5500-cortex-m33:LPC5500_SERIES
7777
[cortex-m33]: https://developer.arm.com/ip-products/processors/cortex-m/cortex-m33
7878
[embedded-hal]: https://lib.rs/embedded-hal
7979
[usb-device]: https://lib.rs/usb-device
@@ -83,16 +83,16 @@ from the various [STM32 HALs][stm32-rs].
8383
[stm32-rs]: https://github.com/stm32-rs
8484
[littlefs]: https://github.com/ARMmbed/littlefs
8585
[salty]: https://github.com/nickray/salty
86-
[examples]: https://github.com/nickray/lpc55s6x-hal/tree/main/examples
86+
[examples]: https://github.com/nickray/lpc55-hal/tree/main/examples
8787
[lpcxpresso55s69]: https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc5500-cortex-m33/lpcxpresso55s69-development-board:LPC55S69-EVK
8888
[jlink-fw]: https://www.segger.com/products/debug-probes/j-link/models/other-j-links/lpcxpresso-on-board/
8989

90-
[crates-image]: https://img.shields.io/crates/v/lpc55s6x-hal.svg?style=flat-square
91-
[crates-link]: https://crates.io/crates/lpc55s6x-hal
92-
[build-image]: https://img.shields.io/circleci/build/github/nickray/lpc55s6x-hal/main.svg?style=flat-square
93-
[build-link]: https://circleci.com/gh/nickray/lpc55s6x-hal/tree/main
94-
[docs-image]: https://docs.rs/lpc55s6x-hal/badge.svg?style=flat-square
95-
[docs-link]: https://docs.rs/lpc55s6x-hal
90+
[crates-image]: https://img.shields.io/crates/v/lpc55-hal.svg?style=flat-square
91+
[crates-link]: https://crates.io/crates/lpc55-hal
92+
[build-image]: https://img.shields.io/circleci/build/github/nickray/lpc55-hal/main.svg?style=flat-square
93+
[build-link]: https://circleci.com/gh/nickray/lpc55-hal/tree/main
94+
[docs-image]: https://docs.rs/lpc55-hal/badge.svg?style=flat-square
95+
[docs-link]: https://docs.rs/lpc55-hal
9696
[docs-master-image]: https://img.shields.io/badge/docs-master-blue?style=flat-square
9797
[docs-master-link]: https://lpc55-hal.netlify.com
9898

examples/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# lpc55s6x-hal examples
1+
# lpc55-hal examples
22

33
We use the LPCXpresso55S69 dev board for testing.
44
These would be split out to a board support crate later.

examples/aes.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use cortex_m_rt::entry;
1010
#[allow(unused_imports)]
1111
use hal::prelude::*;
1212
#[allow(unused_imports)]
13-
use lpc55s6x_hal as hal;
13+
use lpc55_hal as hal;
1414

1515
use aes_soft::block_cipher_trait::generic_array::GenericArray;
1616
use aes_soft::block_cipher_trait::BlockCipher;

examples/baby_usb.rs.hidden

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use cortex_m_semihosting::{dbg, hprintln};
1212
#[allow(unused_imports)]
1313
use hal::prelude::*;
1414
#[allow(unused_imports)]
15-
use lpc55s6x_hal as hal;
15+
use lpc55_hal as hal;
1616

1717
use core::ptr;
1818

examples/flash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate panic_semihosting;
55
use cortex_m_rt::entry;
66
use cortex_m_semihosting::{dbg, hprintln};
77

8-
use lpc55s6x_hal as hal;
8+
use lpc55_hal as hal;
99
use hal::prelude::*;
1010

1111
macro_rules! dbgx {

examples/i2c.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cortex_m_rt::entry;
77
use core::fmt::Write;
88

99
use hal::prelude::*;
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
use hal::{
1313
drivers::{

examples/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use heapless::{
1818
i,
1919
spsc::{Consumer, Producer, Queue},
2020
};
21-
use lpc55s6x_hal as hal;
21+
use lpc55_hal as hal;
2222
use panic_semihosting as _;
2323

2424
#[rtfm::app(device = hal::raw)]

examples/led_dwt.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate panic_halt; // 672 bytes
77
use cortex_m_rt::entry;
88

99
use hal::{drivers::pins::Level, prelude::*};
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
#[entry]
1313
fn main() -> ! {

examples/led_minimalist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate panic_halt; // 672 bytes
77
use cortex_m_rt::entry;
88

99
use hal::{drivers::pins::Level, prelude::*};
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
#[entry]
1313
fn main() -> ! {

examples/led_sleep.rs.deactivated

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cortex_m_rt::entry;
77
// use cortex_m_semihosting::{dbg, hprintln};
88

99
use hal::prelude::*;
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
#[entry]
1313
fn main() -> ! {

examples/led_utick.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ extern crate panic_halt; // 672 bytes
66

77
use cortex_m_rt::entry;
88

9-
use lpc55s6x_hal as hal;
9+
use lpc55_hal as hal;
1010
use hal::{
1111
drivers::pins::Level,
1212
prelude::*,

examples/rng.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cortex_m_rt::entry;
77
use cortex_m_semihosting::dbg;
88

99
use embedded_hal::blocking::rng::Read;
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
#[entry]
1313
fn main() -> ! {

examples/rtfm_led.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ extern crate panic_semihosting;
55
// extern crate panic_halt;
66
use cortex_m_semihosting::dbg;
77

8-
use lpc55s6x_hal as hal;
8+
use lpc55_hal as hal;
99
use hal::{
1010
prelude::*,
1111
drivers::pins::Level,

examples/salty.rs.hidden

+166
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
#![no_main]
2+
#![no_std]
3+
4+
///
5+
/// Compare also with: https://github.com/Ko-/aes-armcortexm
6+
///
7+
// extern crate panic_halt;
8+
extern crate panic_semihosting;
9+
use cortex_m_rt::entry;
10+
11+
#[allow(unused_imports)]
12+
use hal::prelude::*;
13+
#[allow(unused_imports)]
14+
use lpc55_hal as hal;
15+
16+
use salty::{Keypair, Sha512};
17+
18+
use cortex_m_semihosting::hprintln;
19+
20+
fn test_ed25519ph_with_rfc_8032_test_vector() {
21+
let seed: [u8; 32] = [
22+
0x83, 0x3f, 0xe6, 0x24, 0x09, 0x23, 0x7b, 0x9d,
23+
0x62, 0xec, 0x77, 0x58, 0x75, 0x20, 0x91, 0x1e,
24+
0x9a, 0x75, 0x9c, 0xec, 0x1d, 0x19, 0x75, 0x5b,
25+
0x7d, 0xa9, 0x01, 0xb9, 0x6d, 0xca, 0x3d, 0x42,
26+
];
27+
28+
let keypair = Keypair::from(&seed);
29+
30+
let message: [u8; 3] = [0x61, 0x62, 0x63];
31+
32+
let prehashed_message = Sha512::new().updated(&message).finalize();
33+
34+
let mut signature: salty::Signature = salty::Signature::default();
35+
for _ in 1..=3 {
36+
let cycles_before = hal::get_cycle_count();
37+
signature = keypair.sign_prehashed(&prehashed_message, None);
38+
let cycles_after = hal::get_cycle_count();
39+
hprintln!("signing took {} cycles", cycles_after - cycles_before).ok();
40+
}
41+
42+
let expected_r = [
43+
0x98, 0xa7, 0x02, 0x22, 0xf0, 0xb8, 0x12, 0x1a,
44+
0xa9, 0xd3, 0x0f, 0x81, 0x3d, 0x68, 0x3f, 0x80,
45+
0x9e, 0x46, 0x2b, 0x46, 0x9c, 0x7f, 0xf8, 0x76,
46+
0x39, 0x49, 0x9b, 0xb9, 0x4e, 0x6d, 0xae, 0x41,
47+
];
48+
49+
let expected_s = [
50+
0x31, 0xf8, 0x50, 0x42, 0x46, 0x3c, 0x2a, 0x35,
51+
0x5a, 0x20, 0x03, 0xd0, 0x62, 0xad, 0xf5, 0xaa,
52+
0xa1, 0x0b, 0x8c, 0x61, 0xe6, 0x36, 0x06, 0x2a,
53+
0xaa, 0xd1, 0x1c, 0x2a, 0x26, 0x08, 0x34, 0x06,
54+
];
55+
56+
assert_eq!(signature.r.to_bytes(), expected_r);
57+
assert_eq!(signature.s.to_bytes(), expected_s);
58+
59+
let public_key = keypair.public;
60+
let cycles_before = hal::get_cycle_count();
61+
let verification = public_key.verify_prehashed(&prehashed_message, &signature, None);
62+
let cycles_after = hal::get_cycle_count();
63+
hprintln!("verification took {} cycles", cycles_after - cycles_before).ok();
64+
assert!(verification.is_ok());
65+
}
66+
67+
impl AsRef<[u8]> for &[u8; 64]
68+
{
69+
#[inline]
70+
fn as_ref(&self) -> &[u8] {
71+
self
72+
}
73+
}
74+
75+
#[entry]
76+
fn main() -> ! {
77+
78+
let hal = hal::Peripherals::take().unwrap();
79+
80+
let mut anactrl = hal.anactrl;
81+
let mut pmc = hal.pmc;
82+
let mut syscon = hal.syscon;
83+
84+
85+
let seed: [u8; 32] = [
86+
0x83, 0x3f, 0xe6, 0x24, 0x09, 0x23, 0x7b, 0x9d,
87+
0x62, 0xec, 0x77, 0x58, 0x75, 0x20, 0x91, 0x1e,
88+
0x9a, 0x75, 0x9c, 0xec, 0x1d, 0x19, 0x75, 0x5b,
89+
0x7d, 0xa9, 0x01, 0xb9, 0x6d, 0xca, 0x3d, 0x42,
90+
];
91+
92+
let keypair = Keypair::from(&seed);
93+
let context = b"";
94+
let message: [u8; 3] = [0x61, 0x62, 0x63];
95+
let prehashed_message = &salty::Sha512::new().updated(&message).finalize();
96+
// let prehashed_message = &Sha512::new().chain(&message).result();
97+
use sha2::{Sha512, Digest};
98+
for _ in 1..=20 {
99+
let cycles_before = hal::get_cycle_count();
100+
let first_hash = Sha512::new()
101+
// Ed25519ph parts
102+
.chain(b"SigEd25519 no Ed25519 collisions")
103+
.chain(&[1])
104+
// context parts
105+
.chain(&[context.len() as u8])
106+
.chain(context)
107+
// usual parts
108+
.chain(&keypair.secret.nonce)
109+
.chain(&prehashed_message)
110+
// .finalize();
111+
.result()
112+
;
113+
// let first_hash = salty::Sha512::new()
114+
// // Ed25519ph parts
115+
// .updated(b"SigEd25519 no Ed25519 collisions")
116+
// .updated(&[1])
117+
// // context parts
118+
// .updated(&[context.len() as u8])
119+
// .updated(context)
120+
// // usual parts
121+
// .updated(&keypair.secret.nonce)
122+
// .updated(prehashed_message)
123+
// .finalize();
124+
// // .result()
125+
// ;
126+
let cycles_after = hal::get_cycle_count();
127+
hprintln!("first hash took {} cycles", cycles_after - cycles_before).ok();
128+
}
129+
for _ in 1..=20 {
130+
let cycles_before = hal::get_cycle_count();
131+
let first_hash = salty::Sha512::new()
132+
// Ed25519ph parts
133+
.updated(b"SigEd25519 no Ed25519 collisions")
134+
.updated(&[1])
135+
// context parts
136+
// .updated(&[context.len() as u8])
137+
.updated(context)
138+
// usual parts
139+
.updated(&keypair.secret.nonce)
140+
.updated(prehashed_message)
141+
// .finalize();
142+
;
143+
let cycles_after = hal::get_cycle_count();
144+
hprintln!("first hash took {} cycles", cycles_after - cycles_before).ok();
145+
}
146+
147+
hal::enable_cycle_counter();
148+
let cycles_before = hal::get_cycle_count();
149+
hal::ClockRequirements::default()
150+
.system_frequency(96.mhz())
151+
.configure(&mut anactrl, &mut pmc, &mut syscon)
152+
.unwrap();
153+
let cycles_after = hal::get_cycle_count();
154+
hprintln!("clocks configured in {} cycles", cycles_after - cycles_before).ok();
155+
156+
for _ in 1..=3 {
157+
let cycles_before = hal::get_cycle_count();
158+
test_ed25519ph_with_rfc_8032_test_vector();
159+
let cycles_after = hal::get_cycle_count();
160+
hprintln!("signing and verification took {} cycles", cycles_after - cycles_before).ok();
161+
}
162+
163+
hprintln!("DONE").ok();
164+
165+
loop { continue; }
166+
}

examples/semihosting.rs.hidden

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use cortex_m::asm;
66
use cortex_m_rt::entry;
77
use cortex_m_semihosting::{dbg, hprint, hprintln};
88

9-
use lpc55s6x_hal as hal;
9+
use lpc55_hal as hal;
1010

1111
// use serde::Serialize;
1212
// use serde_cbor::Serializer;

examples/serial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cortex_m_rt::entry;
77
// use core::fmt::Write;
88

99
use hal::prelude::*;
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
use hal::{
1313
drivers::{

examples/spi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use cortex_m_rt::entry;
77
use core::fmt::Write;
88

99
use hal::prelude::*;
10-
use lpc55s6x_hal as hal;
10+
use lpc55_hal as hal;
1111

1212
use hal::{
1313
drivers::{

0 commit comments

Comments
 (0)