diff options
Diffstat (limited to 'docs/modules')
| -rw-r--r-- | docs/modules/ROOT/pages/best_practices.adoc | 6 | ||||
| -rw-r--r-- | docs/modules/ROOT/pages/faq.adoc | 12 | ||||
| -rw-r--r-- | docs/modules/ROOT/pages/new_project.adoc | 25 | ||||
| -rw-r--r-- | docs/modules/ROOT/pages/project_structure.adoc | 9 |
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 @@ | |||
| 3 | Over 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. | 3 | Over 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 |
| 6 | It 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. | 6 | It may be tempting to pass arrays or wrappers, like link:https://docs.rs/heapless/latest/heapless/[`heapless::Vec`], |
| 7 | This, however, can easily blow up your stack if you are not careful. | 7 | to a function or return one just like you would with a `std::Vec`. However, in most embedded applications you don't |
| 8 | want to spend resources on an allocator and end up placing buffers on the stack. This, however, can easily blow up | ||
| 9 | your stack if you are not careful. | ||
| 8 | 10 | ||
| 9 | Consider the following example: | 11 | Consider 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 | ||
| 30 | You are likely missing some features of the `embassy-executor` crate. | 30 | You are likely missing some features of the `embassy-executor` crate. |
| 31 | 31 | ||
| 32 | For Cortex-M targets, consider making sure that ALL of the following features are active in your `Cargo.toml` for the `embassy-executor` crate: | 32 | For 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 | ||
| 38 | For ESP32, consider using the executors and `#[main]` macro provided by your appropriate link:https://crates.io/crates/esp-hal-common[HAL crate]. | 37 | For 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 | |||
| 125 | embassy crates are coming from crates.io, and some from git, each of them pulling in a different set | 124 | embassy crates are coming from crates.io, and some from git, each of them pulling in a different set |
| 126 | of dependencies. | 125 | of dependencies. |
| 127 | 126 | ||
| 128 | To resolve this issue, make sure to only use a single source for all your embassy crates! To do this, | 127 | To resolve this issue, make sure to only use a single source for all your embassy crates! |
| 129 | you should patch your dependencies to use git sources using `[patch.crates.io]` and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`. | 128 | To do this, you should patch your dependencies to use git sources using `[patch.crates.io]` |
| 129 | and maybe `[patch.'https://github.com/embassy-rs/embassy.git']`. | ||
| 130 | 130 | ||
| 131 | Example: | 131 | Example: |
| 132 | 132 | ||
| 133 | [source,toml] | 133 | [source,toml] |
| 134 | ---- | 134 | ---- |
| 135 | [patch.crates-io] | 135 | [patch.crates-io] |
| 136 | embassy-time = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" } | 136 | embassy-time-queue-driver = { git = "https://github.com/embassy-rs/embassy.git", rev = "e5fdd35" } |
| 137 | embassy-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 | ||
| 139 | Note that the git revision should match any other embassy patches or git dependencies that you are using! | 141 | Note 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 | ||
| 3 | Once 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. | 3 | Once you’ve successfully xref:getting_started.adoc[run some example projects], the next step is to make a standalone Embassy project. |
| 4 | |||
| 5 | There 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 | |||
| 14 | But if you want to start from scratch: | ||
| 4 | 15 | ||
| 5 | As 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. | 16 | As 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 |
| 168 | 0.000000 TRACE BDCR configured: 00008200 | 179 | 0.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 |
| 170 | 0.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)) } | 181 | 0.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 |
| 172 | 0.000000 INFO Hello World! | 183 | 0.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 |
| 174 | 0.000091 INFO high | 185 | 0.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 |
| 176 | 0.300201 INFO low | 187 | 0.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 | ||
| 41 | This 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]. | 41 | 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]. |
| 42 | 42 | ||
| 43 | == Cargo.toml | 43 | == Cargo.toml |
| 44 | 44 | ||
| 45 | This is your manifest file, where you can configure all of the embassy components to use the features you need. | 45 | This is your manifest file, where you can configure all of the embassy components to use the features you need. |
| 46 | 46 | ||
| 47 | TODO: 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 | ||
