Skip to content

Commit 4bc4bfa

Browse files
Merge #246
246: Add readme documentation for demos r=thejpster a=ninjasource Hi, I've recently worked through all the demos and took notes as I was going. I thought it may be useful to add those notes to this repo if appropriate. I'm not sure if this is the correct place to put them but adding a `README.md` file to the examples folder confuses cargo builds for some reason. I hope that this will be useful as I was not familiar with all the acronyms in the project and I think that newcomers will find this quick reference useful too. Co-authored-by: David Haig <[email protected]> Co-authored-by: David Haig <[email protected]>
2 parents b2e5b97 + 059ee47 commit 4bc4bfa

File tree

19 files changed

+207
-11
lines changed

19 files changed

+207
-11
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,49 @@ at your option.
5151
Unless you explicitly state otherwise, any contribution intentionally submitted
5252
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
5353
dual licensed as above, without any additional terms or conditions.
54+
55+
## Summary of the Examples
56+
57+
Here follows a brief description of each demo for quick reference. For a more in-depth explanation on how the peripherals work please refer to the device reference manuals linked above, the readme for each demo and the comments in the demo code itself.
58+
59+
| Demo | Category | Description |
60+
|-------------------------------------------------------|-------------------|-----------------------------------------------------------------------|
61+
| [blinky-button-demo](./examples/blinky-button-demo/README.md) | Hello World | Blinky button demo |
62+
| [ccm-demo](./examples/ccm-demo/README.md) | Encryption | Cipher block chaining - message authentication code (CCM) mode demo |
63+
| [comp-demo](./examples/comp-demo/README.md) | Analog Pins | Voltage comparator peripheral demo |
64+
| [ecb-demo](./examples/ecb-demo/README.md) | Encryption | AES electronic codebook mode encryption demo |
65+
| [gpiote-demo](./examples/gpiote-demo/README.md) | Digital Pins | General-Purpose Input Output Tasks and Events module demo |
66+
| [i2s-controller-demo](./examples/i2s-controller-demo/README.md)| Audio | Inter-IC Sound interface "controller mode (aka master mode)" demo |
67+
| [i2s-peripheral-demo](./examples/i2s-peripheral-demo/README.md)| Audio | Inter-IC Sound interface "peripheral mode (aka slave mode)" demo |
68+
| [lpcomp-demo](./examples/lpcomp-demo/README.md) | Analog Pins | Low power voltage comparator demo |
69+
| [ppi-demo](./examples/ppi-demo/README.md) | Channels | Programmable peripheral interconnect (PPI) demo |
70+
| [pwm-demo](./examples/pwm-demo/README.md) | Digital Pins | Pulse width modulation demo |
71+
| [qdec-demo](./examples/qdec-demo/README.md) | Sensor Decoding | Quadrature sensor decoder (QDEC) demo |
72+
| [rtic-demo](./examples/rtic-demo/README.md) | Framework | The Real-Time Interrupt-driven Concurrency framework demo |
73+
| [spi-demo](./examples/spi-demo/README.md) | Digital Pins | Serial peripheral interface master (SPIM) with EasyDMA demo |
74+
| [spis-demo](./examples/spis-demo/README.md) | Digital Pins | Serial peripheral interface slave (SPIS) demo |
75+
| [twi-ssd1306](./examples/twi-ssd1306/README.md) | Digital Pins | I2C compatible Two-Wire Interface with the SSD1306 OLED Display demo |
76+
| [twim-demo](./examples/twim-demo/README.md) | Digital Pins | I2C compatible Two-Wire Interface Master mode demo |
77+
| [twis-demo](./examples/twis-demo/README.md) | Digital Pins | I2C compatible Two-Wire Interface Slave mode demo |
78+
| [wdt-demo](./examples/wdt-demo/README.md) | Timer | Watchdog timer demo |
79+
80+
81+
## Running the Examples
82+
83+
Each demo readme should contain instructions on how to run it. However, the information below describes the technologies used and can be used to troubleshoot your system setup. Run the demos from within their respective project directories. E.g. to run `ccm-demo`, you must be in the `nrf-hal/examples/ccm-demo/` directory.
84+
> Since the demos are stand-alone projects you would **NOT** typically run them with `cargo run --example xyz-demo` like some cargo projects are configured to do.
85+
86+
### Once Off System Setup
87+
88+
Install the cross compilation toolchain to target your device. You would typically pass the target as a parameter to cargo or explicitly set it in your cargo config file. If you get compilation errors about `eh_personality` then you have not set the target correctly. Here is an example of the target for a nRF52840 chip:
89+
```console
90+
$ rustup target add thumbv7em-none-eabihf
91+
```
92+
Install the tools to flash the device.
93+
```console
94+
$ cargo install cargo-embed
95+
```
96+
97+
### For Every Project (optional)
98+
99+
Setup the `Cargo.toml` file to use the correct features. Features allow for conditional compilation which is essential for a library like this that supports multiple different devices. Under the `[features]` section add the following line `default = ["52840"]` for the nRF52840-DK device or whatever other feature is applicable for your device. This is optional but it will allow you to simply call `cargo run` and `cargo build` instead of `cargo run --features 52840` and `cargo build --features 52840` respectively. Note that some demo projects do not have features so this step may not be necessary. If you get a whole bunch of compilation errors or plugins like rust-analyzer are not working then check that you have set the chip features correctly.

