feat: create crc crate

This commit is contained in:
cscherr 2025-07-09 15:02:17 +02:00
parent e83167634a
commit b3ca9eeabf
Signed by: cscherrNT
GPG key ID: 8E2B45BC51A27EA7
9 changed files with 48 additions and 1 deletions

View file

@ -1,11 +1,15 @@
[build]
target = "thumbv6m-none-eabi"
# target = "thumbv6m-none-eabi"
[test]
target = "x86_64-unknown-linux-gnu"
[target.thumbv6m-none-eabi]
runner = 'probe-rs run --chip STM32L053R8'
[alias]
target = "thumbv6m-none-eabi"
cflash = "flash --chip STM32L053R8"
[env]

4
Cargo.lock generated
View file

@ -92,6 +92,10 @@ dependencies = [
"syn",
]
[[package]]
name = "crc"
version = "0.1.0"
[[package]]
name = "critical-section"
version = "1.2.0"

View file

@ -17,3 +17,6 @@ panic-probe = { version = "0.3", features = ["print-defmt"] }
[profile.release]
debug = "full" # those are not on the board
[workspace]
members = ["", "crates/crc"]

1
crates/crc/.gitignore vendored Executable file
View file

@ -0,0 +1 @@
/target

6
crates/crc/Cargo.toml Executable file
View file

@ -0,0 +1,6 @@
[package]
name = "crc"
version = "0.1.0"
edition = "2024"
[dependencies]

0
crates/crc/src/crc_32.rs Executable file
View file

9
crates/crc/src/crc_dev.rs Executable file
View file

@ -0,0 +1,9 @@
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}

14
crates/crc/src/lib.rs Executable file
View file

@ -0,0 +1,14 @@
mod crc_32;
pub use crc_32::*;
// for testing purposes
mod crc_dev;
pub use crc_dev::*;
pub trait Crc {
type Input: ?Sized;
type Checksum: Eq;
const CHECKSUM_LEN: usize;
fn process(data: &Self::Input) -> Self::Checksum;
}

6
scripts/flash.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
# I'm using a bash script because if i set the target in .cargo/config.toml
# i can't build for x86_64 anymore, which means I can't run the unit tests.
TARGET="thumbv6m-none-eabi"
cargo build --target $TARGET
cargo run --target $TARGET