From 52026cb46886d9bc20fa0d2c1037464d036eb307 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Fri, 25 Oct 2024 12:24:15 +0200 Subject: [PATCH] Add support for lpc55-hal 0.4 --- CHANGELOG.md | 4 ++++ Cargo.toml | 5 ++++- Makefile | 6 ++++-- src/t1/i2cimpl.rs | 20 ++++++++++++++++++-- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3c9595..2a14163 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ SPDX-License-Identifier: CC0-1.0 # Changelog +## Unreleased + +- Add support for `lpc55-hal` 0.4 behind a `lpc55-04` feature + ## [v0.1.6][] (2025-08-13) - Fix `ExportObject` for large keys (NIST-P521 and brainpoolp512) ([#16][]) diff --git a/Cargo.toml b/Cargo.toml index 002a272..68c71b1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,6 +22,7 @@ heapless = "0.7" hex-literal = "0.4.1" iso7816 = "0.1.1" lpc55-hal = { version = "0.3.0", optional = true } +lpc55-hal-04 = { package = "lpc55-hal", version = "0.4.0", optional = true } nrf-hal-common = { version = "0.15.0", optional = true } rand = { version = "0.8.5", optional = true, default-features = false } serde = { version = "1.0.185", default-features = false, features = ["derive"], optional = true } @@ -41,7 +42,9 @@ log-error = [] log-none = [] nrf = ["nrf-hal-common"] -lpc55 = ["lpc55-hal"] +lpc55 = ["lpc55-03"] +lpc55-03 = ["dep:lpc55-hal"] +lpc55-04 = ["dep:lpc55-hal-04"] aes-session = ["aes", "cmac", "rand"] serde_bytes = ["dep:serde_bytes"] diff --git a/Makefile b/Makefile index 39833b3..fbd8a53 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,8 @@ check: src/se05x/commands.rs cargo c cargo c --features builder cargo c --features nrf,nrf-hal-common/52840 --target thumbv7em-none-eabihf - cargo c --features lpc55 --target thumbv8m.main-none-eabi + cargo c --features lpc55-03 --target thumbv8m.main-none-eabi + cargo c --features lpc55-04 --target thumbv8m.main-none-eabi .PHONY: lint @@ -28,7 +29,8 @@ lint: src/se05x/commands.rs verify-commands cargo fmt --check cargo clippy cargo clippy --features nrf,nrf-hal-common/52840 --target thumbv7em-none-eabihf - cargo clippy --features lpc55 --target thumbv8m.main-none-eabi + cargo clippy --features lpc55-03 --target thumbv8m.main-none-eabi + cargo clippy --features lpc55-04 --target thumbv8m.main-none-eabi cargo doc --features aes-session,builder,serde --no-deps README.md: src/lib.rs Makefile diff --git a/src/t1/i2cimpl.rs b/src/t1/i2cimpl.rs index 54838e7..51ed676 100644 --- a/src/t1/i2cimpl.rs +++ b/src/t1/i2cimpl.rs @@ -17,8 +17,8 @@ mod nrf52832 { } } -#[cfg(feature = "lpc55")] -mod lpc55 { +#[cfg(feature = "lpc55-03")] +mod lpc55_03 { use crate::t1::I2CErrorNack; use lpc55_hal::drivers::i2c::Error; @@ -32,3 +32,19 @@ mod lpc55 { } } } + +#[cfg(feature = "lpc55-04")] +mod lpc55_04 { + use crate::t1::I2CErrorNack; + + use lpc55_hal_04::drivers::i2c::Error; + + impl I2CErrorNack for Error { + fn is_address_nack(&self) -> bool { + matches!(self, Error::NackAddress) + } + fn is_data_nack(&self) -> bool { + matches!(self, Error::NackData) + } + } +}