examples/blinky-button-demo/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Blinky button demo
22

3-
This example turns on LED 1 when you press Button 1 on the nrf52-dk (PCA10040).
3+
This hello world example turns on LED 1 when you press Button 1 on the nrf52-dk (PCA10040).
4+
> Note: You will have to change the pin numbers if you use a different device.
45
56
## Set up with `cargo-embed`
67

examples/ccm-demo/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# AES-CCM demo
1+
# CCM encryption demo
2+
3+
This CCM (cipher block chaining) encryption demo initialises a text message of the maximum size of 251 bytes and encrypts and decrypts it, measuring the time it takes. It then repeats the process with smaller and smaller chunks of data to demonstrate how long smaller packets take to process.
4+
5+
## How to run
26

37
Choose the microcontroller with one of the following features:
48
- 52810

examples/comp-demo/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Comp demo
2+
3+
This demo uses the Comparator (comp) peripheral to compare the differential voltages between two pins. If the voltage on Pin 30 is higher than Pin 31 (reference voltage) the built in LED will switch off otherwise it will switch on. The demo uses `nrf52840-hal` but this can be swapped out with an alternative if required.
4+
5+
## How to run
6+
7+
If using `cargo-embed`, just run
8+
9+
```console
10+
$ cargo embed --release --target=thumbv7em-none-eabihf
11+
```

examples/ecb-demo/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# AES electronic codebook mode encryption demo
1+
# ECB encryption demo
2+
3+
The AES electronic codebook mode (ECB) demo demonstrates a blocking 128-bit AES encryption of 16 bytes of data using a 16 byte key. Encryption only, no decryption.
4+
5+
## How to run
26

37
Choose the microcontroller with one of the following features:
48
- 51

examples/gpiote-demo/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Gpiote demo
2+
3+
The General-Purpose Input Output Tasks and Events (gpiote) module demo targets the nRF52840-DK in particular because of the 4 available hardware buttons on the board itself. The demo shows how you can use the `cortex-m-rtic` crate to easily debounce some buttons without blocking the CPU. GPIO pin state changes fire events which can be used to carry out tasks. This showcases the PPI (programmable peripheral interconnect) system for which there is also a dedicated demo.
4+
5+
## How to run
6+
7+
If using `cargo-embed`, just run
8+
9+
```console
10+
$ cargo embed --release --target=thumbv7em-none-eabihf
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# I2S controller demo
2+
3+
The Inter-IC Sound interface (I2S) controller mode (aka master mode) demo. This demo generates Morse code audio signals from text received over UART and plays them back over I2S. Tested with nRF52840-DK and a UDA1334a DAC.
4+
5+
## How to run
6+
7+
If using `cargo-embed`, just run
8+
9+
```console
10+
$ cargo embed --release --target=thumbv7em-none-eabihf
11+
```
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# I2S peripheral demo
2+
3+
The Inter-IC Sound interface (I2S) peripheral mode (aka slave mode) demo. This demonstrates full duplex communication between a controller and peripheral mode I2S peripheral using the EasyDMA capabilities of the chip. This targets the nrf52840 family of devices.
4+
5+
## How to run
6+
7+
If using `cargo-embed`, just run
8+
9+
```console
10+
$ cargo embed --release --target=thumbv7em-none-eabihf
11+
```

examples/lpcomp-demo/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Lpcomp demo
2+
3+
This low power voltage comparator (lpcomp) demo shows how you would keep the device in low power mode and power it up when an analog voltage on a pin changes with respect to a voltage on a reference pin. This targets the nrf52840 family of devices.
4+
5+
## How to run
6+
7+
If using `cargo-embed`, just run
8+
9+
```console
10+
$ cargo embed --release --target=thumbv7em-none-eabihf
11+
```

examples/ppi-demo/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Programmable peripheral interconnect demo
1+
# PPI demo
2+
3+
The Programmable Peripheral Interconnect (PPI) allows peripherals to interact with each other without having to go through the CPU. Note that you need to choose a chip feature in order for this demo to build. See above. This demo uses the Bluetooth RADIO peripheral as an example but does nothing special with Bluetooth itself so this is not the demo to learn about that capability.
4+
5+
## How to run
26

37
Choose the microcontroller with one of the following features:
48
- 51

0 commit comments

Comments
 (0)