Skip to content

Commit

Permalink
Merge pull request #104 from tweedegolf/feedback-updates
Browse files Browse the repository at this point in the history
Feedback updates
  • Loading branch information
diondokter authored Sep 25, 2024
2 parents 4c8b587 + 360b454 commit 18ac983
Show file tree
Hide file tree
Showing 5 changed files with 1,088 additions and 6 deletions.
7 changes: 4 additions & 3 deletions book/src/foreign-function-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Use a CRC checksum function written in C in a Rust program

## Steps

1. Add the `cc` build dependency, by adding to `Crate.toml` the lines:
1. Add the `cc` build dependency, by adding to `Cargo.toml` the lines:
```toml
[build-dependencies]
cc = "1.0"
```
2. Create `build.rs` with contents
2. Create `build.rs` (in the same directory as `Cargo.toml`) with contents
```rust
extern crate cc;

Expand All @@ -29,7 +29,8 @@ Use a CRC checksum function written in C in a Rust program
}
```

This will find your c code, compile it, and link it into the executable rust produces
`build.rs` is a build script that cargo runs before it compiles your crate.
This will find your c code, compile it, and link it into the executable rust produces.
3. In `main.rs`, define an extern (fill in the argument and return types)
```rust
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# runner = "probe-rs run --chip nRF52833_xxAA --catch-reset --catch-hardfault --allow-erase-all"
runner = "probe-rs run --chip nRF52833_xxAA --catch-reset --catch-hardfault --allow-erase-all --probe 0d28:0204:990636020005282085E7C008F3731B68000000006E052820"
runner = "probe-rs run --chip nRF52833_xxAA --catch-reset --catch-hardfault --allow-erase-all"
# runner = "probe-rs run --chip nRF52833_xxAA --catch-reset --catch-hardfault --allow-erase-all --probe 0d28:0204:990636020005282085E7C008F3731B68000000006E052820"

rustflags = [
"-C", "link-arg=-Tlink.x",
Expand Down
Loading

0 comments on commit 18ac983

Please sign in to comment.