feat: create crc crate
This commit is contained in:
parent
e83167634a
commit
b3ca9eeabf
9 changed files with 48 additions and 1 deletions
|
@ -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
4
Cargo.lock
generated
|
@ -92,6 +92,10 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crc"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "critical-section"
|
||||
version = "1.2.0"
|
||||
|
|
|
@ -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
1
crates/crc/.gitignore
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
/target
|
6
crates/crc/Cargo.toml
Executable file
6
crates/crc/Cargo.toml
Executable file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "crc"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
0
crates/crc/src/crc_32.rs
Executable file
0
crates/crc/src/crc_32.rs
Executable file
9
crates/crc/src/crc_dev.rs
Executable file
9
crates/crc/src/crc_dev.rs
Executable 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
14
crates/crc/src/lib.rs
Executable 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
6
scripts/flash.sh
Executable 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
|
Loading…
Add table
Reference in a new issue