aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT
diff options
context:
space:
mode:
authorBadr Bouslikhin <[email protected]>2024-02-11 19:35:42 +0100
committerGitHub <[email protected]>2024-02-11 19:35:42 +0100
commit2a09996a789af11951131081f0288ddd8b39b126 (patch)
tree36906b503e33f5f414c23347d78415cb4cba25dd /docs/modules/ROOT
parentc95bf6895adfcd33b5238c02620e83c6713205ce (diff)
parentedb3989b577a15bed3d0434f25edc20b6f24bf52 (diff)
Merge branch 'embassy-rs:main' into usb-dfu-erase-then-write
Diffstat (limited to 'docs/modules/ROOT')
-rw-r--r--docs/modules/ROOT/pages/best_practices.adoc6
-rw-r--r--docs/modules/ROOT/pages/faq.adoc12
-rw-r--r--docs/modules/ROOT/pages/new_project.adoc25
-rw-r--r--docs/modules/ROOT/pages/project_structure.adoc9
4 files changed, 36 insertions, 16 deletions
diff --git a/docs/modules/ROOT/pages/best_practices.adoc b/docs/modules/ROOT/pages/best_practices.adoc
index 1e02f9ba9..bfcedec06 100644
--- a/docs/modules/ROOT/pages/best_practices.adoc
+++ b/docs/modules/ROOT/pages/best_practices.adoc
@@ -3,8 +3,10 @@
3Over time, a couple of best practices have emerged. The following list should serve as a guideline for developers writing embedded software in _Rust_, especially in the context of the _Embassy_ framework. 3Over time, a couple of best practices have emerged. The following list should serve as a guideline for developers writing embedded software in _Rust_, especially in the context of the _Embassy_ framework.
4 4
5== Passing Buffers by Reference 5== Passing Buffers by Reference
6It may be tempting to pass arrays or wrappers, like link:https://docs.rs/heapless/latest/heapless/[`heapless::Vec`], to a function or return one just like you would with a `std::Vec`. However, in most embedded applications you don't want to spend ressources on an allocator and end up placing buffers on the stack. 6It may be tempting to pass arrays or wrappers, like link:https://docs.rs/heapless/latest/heapless/[`heapless::Vec`],
7This, however, can easily blow up your stack if you are not careful. 7to a function or return one just like you would with a `std::Vec`. However, in most embedded applications you don't
8want to spend resources on an allocator and end up placing buffers on the stack. This, however, can easily blow up
9your stack if you are not careful.
8 10
9Consider the following example: 11Consider the following example:
10[,rust] 12[,rust]
diff --git a/docs/modules/ROOT/pages/faq.adoc b/docs/modules/ROOT/pages/faq.adoc
index 05ff7c598..7fb81e2ca 100644
--- a/docs/modules/ROOT/pages/faq.adoc
+++ b/docs/modules/ROOT/pages/faq.adoc
@@ -29,11 +29,10 @@ If you see an error like this:
29 29
30You are likely missing some features of the `embassy-executor` crate. 30You are likely missing some features of the `embassy-executor` crate.
31 31
32For Cortex-M targets, consider making sure that ALL of the following features are active in your `Cargo.toml` for the `embassy-executor` crate: 32For Cortex-M targets, check whether ALL of the following features are enabled in your `Cargo.toml` for the `embassy-executor` crate:
33 33
34* `arch-cortex-m` 34* `arch-cortex-m`
35* `executor-thread` 35* `executor-thread`
36* `nightly`
37 36
38For ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. 37For ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate].
39 38
@@ -125,15 +124,18 @@ You have multiple versions of the same crate in your dependency tree. This means
125embassy crates are coming from crates.io, and some from git, each of them pulling in a different set 124embassy crates are coming from crates.io, and some from git, each of them pulling in a different set
126of dependencies. 125of dependencies.
127 126
128To resolve this issue, make sure to only use a single source for all your embassy crates! To do this, 127To resolve this issue, make sure to only use a single source for all your embassy crates!
129you should patch your dependencies to use git sources using `[patch.crates.io]` and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`. 128To do this, you should patch your dependencies to use git sources using `[patch.crates.io]`
129and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`.
130 130
131Example: 131Example:
132 132
133[source,toml] 133[source,toml]
134---- 134----
135[patch.crates-io] 135[patch.crates-io]
136embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" } 136embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" }
137embassy-time-driver = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" }
138# embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" }
137---- 139----
138 140
139Note that the git revision should match any other embassy patches or git dependencies that you are using! 141Note that the git revision should match any other embassy patches or git dependencies that you are using!
diff --git a/docs/modules/ROOT/pages/new_project.adoc b/docs/modules/ROOT/pages/new_project.adoc
index ce139ed8d..320966bb6 100644
--- a/docs/modules/ROOT/pages/new_project.adoc
+++ b/docs/modules/ROOT/pages/new_project.adoc
@@ -1,6 +1,17 @@
1= Starting a new Embassy project 1= Starting a new Embassy project
2 2
3Once you’ve successfully xref:getting_started.adoc[run some example projects], the next step is to make a standalone Embassy project. The easiest way to do this is to adapt an example for a similar chip to the one you’re targeting. 3Once you’ve successfully xref:getting_started.adoc[run some example projects], the next step is to make a standalone Embassy project.
4
5There are some tools for generating Embassy projects: (WIP)
6
7==== CLI
8- link:https://github.com/adinack/cargo-embassy[cargo-embassy] (STM32 and NRF)
9
10==== cargo-generate
11- link:https://github.com/lulf/embassy-template[embassy-template] (STM32, NRF, and RP)
12- link:https://github.com/bentwire/embassy-rp2040-template[embassy-rp2040-template] (RP)
13
14But if you want to start from scratch:
4 15
5As an example, let’s create a new embassy project from scratch for a STM32G474. The same instructions are applicable for any supported chip with some minor changes. 16As an example, let’s create a new embassy project from scratch for a STM32G474. The same instructions are applicable for any supported chip with some minor changes.
6 17
@@ -166,13 +177,13 @@ should result in a blinking LED (if there’s one attached to the pin in `src/ma
166 Erasing sectors ✔ [00:00:00] [#########################################################] 18.00 KiB/18.00 KiB @ 54.09 KiB/s (eta 0s ) 177 Erasing sectors ✔ [00:00:00] [#########################################################] 18.00 KiB/18.00 KiB @ 54.09 KiB/s (eta 0s )
167 Programming pages ✔ [00:00:00] [#########################################################] 17.00 KiB/17.00 KiB @ 35.91 KiB/s (eta 0s ) Finished in 0.817s 178 Programming pages ✔ [00:00:00] [#########################################################] 17.00 KiB/17.00 KiB @ 35.91 KiB/s (eta 0s ) Finished in 0.817s
1680.000000 TRACE BDCR configured: 00008200 1790.000000 TRACE BDCR configured: 00008200
169└─ embassy_stm32::rcc::bd::{impl#3}::init::{closure#4} @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:117 180└─ embassy_stm32::rcc::bd::{impl#3}::init::{closure#4} @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:117
1700.000000 DEBUG rcc: Clocks { sys: Hertz(16000000), pclk1: Hertz(16000000), pclk1_tim: Hertz(16000000), pclk2: Hertz(16000000), pclk2_tim: Hertz(16000000), hclk1: Hertz(16000000), hclk2: Hertz(16000000), pll1_p: None, adc: None, adc34: None, rtc: Some(Hertz(32000)) } 1810.000000 DEBUG rcc: Clocks { sys: Hertz(16000000), pclk1: Hertz(16000000), pclk1_tim: Hertz(16000000), pclk2: Hertz(16000000), pclk2_tim: Hertz(16000000), hclk1: Hertz(16000000), hclk2: Hertz(16000000), pll1_p: None, adc: None, adc34: None, rtc: Some(Hertz(32000)) }
171└─ embassy_stm32::rcc::set_freqs @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:130 182└─ embassy_stm32::rcc::set_freqs @ /home/you/.cargo/git/checkouts/embassy-9312dcb0ed774b29/7703f47/embassy-stm32/src/fmt.rs:130
1720.000000 INFO Hello World! 1830.000000 INFO Hello World!
173└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:14 184└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:14
1740.000091 INFO high 1850.000091 INFO high
175└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:19 186└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:19
1760.300201 INFO low 1870.300201 INFO low
177└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:23 188└─ embassy_stm32g474::____embassy_main_task::{async_fn#0} @ src/main.rs:23
178---- \ No newline at end of file 189----
diff --git a/docs/modules/ROOT/pages/project_structure.adoc b/docs/modules/ROOT/pages/project_structure.adoc
index 61ffd05a6..2adfcc1df 100644
--- a/docs/modules/ROOT/pages/project_structure.adoc
+++ b/docs/modules/ROOT/pages/project_structure.adoc
@@ -38,13 +38,18 @@ DEFMT_LOG = "trace" # <- can change to info, warn, or error
38 38
39== build.rs 39== build.rs
40 40
41This is the build script for your project. It links defmt (what is 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]. 41This 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].
42 42
43== Cargo.toml 43== Cargo.toml
44 44
45This is your manifest file, where you can configure all of the embassy components to use the features you need. 45This is your manifest file, where you can configure all of the embassy components to use the features you need.
46 46
47TODO: someone should exhaustively describe every feature for every component! 47==== Features
48===== Time
49- tick-hz-x: Configures the tick rate of `embassy-time`. Higher tick rate means higher precision, and higher CPU wakes.
50- defmt-timestamp-uptime: defmt log entries will display the uptime in seconds.
51
52...more to come
48 53
49== memory.x 54== memory.x
50 55