diff options
| author | Ulf Lilleengen <[email protected]> | 2024-05-18 10:17:03 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2024-05-21 10:05:21 +0200 |
| commit | 739e5861c2e47db251725163fcd91cd822cf97b7 (patch) | |
| tree | 947dc7961ca7c42ec216056fc2adf616ab812b10 /docs/pages/project_structure.adoc | |
| parent | 51d553092550059afb22b2620cea14bbed21abff (diff) | |
convert from antora to asciidoctor
Diffstat (limited to 'docs/pages/project_structure.adoc')
| -rw-r--r-- | docs/pages/project_structure.adoc | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/docs/pages/project_structure.adoc b/docs/pages/project_structure.adoc new file mode 100644 index 000000000..722ec8d9d --- /dev/null +++ b/docs/pages/project_structure.adoc | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | = Project Structure | ||
| 2 | |||
| 3 | There are many ways to configure embassy and its components for your exact application. The link:https://github.com/embassy-rs/embassy/tree/main/examples[examples] directory for each chipset demonstrates how your project structure should look. Let's break it down: | ||
| 4 | |||
| 5 | The toplevel file structure of your project should look like this: | ||
| 6 | [source,plain] | ||
| 7 | ---- | ||
| 8 | {} = Maybe | ||
| 9 | |||
| 10 | my-project | ||
| 11 | |- .cargo | ||
| 12 | | |- config.toml | ||
| 13 | |- src | ||
| 14 | | |- main.rs | ||
| 15 | |- build.rs | ||
| 16 | |- Cargo.toml | ||
| 17 | |- {memory.x} | ||
| 18 | |- rust-toolchain.toml | ||
| 19 | ---- | ||
| 20 | |||
| 21 | [discrete] | ||
| 22 | == .cargo/config.toml | ||
| 23 | |||
| 24 | This directory/file describes what platform you're on, and configures link:https://github.com/probe-rs/probe-rs[probe-rs] to deploy to your device. | ||
| 25 | |||
| 26 | Here is a minimal example: | ||
| 27 | |||
| 28 | [source,toml] | ||
| 29 | ---- | ||
| 30 | [target.thumbv6m-none-eabi] # <-change for your platform | ||
| 31 | runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip | ||
| 32 | |||
| 33 | [build] | ||
| 34 | target = "thumbv6m-none-eabi" # <-change for your platform | ||
| 35 | |||
| 36 | [env] | ||
| 37 | DEFMT_LOG = "trace" # <- can change to info, warn, or error | ||
| 38 | ---- | ||
| 39 | |||
| 40 | [discrete] | ||
| 41 | == build.rs | ||
| 42 | |||
| 43 | This is the build script for your project. It links defmt (what is link:https://defmt.ferrous-systems.com[defmt]?) and the `memory.x` file if needed. This file is pretty specific for each chipset, just copy and paste from the corresponding link:https://github.com/embassy-rs/embassy/tree/main/examples[example]. | ||
| 44 | |||
| 45 | [discrete] | ||
| 46 | == Cargo.toml | ||
| 47 | |||
| 48 | This is your manifest file, where you can configure all of the embassy components to use the features you need. | ||
| 49 | |||
| 50 | [discrete] | ||
| 51 | === Features | ||
| 52 | |||
| 53 | [discrete] | ||
| 54 | ==== Time | ||
| 55 | - tick-hz-x: Configures the tick rate of `embassy-time`. Higher tick rate means higher precision, and higher CPU wakes. | ||
| 56 | - defmt-timestamp-uptime: defmt log entries will display the uptime in seconds. | ||
| 57 | |||
| 58 | ...more to come | ||
| 59 | |||
| 60 | [discrete] | ||
| 61 | == memory.x | ||
| 62 | |||
| 63 | This file outlines the flash/ram usage of your program. It is especially useful when using link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] on an nRF5x. | ||
| 64 | |||
| 65 | Here is an example for using S140 with an nRF52840: | ||
| 66 | |||
| 67 | [source,x] | ||
| 68 | ---- | ||
| 69 | MEMORY | ||
| 70 | { | ||
| 71 | /* NOTE 1 K = 1 KiBi = 1024 bytes */ | ||
| 72 | /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ | ||
| 73 | FLASH : ORIGIN = 0x00027000, LENGTH = 868K | ||
| 74 | RAM : ORIGIN = 0x20020000, LENGTH = 128K | ||
| 75 | } | ||
| 76 | ---- | ||
| 77 | |||
| 78 | [discrete] | ||
| 79 | == rust-toolchain.toml | ||
| 80 | |||
| 81 | This file configures the rust version and configuration to use. | ||
| 82 | |||
| 83 | A minimal example: | ||
| 84 | |||
| 85 | [source,toml] | ||
| 86 | ---- | ||
| 87 | [toolchain] | ||
| 88 | channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses | ||
| 89 | components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size" | ||
| 90 | targets = [ | ||
| 91 | "thumbv6m-none-eabi" # <-change for your platform | ||
| 92 | ] | ||
| 93 | ---- | ||
