aboutsummaryrefslogtreecommitdiff
path: root/docs/modules/ROOT
diff options
context:
space:
mode:
Diffstat (limited to 'docs/modules/ROOT')
-rw-r--r--docs/modules/ROOT/nav.adoc10
-rw-r--r--docs/modules/ROOT/pages/basic_application.adoc75
-rw-r--r--docs/modules/ROOT/pages/getting_started.adoc59
-rw-r--r--docs/modules/ROOT/pages/hal.adoc8
-rw-r--r--docs/modules/ROOT/pages/nrf.adoc24
-rw-r--r--docs/modules/ROOT/pages/runtime.adoc10
-rw-r--r--docs/modules/ROOT/pages/stm32.adoc3
7 files changed, 180 insertions, 9 deletions
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index dbf9b0bae..98c4ee77f 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -1,4 +1,8 @@
1* xref:runtime.adoc[Executor] 1* xref:runtime.adoc[Runtime]
2* xref:traits.adoc[Async traits] 2* xref:traits.adoc[APIs]
3* xref:hal.adoc[Hardware Interface] 3* xref:hal.adoc[Hardware Abstraction Layer]
4** xref:nrf.adoc[nRF]
5** xref:stm32.adoc[STM32]
6* xref:getting_started.adoc[Getting started]
7** xref:basic_application.adoc[Basic application]
4* xref:examples.adoc[Examples] 8* xref:examples.adoc[Examples]
diff --git a/docs/modules/ROOT/pages/basic_application.adoc b/docs/modules/ROOT/pages/basic_application.adoc
new file mode 100644
index 000000000..d56cb5e1d
--- /dev/null
+++ b/docs/modules/ROOT/pages/basic_application.adoc
@@ -0,0 +1,75 @@
1= A basic Embassy application
2
3So you've got one of the xref:examples.adoc[examples] running, but what now? Let's go through a simple Embassy application for the nRF52 DK to understand it better.
4
5
6== The Cargo.toml
7
8== The main
9
10=== Rust Nightly
11
12The first thing you'll notice is a few declarations stating that Embassy requires some nightly features:
13
14[source,rust]
15----
16#![no_std]
17#![no_main]
18#![feature(type_alias_impl_trait)]
19----
20
21=== Dealing with errors
22
23Then, what follows are some declarations on how to deal with panics and faults. During development, a good practice is to rely on `defmt-rtt` and `panic-probe` to print diagnostics to the terminal:
24
25[source,rust]
26----
27use defmt_rtt as _;
28use panic_probe as _;
29----
30
31=== Task declaration
32
33After a bit of import declaration, the tasks run by the application should be declared:
34
35[source,rust]
36----
37#[embassy::task]
38async fn blinker(led: Output<'static, P0_13>, interval: Duration) {
39 loop {
40 let _ = led.set_high();
41 Timer::after(interval).await;
42 let _ = led.set_low();
43 Timer::after(interval).await;
44 }
45}
46----
47
48An 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.
49
50NOTE: Notice that there is not busy waiting going on in this task. It is using the Embassy timer to yield execution, allowing the microcontroller to sleep in between the blinking.
51
52=== Main
53
54The 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.
55
56The `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:
57
58[source, rust]
59----
60#[embassy::main]
61async fn main(spawner: Spawner, p: Peripherals) {
62 let mut led = Output::new(p.P0_13, Level::Low, OutputDrive::Standard);
63 let _ = spawner.spawn(blinker(led, Duration::from_millis(300)));
64}
65----
66
67
68What 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:
69
70. Creates an Embassy Executor instance
71. Initializes the microcontroller to get the `Peripherals`
72. Defines a main task for the entry point
73. Runs the executor spawning the main task
74
75There is also a way to run the executor without using the macro, in which case you have to create the `Executor` instance yourself.
diff --git a/docs/modules/ROOT/pages/getting_started.adoc b/docs/modules/ROOT/pages/getting_started.adoc
new file mode 100644
index 000000000..760fe8601
--- /dev/null
+++ b/docs/modules/ROOT/pages/getting_started.adoc
@@ -0,0 +1,59 @@
1= Getting started
2
3So you want to try Embassy, great! To get started, there are a few tools you need to install:
4
5* link:https://rustup.rs/[rustup] - the Rust toolchain is needed to compile Rust code.
6* link:https://crates.io/crates/probe-run[probe-run] - to flash the firmware on your device. If you already have other tools like `OpenOCD` setup, you can use that as well.
7
8If you don't have any supported board, don't worry: you can also run embassy on your PC using the `std` examples.
9
10== Getting a board with examples
11
12Embassy supports many microcontroller families, but the easiest ways to get started is if you have one of the more common development kits.
13
14=== nRF kits
15
16* link:https://www.nordicsemi.com/Products/Development-hardware/nrf52-dk[nRF52 DK]
17* link:https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK[nRF9160 DK]
18
19=== STM32 kits
20
21* link:https://www.st.com/en/evaluation-tools/nucleo-h743zi.html[STM32 Nucleo-144 development board with STM32H743ZI MCU]
22* link:https://www.st.com/en/evaluation-tools/nucleo-f429zi.html[STM32 Nucleo-144 development board with STM32F429ZI MCU]
23* link:https://www.st.com/en/evaluation-tools/b-l4s5i-iot01a.html[STM32L4+ Discovery kit IoT node, low-power wireless, BLE, NFC, WiFi]
24* link:https://www.st.com/en/evaluation-tools/b-l072z-lrwan1.html[STM32L0 Discovery kit LoRa, Sigfox, low-power wireless]
25* link:https://www.st.com/en/evaluation-tools/nucleo-wl55jc.html[STM32 Nucleo-64 development board with STM32WL55JCI MCU]
26* link:https://www.st.com/en/evaluation-tools/b-u585i-iot02a.html[Discovery kit for IoT node with STM32U5 series]
27
28
29=== RP2040 kits
30
31* link:https://www.raspberrypi.com/products/raspberry-pi-pico/[Raspberry Pi Pico]
32
33== Running an example
34
35First you need to clone the [github repository];
36
37[source, bash]
38----
39git clone https://github.com/embassy-rs/embassy.git
40cd embassy
41----
42
43You can run an example by opening a terminal and entering the following commands:
44
45[source, bash]
46----
47cd examples/nrf
48DEFMT_LOG=info cargo run --bin blinky --release
49----
50
51IMPORTANT: 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.
52
53== Whats next?
54
55Congratulations, you have your first Embassy application running! Here are some alternatives on where to go from here:
56
57* Read more about the xref:runtime.adoc[runtime].
58* Read more about the xref:hal.adoc[HAL].
59* 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 75dd496c9..8e7fb8dba 100644
--- a/docs/modules/ROOT/pages/hal.adoc
+++ b/docs/modules/ROOT/pages/hal.adoc
@@ -2,8 +2,8 @@
2 2
3Embassy provides HAL's for several microcontroller families: 3Embassy provides HAL's for several microcontroller families:
4 4
5* embassy-nrf for the nRF family of devices from Nordic Semiconductor 5* `embassy-nrf` for the nRF microcontroller sfrom Nordic Semiconductor
6* embassy-stm32 for STM32 family of devices from ST Microelectronics 6* `embassy-stm32` for STM32 microcontrollers from ST Microelectronics
7* embassy-rp for Raspberry Pi Pico 7* `embassy-rp` for the Raspberry Pi RP2040 microcontrollers
8 8
9These HALs provide async/await access to most peripherals while also implementing the async traits in Embassy. 9These HALs implement async/await functionality for most peripherals while also implementing the async traits in Embassy.
diff --git a/docs/modules/ROOT/pages/nrf.adoc b/docs/modules/ROOT/pages/nrf.adoc
index 21c388f61..10fe54b47 100644
--- a/docs/modules/ROOT/pages/nrf.adoc
+++ b/docs/modules/ROOT/pages/nrf.adoc
@@ -1,3 +1,25 @@
1= Embassy nRF HAL 1= Embassy nRF HAL
2 2
3TODO 3The link:https://github.com/embassy-rs/embassy/tree/master/embassy-nrf[Embassy nRF HAL] is based on the PACs (Peripheral Access Crate) from link:https://github.com/nrf-rs/[nrf-rs].
4
5== Timer driver
6
7The nRF timer driver operates at 32768 Hz by default.
8
9== Peripherals
10
11The following peripherals have a HAL implementation at present:
12
13* PWM
14* SPIM
15* QSPI
16* NVMC
17* GPIOTE
18* RNG
19* TIMER
20* WDT
21* TEMP
22* PPI
23* UARTE
24* TWIM
25* SAADC
diff --git a/docs/modules/ROOT/pages/runtime.adoc b/docs/modules/ROOT/pages/runtime.adoc
index 2970bd59e..25feb9c29 100644
--- a/docs/modules/ROOT/pages/runtime.adoc
+++ b/docs/modules/ROOT/pages/runtime.adoc
@@ -20,6 +20,8 @@ IMPORTANT: The executor relies on tasks not blocking indefinitely, as this preve
20 20
21image::embassy_executor.png[Executor model] 21image::embassy_executor.png[Executor model]
22 22
23If you use the `#[embassy::main]` macro in your application, it creates the `Executor` for you and spawns the main entry point as the first task. You can also create the Executor manually, and you can in fact create multiple Executors.
24
23 25
24== Interrupts 26== Interrupts
25 27
@@ -29,10 +31,16 @@ The peripheral HAL then (4) ensures that interrupt signals are routed to to the
29 31
30image::embassy_irq.png[Interrupt handling] 32image::embassy_irq.png[Interrupt handling]
31 33
34NOTE: There exists a special executor named `InterruptExecutor` which can be driven by an interrupt. This can be used to drive tasks at different priority levels by creating multiple `InterruptExecutor` instances.
35
32== Time 36== Time
33 37
34Embassy features an internal timer queue enabled by the `time` feature flag. When enabled, Embassy assumes a time `Driver` implementation existing for the platform. Embassy provides time drivers for the nRF, STM32, RPi Pico, WASM and Std platforms. 38Embassy features an internal timer queue enabled by the `time` feature flag. When enabled, Embassy assumes a time `Driver` implementation existing for the platform. Embassy provides time drivers for the nRF, STM32, RPi Pico, WASM and Std platforms.
35 39
36The timer driver implementations for the embedded platforms support a fixed number of alarms that can be set, which is normally the number of tasks you expect wanting to use the timer at the same time. 40The timer driver implementations for the embedded platforms might support only a fixed number of alarms that can be set. Make sure the number of tasks you expect wanting to use the timer at the same time do not exceed this limit.
41
42The timer speed is configurable at compile time using the `time-tick-<frequency>`. At present, the the timer may be configured to run at 1000 Hz, 32768 Hz, or 1 MHz. Before changing the defaults, make sure the target HAL supports the particular frequency setting.
43
44
37 45
38NOTE: If you do not require timers in your application, not enabling the `time` feature can save some CPU cycles and reduce power usage. 46NOTE: If you do not require timers in your application, not enabling the `time` feature can save some CPU cycles and reduce power usage.
diff --git a/docs/modules/ROOT/pages/stm32.adoc b/docs/modules/ROOT/pages/stm32.adoc
new file mode 100644
index 000000000..328f69e2a
--- /dev/null
+++ b/docs/modules/ROOT/pages/stm32.adoc
@@ -0,0 +1,3 @@
1= Embassy STM32 HAL
2
3TODO