aboutsummaryrefslogtreecommitdiff
path: root/docs/pages/project_structure.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'docs/pages/project_structure.adoc')
-rw-r--r--docs/pages/project_structure.adoc93
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
3There 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
5The toplevel file structure of your project should look like this:
6[source,plain]
7----
8{} = Maybe
9
10my-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
24This 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
26Here is a minimal example:
27
28[source,toml]
29----
30[target.thumbv6m-none-eabi] # <-change for your platform
31runner = 'probe-rs run --chip STM32F031K6Tx' # <- change for your chip
32
33[build]
34target = "thumbv6m-none-eabi" # <-change for your platform
35
36[env]
37DEFMT_LOG = "trace" # <- can change to info, warn, or error
38----
39
40[discrete]
41== build.rs
42
43This 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
48This 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
63This 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
65Here is an example for using S140 with an nRF52840:
66
67[source,x]
68----
69MEMORY
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
81This file configures the rust version and configuration to use.
82
83A minimal example:
84
85[source,toml]
86----
87[toolchain]
88channel = "nightly-2023-08-19" # <- as of writing, this is the exact rust version embassy uses
89components = [ "rust-src", "rustfmt" ] # <- optionally add "llvm-tools-preview" for some extra features like "cargo size"
90targets = [
91 "thumbv6m-none-eabi" # <-change for your platform
92]
93----