### Install probe-rs-tools for Flashing Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/README.md Installs the probe-rs-tools, a command-line utility used for flashing embedded devices. This tool is required to upload your compiled firmware to the nRF microcontroller. ```console cargo install probe-rs-tools ``` -------------------------------- ### Release Process Setup (Unix) Source: https://github.com/nrf-rs/nrf-hal/blob/master/CONTRIBUTING.md Steps to prepare the workspace for releasing new versions of the HALs, involving backing up and activating specific Cargo.toml files. ```bash mv Cargo.toml Cargo.my.toml cp Cargo.ci.toml Cargo.toml ``` -------------------------------- ### Cargo.toml Features Setup Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/README.md Configures Cargo.toml to use device-specific features for conditional compilation. Setting a default feature simplifies build commands. ```toml [features] default = ["52840"] ``` -------------------------------- ### nrf-hal Development Setup Source: https://github.com/nrf-rs/nrf-hal/blob/master/README.md Instructions for setting up the development environment for nrf-hal projects, including copying and editing `Cargo.example.toml` and `.vscode/settings.json` for target configuration. ```toml # Example Cargo.toml configuration # Copy and edit this file based on your target [package] name = "my-nrf-project" version = "0.1.0" authors = ["Your Name "] edition = "2021" [dependencies] # Specify the nrf-hal crate for your target, e.g.: # nrf52840-hal = { version = "0.15.0", features = ["panic-halt"] } # Example for nRF52840 nrf52840-hal = { version = "0.15.0", features = ["panic-halt"] } [profile.release] # Optimize for size opt-level = "s" # Example .vscode/settings.json configuration for Visual Studio Code # Adjust "rust-analyzer.target" based on your chosen nRF target # { # "rust-analyzer.target": "thumbv7em-none-eabihf", # "rust-analyzer.checkOnSave": true # } ``` -------------------------------- ### HAL Test Environment Setup Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf52840-hal-tests/README.md Instructions for setting up the testing environment, including navigating to the correct directory and considerations for different development boards by modifying probe-run configurations. ```bash cd nrf52840-hal-tests ``` -------------------------------- ### Install Rust Target Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf9160-hal/README.md Installs the required `thumbv8m.main-none-eabihf` target for the Nordic nRF9160 development. ```console $ rustup target add thumbv8m.main-none-eabihf ``` -------------------------------- ### Running the PWM Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/pwm-demo/README.md This command executes the PWM demo using cargo-embed, targeting the thumbv7em-none-eabihf architecture in release mode. Ensure you have cargo-embed installed and the nRF52840-DK connected. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### ELF to Intel HEX Conversion and Flashing Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/README.md Demonstrates converting a compiled ELF file to Intel HEX format and copying it to an Mbed-enabled programmer's USB storage for flashing. ```bash cargo build --target thumbv7em-none-eabihf arm-none-eabi-objcopy -O ihex target/thumbv7em-none-eabihf/debug/blinky-button-demo.elf /media/${USER}/JLINK/blinky-button-demo.hex ``` -------------------------------- ### Run Lpcomp Demo with Cargo Embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/lpcomp-demo/README.md This command executes the Lpcomp demo in release mode for the nRF52840 target using cargo-embed. Ensure you have the necessary toolchain and device setup. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Install cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/blinky-button-demo/README.md Installs the cargo-embed tool, a necessary utility for embedding and debugging Rust applications on embedded targets. ```console cargo install probe-rs-tools ``` -------------------------------- ### Install Rust Target for nRF52840 Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/README.md Adds the necessary cross-compilation target for the nRF52840 microcontroller to your Rust toolchain. This is essential for compiling embedded applications. ```console rustup target add thumbv7em-none-eabihf ``` -------------------------------- ### Install cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/rtc-demo/README.md Installs the `cargo-embed` tool, which is used to flash and debug embedded applications. ```console cargo install probe-rs-tools ``` -------------------------------- ### Run QDEC Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/qdec-demo/README.md This command executes the QDEC demo using cargo-embed, targeting the thumbv7em-none-eabihf architecture in release mode. Ensure you have cargo-embed installed and configured for your nRF52840 development kit. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run Blinky Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/blinky-button-demo/README.md Executes the blinky button demo application on an embedded target using cargo-embed. This command compiles, flashes, and starts the application, targeting the thumbv7em-none-eabihf architecture. ```console cargo embed --target thumbv7em-none-eabihf ``` -------------------------------- ### Install Rust Target Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf5340-app-hal/README.md Installs the necessary Rust target for the nRF5340 microcontroller, which is required for building applications for this platform. ```console $ rustup target add thumbv8m.main-none-eabihf ``` -------------------------------- ### nrf-hal Device Reference Manuals Source: https://github.com/nrf-rs/nrf-hal/blob/master/README.md Provides links to Nordic's official product specifications and development kit reference guides for various nRF devices, including nRF52805, nRF52810, nRF52811, nRF52832, nRF52833, nRF52840, and nRF9160. ```rust Device | Product Specification | DK Reference Guide | |---|---|---| | [`nRF52805`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52805) | [`v1.3`](https://infocenter.nordicsemi.com/pdf/nRF52805_PS_v1.3.pdf) | [`v1.3.1*`](https://infocenter.nordicsemi.com/pdf/nRF52_DK_User_Guide_v1.3.1.pdf) | | [`nRF52810`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52810) | [`v1.3`](https://infocenter.nordicsemi.com/pdf/nRF52810_PS_v1.3.pdf) | [`v1.3.1*`](https://infocenter.nordicsemi.com/pdf/nRF52_DK_User_Guide_v1.3.1.pdf) | | [`nRF52811`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52811) | [`v1.0`](https://infocenter.nordicsemi.com/pdf/nRF52811_PS_v1.0.pdf) | [`v1.3.1*`](https://infocenter.nordicsemi.com/pdf/nRF52_DK_User_Guide_v1.3.1.pdf) | | [`nRF52832`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52832) | [`v1.4`](https://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.4.pdf) | [`v1.3.1*`](https://infocenter.nordicsemi.com/pdf/nRF52_DK_User_Guide_v1.3.1.pdf) | | [`nRF52833`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52833) | [`v1.3`](https://infocenter.nordicsemi.com/pdf/nRF52833_PS_v1.3.pdf) | [`v1.0.1`](http://infocenter.nordicsemi.com/pdf/nRF52833_DK_User_Guide_v1.0.1.pdf) | | [`nRF52840`](https://www.nordicsemi.com/Products/Low-power-short-range-wireless/nRF52840) | [`v1.1`](https://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.1.pdf) | [`v1.2`](https://infocenter.nordicsemi.com/pdf/nRF52840_DK_User_Guide_v1.2.pdf) | | [`nRF9160`](https://www.nordicsemi.com/Products/Low-power-cellular-IoT/nRF9160) | [`v2.0`](https://infocenter.nordicsemi.com/pdf/nRF9160_PS_v2.0.pdf) | [`v0.9.3`](https://infocenter.nordicsemi.com/pdf/nRF9160_DK_HW_User_Guide_v0.9.3.pdf) | * These devices do not have a separate development kit and share the [NRF52 DK](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52-DK) ``` -------------------------------- ### Run Demo Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/twi-ssd1306/README.md Command to compile and run the TWI master demo using cargo. ```console cargo run ``` -------------------------------- ### Run Gpiote Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/gpiote-demo/README.md Command to run the gpiote demo using cargo-embed in release mode for the thumbv7em-none-eabihf target. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run Comparator Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/comp-demo/README.md Command to build and run the nRF HAL comparator demo using cargo-embed. It specifies the release profile and the target architecture. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run TWIM Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/twim-demo/README.md Command to build and run the TWIM demo using cargo-embed with release mode and a specific target architecture. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run I2S Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/i2s-controller-demo/README.md Instructions for running the I2S controller demo using `cargo-embed`. This command compiles the project in release mode and targets the `thumbv7em-none-eabihf` architecture, suitable for embedded systems like the nRF52840. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run PPI Demo with Cargo Embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/ppi-demo/README.md Command to build and run the PPI demo using cargo-embed. Requires specifying the correct chip feature and target architecture for your microcontroller. ```console cargo embed --release --features=52832 --target=thumbv7em-none-eabihf ``` -------------------------------- ### Build and Flash Secure Partition Manager (SPM) Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf9160-hal/README.md Provides the console commands to initialize the nRF Connect SDK, build the Secure Partition Manager (SPM) for the nRF9160-DK, and flash it to the development kit. ```console $ west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.5.1 ncs $ cd ncs $ west update # This takes *ages* $ cd nrf/examples/spm $ west build --board=nrf9160dk_nrf9160 $ west flash ``` -------------------------------- ### Run I2S Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/i2s-peripheral-demo/README.md Command to build and run the I2S peripheral demo using cargo-embed. It specifies the release profile and the target architecture. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run RTC Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/rtc-demo/README.md Compiles and flashes the RTC demo application to the nRF52840 DK using `cargo-embed`. ```console cargo embed --target thumbv7em-none-eabihf ``` -------------------------------- ### Run ECB Encryption Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/ecb-demo/README.md Command to run the ECB encryption demo using cargo-embed. Ensure you replace the chip and target specifications with those matching your microcontroller. ```console cargo embed --release --features=52832 --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run TWIS Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/twis-demo/README.md Command to build and run the TWIS demo using cargo-embed. It specifies the release profile and the target architecture. ```console $ cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run SPI Slave Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/spis-demo/README.md This command executes the SPI slave demo using cargo-embed with release optimizations and targets the thumbv7em-none-eabihf architecture. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Run Timer Demo Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/monotonic-blinky/README.md Command to run the monotonic demo using the Timer peripheral with cargo embed. ```bash cargo embed --release --bin timer ``` -------------------------------- ### Version Bumping with cargo-xtask Source: https://github.com/nrf-rs/nrf-hal/blob/master/CONTRIBUTING.md Command to automate the bumping of crate versions for a new release using `cargo-xtask`. ```bash cargo xtask bump ``` -------------------------------- ### Run WDT Demo with cargo-embed Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/wdt-demo/README.md This command executes the WDT demo in release mode for the specified target architecture. It's used to test the watchdog timer's behavior and panic recovery. ```console cargo embed --release --target=thumbv7em-none-eabihf ``` -------------------------------- ### Publishing HAL Crates Source: https://github.com/nrf-rs/nrf-hal/blob/master/CONTRIBUTING.md Command to publish HAL crates to crates.io, with a specific note for `nrf-hal-common` requiring `--no-verify`. ```bash cargo publish --no-verify ``` -------------------------------- ### Build and Flash Secure Partition Manager (SPM) Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf5340-app-hal/README.md Provides the console commands to initialize the Nordic Connect SDK (NCS), update its components, build the SPM for the nRF5340-DK, and flash it to the development kit. This process sets up the secure environment for running non-secure applications. ```console $ west init -m https://github.com/nrfconnect/sdk-nrf --mr v1.5.1 ncs $ cd ncs $ west update # This takes *ages* $ cd nrf/examples/spm $ west build --board=nrf5340dk_nrf5340_cpuapp $ west flash ``` -------------------------------- ### Run CCM Encryption Demo Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/ccm-demo/README.md Command to build and run the CCM encryption demo using cargo-embed. Requires specifying the target microcontroller's feature and target architecture. ```console cargo embed --release --features=52832 --target=thumbv7em-none-eabihf ``` -------------------------------- ### Tagging a Release Source: https://github.com/nrf-rs/nrf-hal/blob/master/CONTRIBUTING.md Command to create a Git tag for a new release version. ```bash git tag -a -m 'vX.Y.Z' 'vX.Y.Z' git push --tags origin ``` -------------------------------- ### Run RTC Demo Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/monotonic-blinky/README.md Command to run the monotonic demo using the RTC peripheral with cargo embed. ```bash cargo embed --release --bin rtc ``` -------------------------------- ### SPI Master Demo with EasyDMA Source: https://github.com/nrf-rs/nrf-hal/blob/master/examples/spi-demo/README.md This Rust code demonstrates the SPIM master functionality with EasyDMA for SPI communication. It sends data and loops it back to verify full-duplex transfer. Successful execution lights up all four LEDs on the nRF52-DK. ```rust #[allow(unused_mut)] #[allow(unused_variables)] fn main() { // Placeholder for the actual SPI master demo code // This would involve initializing the SPIM peripheral, configuring pins, // setting up EasyDMA, and performing data transfers. // Example: // let mut spi = SPIM0::new(p0, Pins::new(p0.p0_24, p0.p0_23, p0.p0_22)); // spi.enable(); // spi.transfer(&[0x01, 0x02, 0x03]); } ``` -------------------------------- ### nrf-hal Crate List Source: https://github.com/nrf-rs/nrf-hal/blob/master/README.md Lists the available HAL crates for different nRF microcontroller families, including links to their documentation and crates.io pages, as well as their target architectures. ```rust Crate | Docs | crates.io | target | |---|---|---|---| | `nrf51-hal` | [![docs.rs](https://docs.rs/nrf51-hal/badge.svg)](https://docs.rs/nrf51-hal) | [![crates.io](https://img.shields.io/crates/d/nrf51-hal.svg)](https://crates.io/crates/nrf51-hal) | `thumbv6m-none-eabi` | | `nrf52805-hal` | [![docs.rs](https://docs.rs/nrf52805-hal/badge.svg)](https://docs.rs/nrf52805-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52805-hal.svg)](https://crates.io/crates/nrf52805-hal) | `thumbv7em-none-eabi` | | `nrf52810-hal` | [![docs.rs](https://docs.rs/nrf52810-hal/badge.svg)](https://docs.rs/nrf52810-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52810-hal.svg)](https://crates.io/crates/nrf52810-hal) | `thumbv7em-none-eabi` | | `nrf52811-hal` | [![docs.rs](https://docs.rs/nrf52811-hal/badge.svg)](https://docs.rs/nrf52811-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52811-hal.svg)](https://crates.io/crates/nrf52811-hal) | `thumbv7em-none-eabi` | | `nrf52832-hal` | [![docs.rs](https://docs.rs/nrf52832-hal/badge.svg)](https://docs.rs/nrf52832-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52832-hal.svg)](https://crates.io/crates/nrf52832-hal) | `thumbv7em-none-eabihf` | | `nrf52833-hal` | [![docs.rs](https://docs.rs/nrf52833-hal/badge.svg)](https://docs.rs/nrf52833-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52833-hal.svg)](https://crates.io/crates/nrf52833-hal) | `thumbv7em-none-eabihf` | | `nrf52840-hal` | [![docs.rs](https://docs.rs/nrf52840-hal/badge.svg)](https://docs.rs/nrf52840-hal) | [![crates.io](https://img.shields.io/crates/d/nrf52840-hal.svg)](https://crates.io/crates/nrf52840-hal) | `thumbv7em-none-eabihf` | | `nrf9160-hal` | [![docs.rs](https://docs.rs/nrf9160-hal/badge.svg)](https://docs.rs/nrf9160-hal) | [![crates.io](https://img.shields.io/crates/d/nrf9160-hal.svg)](https://crates.io/crates/nrf9160-hal) | `thumbv8m.main-none-eabihf` | ``` -------------------------------- ### Run All HAL Tests Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf52840-hal-tests/README.md Executes all available tests for the nRF52840 HAL using Cargo. This command should be run from the `nrf52840-hal-tests` directory. ```bash cargo test ``` -------------------------------- ### Run Specific HAL Test Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf52840-hal-tests/README.md Executes a single, specific test for the nRF52840 HAL. Replace 'nvmc' with the name of the desired test. This command is run from the `nrf52840-hal-tests` directory. ```bash cargo test --test nvmc ``` -------------------------------- ### Required Wiring for nRF52840 HAL Testing Source: https://github.com/nrf-rs/nrf-hal/blob/master/nrf52840-hal-tests/README.md Details the physical connections required between the nRF52840 Development Kit and other components for successful HAL testing. ```text P0.03 <-> GND P0.04 <-> VDD P0.28 <-> P0.29 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.