aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorQuentin Smith <[email protected]>2022-08-19 00:53:06 -0400
committerQuentin Smith <[email protected]>2022-08-19 00:53:41 -0400
commit71e468681b1c074e06276d34ff00e36169c632f5 (patch)
treece86220caabbdc044720df8efb23de7bc4c36ea0 /docs
parent2edf532f8d8ce048137990bf74b07759428ed7c1 (diff)
parentaefa5275a2ab2cac6caef599e7adb76ce1beeddd (diff)
Merge branch 'master' of https://github.com/embassy-rs/embassy into rtos-trace
Diffstat (limited to 'docs')
-rw-r--r--docs/antora.yml2
-rw-r--r--docs/modules/ROOT/examples/basic/Cargo.toml1
-rw-r--r--docs/modules/ROOT/examples/basic/src/main.rs9
-rw-r--r--docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs6
-rw-r--r--docs/modules/ROOT/images/bootloader_flash.pngbin0 -> 32147 bytes
-rw-r--r--docs/modules/ROOT/nav.adoc12
-rw-r--r--docs/modules/ROOT/pages/basic_application.adoc20
-rw-r--r--docs/modules/ROOT/pages/bootloader.adoc5
-rw-r--r--docs/modules/ROOT/pages/getting_started.adoc6
-rw-r--r--docs/modules/ROOT/pages/hal.adoc5
-rw-r--r--docs/modules/ROOT/pages/index.adoc18
-rw-r--r--docs/modules/ROOT/pages/runtime.adoc4
-rw-r--r--docs/modules/ROOT/pages/traits.adoc8
13 files changed, 53 insertions, 43 deletions
diff --git a/docs/antora.yml b/docs/antora.yml
index 807c97c3f..9a00fa820 100644
--- a/docs/antora.yml
+++ b/docs/antora.yml
@@ -1,4 +1,4 @@
1name: embassy 1name: ROOT
2title: Embassy 2title: Embassy
3version: dev 3version: dev
4nav: 4nav:
diff --git a/docs/modules/ROOT/examples/basic/Cargo.toml b/docs/modules/ROOT/examples/basic/Cargo.toml
index 59e1a437a..ae124a871 100644
--- a/docs/modules/ROOT/examples/basic/Cargo.toml
+++ b/docs/modules/ROOT/examples/basic/Cargo.toml
@@ -6,6 +6,7 @@ version = "0.1.0"
6 6
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] } 8embassy-executor = { version = "0.1.0", path = "../../../../../embassy-executor", features = ["defmt", "nightly"] }
9embassy-time = { version = "0.1.0", path = "../../../../../embassy-time", features = ["defmt", "nightly"] }
9embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] } 10embassy-nrf = { version = "0.1.0", path = "../../../../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "nightly"] }
10 11
11defmt = "0.3" 12defmt = "0.3"
diff --git a/docs/modules/ROOT/examples/basic/src/main.rs b/docs/modules/ROOT/examples/basic/src/main.rs
index cec39fd91..04170db55 100644
--- a/docs/modules/ROOT/examples/basic/src/main.rs
+++ b/docs/modules/ROOT/examples/basic/src/main.rs
@@ -3,11 +3,10 @@
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_executor::time::{Duration, Timer};
8use embassy_nrf::gpio::{Level, Output, OutputDrive}; 7use embassy_nrf::gpio::{Level, Output, OutputDrive};
9use embassy_nrf::peripherals::P0_13; 8use embassy_nrf::peripherals::P0_13;
10use embassy_nrf::Peripherals; 9use embassy_time::{Duration, Timer};
11use {defmt_rtt as _, panic_probe as _}; // global logger 10use {defmt_rtt as _, panic_probe as _}; // global logger
12 11
13#[embassy_executor::task] 12#[embassy_executor::task]
@@ -21,7 +20,9 @@ async fn blinker(mut led: Output<'static, P0_13>, interval: Duration) {
21} 20}
22 21
23#[embassy_executor::main] 22#[embassy_executor::main]
24async fn main(spawner: Spawner, p: Peripherals) { 23async fn main(spawner: Spawner) {
24 let p = embassy_nrf::init(Default::default());
25
25 let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard); 26 let led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
26 unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300)))); 27 unwrap!(spawner.spawn(blinker(led, Duration::from_millis(300))));
27} 28}
diff --git a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
index b944a7994..8df632240 100644
--- a/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
+++ b/docs/modules/ROOT/examples/layer-by-layer/blinky-async/src/main.rs
@@ -2,14 +2,14 @@
2#![no_main] 2#![no_main]
3#![feature(type_alias_impl_trait)] 3#![feature(type_alias_impl_trait)]
4 4
5use embassy_executor::executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::exti::ExtiInput; 6use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 7use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
8use embassy_stm32::Peripherals;
9use {defmt_rtt as _, panic_probe as _}; 8use {defmt_rtt as _, panic_probe as _};
10 9
11#[embassy_executor::main] 10#[embassy_executor::main]
12async fn main(_s: Spawner, p: Peripherals) { 11async fn main(_spawner: Spawner) {
12 let p = embassy_stm32::init(Default::default());
13 let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh); 13 let mut led = Output::new(p.PB14, Level::Low, Speed::VeryHigh);
14 let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13); 14 let mut button = ExtiInput::new(Input::new(p.PC13, Pull::Up), p.EXTI13);
15 15
diff --git a/docs/modules/ROOT/images/bootloader_flash.png b/docs/modules/ROOT/images/bootloader_flash.png
new file mode 100644
index 000000000..635783b05
--- /dev/null
+++ b/docs/modules/ROOT/images/bootloader_flash.png
Binary files differ
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index a45da1958..86f2996f1 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -1,10 +1,10 @@
1* xref:runtime.adoc[Runtime]
2* xref:traits.adoc[APIs]
3* xref:hal.adoc[Hardware Abstraction Layer]
4** xref:nrf.adoc[nRF]
5** xref:stm32.adoc[STM32]
6* xref:bootloader.adoc[Bootloader]
7* xref:getting_started.adoc[Getting started] 1* xref:getting_started.adoc[Getting started]
8** xref:basic_application.adoc[Basic application] 2** xref:basic_application.adoc[Basic application]
9** xref:layer_by_layer.adoc[Layer by Layer] 3** xref:layer_by_layer.adoc[Layer by Layer]
4* xref:runtime.adoc[Executor]
5* xref:hal.adoc[HAL]
6** xref:nrf.adoc[nRF]
7** xref:stm32.adoc[STM32]
8* xref:bootloader.adoc[Bootloader]
9
10* xref:examples.adoc[Examples] 10* xref:examples.adoc[Examples]
diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc
index a8875aa93..4dc4a6359 100644
--- a/docs/modules/ROOT/pages/basic_application.adoc
+++ b/docs/modules/ROOT/pages/basic_application.adoc
@@ -21,7 +21,7 @@ Then, what follows are some declarations on how to deal with panics and faults.
21 21
22[source,rust] 22[source,rust]
23---- 23----
24include::example$basic/src/main.rs[lines="5..6"] 24include::example$basic/src/main.rs[lines="11..12"]
25---- 25----
26 26
27=== Task declaration 27=== Task declaration
@@ -30,7 +30,7 @@ After a bit of import declaration, the tasks run by the application should be de
30 30
31[source,rust] 31[source,rust]
32---- 32----
33include::example$basic/src/main.rs[lines="18..27"] 33include::example$basic/src/main.rs[lines="13..22"]
34---- 34----
35 35
36An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking. 36An embassy task must be declared `async`, and may NOT take generic arguments. In this case, we are handed the LED that should be blinked and the interval of the blinking.
@@ -39,32 +39,32 @@ NOTE: Notice that there is no busy waiting going on in this task. It is using th
39 39
40=== Main 40=== Main
41 41
42The main entry point of an Embassy application is defined using the `#[embassy::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument. 42The main entry point of an Embassy application is defined using the `#[embassy_executor::main]` macro. The entry point is also required to take a `Spawner` and a `Peripherals` argument.
43 43
44The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED: 44The `Spawner` is the way the main application spawns other tasks. The `Peripherals` type comes from the HAL and holds all peripherals that the application may use. In this case, we want to configure one of the pins as a GPIO output driving the LED:
45 45
46[source,rust] 46[source,rust]
47---- 47----
48include::example$basic/src/main.rs[lines="28..-1"] 48include::example$basic/src/main.rs[lines="23..-1"]
49---- 49----
50 50
51`#[embassy::main]` takes an optional `config` paramter specifying a function that returns an instance of HAL's `Config` struct. For example: 51`#[embassy_executor::main]` takes an optional `config` parameter specifying a function that returns an instance of HAL's `Config` struct. For example:
52 52
53```rust 53```rust
54fn embassy_config() -> embassy_nrf::config::Config { 54fn embassy_config() -> embassy_nrf::config::Config {
55 embassy_nrf::config::Config::default() 55 embassy_nrf::config::Config::default()
56} 56}
57 57
58#[embassy::main(config = "embassy_config()")] 58#[embassy_executor::main(config = "embassy_config()")]
59async fn main(_spawner: embassy::executor::Spawner, p: embassy_nrf::Peripherals) { 59async fn main(_spawner: Spawner, p: embassy_nrf::Peripherals) {
60 // ... 60 // ...
61} 61}
62``` 62```
63 63
64What happens when the `blinker` task have been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following: 64What happens when the `blinker` task have been spawned and main returns? Well, the main entry point is actually just like any other task, except that you can only have one and it takes some specific type arguments. The magic lies within the `#[embassy::main]` macro. The macro does the following:
65 65
66. Creates an Embassy Executor instance 66. Creates an Embassy Executor
67. Initializes the microcontroller to get the `Peripherals` 67. Initializes the microcontroller HAL to get the `Peripherals`
68. Defines a main task for the entry point 68. Defines a main task for the entry point
69. Runs the executor spawning the main task 69. Runs the executor spawning the main task
70 70
diff --git a/docs/modules/ROOT/pages/bootloader.adoc b/docs/modules/ROOT/pages/bootloader.adoc
index 3df2daf51..ae92e9d5d 100644
--- a/docs/modules/ROOT/pages/bootloader.adoc
+++ b/docs/modules/ROOT/pages/bootloader.adoc
@@ -20,7 +20,10 @@ In general, the bootloader works on any platform that implements the `embedded-s
20 20
21== Design 21== Design
22 22
23The bootloader divides the storage into 4 main partitions, configured by a linker script: 23image::bootloader_flash.png[Bootloader flash layout]
24
25The bootloader divides the storage into 4 main partitions, configurable when creating the bootloader
26instance or via linker scripts:
24 27
25* BOOTLOADER - Where the bootloader is placed. The bootloader itself consumes about 8kB of flash. 28* BOOTLOADER - Where the bootloader is placed. The bootloader itself consumes about 8kB of flash.
26* ACTIVE - Where the main application is placed. The bootloader will attempt to load the application at the start of this partition. This partition is only written to by the bootloader. 29* ACTIVE - Where the main application is placed. The bootloader will attempt to load the application at the start of this partition. This partition is only written to by the bootloader.
diff --git a/docs/modules/ROOT/pages/getting_started.adoc b/docs/modules/ROOT/pages/getting_started.adoc
index 23102b3b5..f3492a3d0 100644
--- a/docs/modules/ROOT/pages/getting_started.adoc
+++ b/docs/modules/ROOT/pages/getting_started.adoc
@@ -46,15 +46,13 @@ You can run an example by opening a terminal and entering the following commands
46[source, bash] 46[source, bash]
47---- 47----
48cd examples/nrf 48cd examples/nrf
49DEFMT_LOG=info cargo run --bin blinky --release 49cargo run --bin blinky --release
50---- 50----
51 51
52IMPORTANT: The DEFMT_LOG environment variable controls the example log verbosity. If you do not specify it, you will not see anything logged to the console.
53
54== Whats next? 52== Whats next?
55 53
56Congratulations, you have your first Embassy application running! Here are some alternatives on where to go from here: 54Congratulations, you have your first Embassy application running! Here are some alternatives on where to go from here:
57 55
58* Read more about the xref:runtime.adoc[runtime]. 56* Read more about the xref:runtime.adoc[executor].
59* Read more about the xref:hal.adoc[HAL]. 57* Read more about the xref:hal.adoc[HAL].
60* Start xref:basic_application.adoc[writing your application]. 58* Start xref:basic_application.adoc[writing your application].
diff --git a/docs/modules/ROOT/pages/hal.adoc b/docs/modules/ROOT/pages/hal.adoc
index 0b15e2fce..de4ab33be 100644
--- a/docs/modules/ROOT/pages/hal.adoc
+++ b/docs/modules/ROOT/pages/hal.adoc
@@ -1,9 +1,10 @@
1= Hardware Abstraction Layer (HAL) 1= Hardware Abstraction Layer (HAL)
2 2
3Embassy provides HAL's for several microcontroller families: 3Embassy provides HALs for several microcontroller families:
4 4
5* `embassy-nrf` for the nRF microcontrollers from Nordic Semiconductor 5* `embassy-nrf` for the nRF microcontrollers from Nordic Semiconductor
6* `embassy-stm32` for STM32 microcontrollers from ST Microelectronics 6* `embassy-stm32` for STM32 microcontrollers from ST Microelectronics
7* `embassy-rp` for the Raspberry Pi RP2040 microcontrollers 7* `embassy-rp` for the Raspberry Pi RP2040 microcontrollers
8 8
9These HALs implement async/await functionality for most peripherals while also implementing the async traits in Embassy. 9These HALs implement async/await functionality for most peripherals while also implementing the
10async traits in `embedded-hal-async`. You can also use these HALs with another executor.
diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc
index 9a14e465d..0a17c6739 100644
--- a/docs/modules/ROOT/pages/index.adoc
+++ b/docs/modules/ROOT/pages/index.adoc
@@ -15,6 +15,20 @@ In Rust, non-blocking operations can be implemented using async-await. Async-awa
15 15
16== What is Embassy? 16== What is Embassy?
17 17
18Embassy is an executor and a Hardware Access Layer (HAL). The executor is a scheduler that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The HAL is an API that you can use to access peripherals, such as USART, UART, I2C, SPI, CAN, and USB. Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. 18The Embassy project consists of several crates that you can use together or independently:
19 19
20Embassy may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing. 20* **Executor** - The link:https://docs.embassy.dev/embassy-executor/[embassy-executor] is an async/await executor that generally executes a fixed number of tasks, allocated at startup, though more can be added later. The HAL is an API that you can use to access peripherals, such as USART, UART, I2C, SPI, CAN, and USB. Embassy provides implementations of both async and blocking APIs where it makes sense. DMA (Direct Memory Access) is an example where async is a good fit, whereas GPIO states are a better fit for a blocking API. The executor may also provide a system timer that you can use for both async and blocking delays. For less than one microsecond, blocking delays should be used because the cost of context-switching is too high and the executor will be unable to provide accurate timing.
21
22* **Hardware Abstraction Layers** - HALs implement safe, idiomatic Rust APIs to use the hardware capabilities, so raw register manipulation is not needed. The Embassy project maintains HALs for select hardware, but you can still use HALs from other projects with Embassy.
23** link:https://docs.embassy.dev/embassy-stm32/[embassy-stm32], for all STM32 microcontroller families.
24** link:https://docs.embassy.dev/embassy-nrf/[embassy-nrf], for the Nordic Semiconductor nRF52, nRF53, nRF91 series.
25
26* **Networking** - The link:https://docs.embassy.dev/embassy-net/[embassy-net] network stack implements extensive networking functionality, including Ethernet, IP, TCP, UDP, ICMP and DHCP. Async drastically simplifies managing timeouts and serving multiple connections concurrently.
27
28* **Bluetooth** - The link:https://github.com/embassy-rs/nrf-softdevice[nrf-softdevice] crate provides Bluetooth Low Energy 4.x and 5.x support for nRF52 microcontrollers.
29
30* **LoRa** - link:https://docs.embassy.dev/embassy-lora/[embassy-lora] supports LoRa networking on STM32WL wireless microcontrollers and Semtech SX127x transceivers.
31
32* **USB** - link:https://docs.embassy.dev/embassy-usb/[embassy-usb] implements a device-side USB stack. Implementations for common classes such as USB serial (CDC ACM) and USB HID are available, and a rich builder API allows building your own.
33
34* **Bootloader and DFU** - link:https://github.com/embassy-rs/embassy/tree/master/embassy-boot[embassy-boot] is a lightweight bootloader supporting firmware application upgrades in a power-fail-safe way, with trial boots and rollbacks.
diff --git a/docs/modules/ROOT/pages/runtime.adoc b/docs/modules/ROOT/pages/runtime.adoc
index 0adaa21a0..a7d6a8d0c 100644
--- a/docs/modules/ROOT/pages/runtime.adoc
+++ b/docs/modules/ROOT/pages/runtime.adoc
@@ -1,6 +1,6 @@
1= Embassy runtime 1= Embassy executor
2 2
3The Embassy runtime is an async/await executor designed for embedded usage along with support functionality for interrupts and timers. 3The Embassy executor is an async/await executor designed for embedded usage along with support functionality for interrupts and timers.
4 4
5== Features 5== Features
6 6
diff --git a/docs/modules/ROOT/pages/traits.adoc b/docs/modules/ROOT/pages/traits.adoc
deleted file mode 100644
index 38b8f2862..000000000
--- a/docs/modules/ROOT/pages/traits.adoc
+++ /dev/null
@@ -1,8 +0,0 @@
1= Embassy Traits
2
3Embassy provides a set of traits and types specifically designed for `async` usage. Many of these futures will be upstreamed to the `embedded-hal` crate at some point in the future, probably when the required GAT (Generic Associated Types) feature is stabilized in Rust.
4
5* `embassy::io`: `AsyncBufRead`, `AsyncWrite`. Traits for byte-stream IO, essentially `no_std` compatible versions of `futures::io`. The primary reason for re-defining these traits is that the `futures::io` variant requires `std::io::Error`, which does not work in the `no_std` environment.
6* `embassy::time`: Time `Driver` trait that is implemented for different platforms. Time in Embassy is represented using the `Duration` and `Instant` types.
7
8These traits are implemented by the platform-specific crates, such as `embassy-nrf` or `embassy-stm32`.