From e0a770e4338b5b3f6ca1087f00d16d0602a09c8e Mon Sep 17 00:00:00 2001 From: Paul LaCrosse Date: Thu, 22 Jun 2023 11:46:39 -0400 Subject: [PATCH] support nRF52805 --- CHANGELOG.md | 2 +- Cargo.ci.toml | 1 + Cargo.example.toml | 1 + README.md | 2 + examples/ccm-demo/Cargo.toml | 2 + examples/ccm-demo/README.md | 1 + examples/ccm-demo/src/main.rs | 2 + examples/ecb-demo/Cargo.toml | 2 + examples/ecb-demo/README.md | 1 + examples/ecb-demo/src/main.rs | 2 + examples/ppi-demo/Cargo.toml | 2 + examples/ppi-demo/README.md | 3 +- examples/ppi-demo/src/main.rs | 4 + examples/rtic-demo/Cargo.toml | 5 ++ examples/rtic-demo/src/main.rs | 3 + nrf-hal-common/Cargo.toml | 5 ++ nrf-hal-common/src/ccm.rs | 2 + nrf-hal-common/src/lib.rs | 14 +++- nrf-hal-common/src/nvmc.rs | 1 + nrf-hal-common/src/ppi/event_nrf52805.rs | 102 +++++++++++++++++++++++ nrf-hal-common/src/ppi/mod.rs | 3 + nrf-hal-common/src/ppi/task_nrf52805.rs | 95 +++++++++++++++++++++ nrf-hal-common/src/spi.rs | 4 +- nrf-hal-common/src/spis.rs | 17 ++-- nrf-hal-common/src/twis.rs | 3 +- nrf-hal-common/src/uicr.rs | 1 + nrf52805-hal/Cargo.toml | 36 ++++++++ nrf52805-hal/build.rs | 22 +++++ nrf52805-hal/memory.x | 23 +++++ nrf52805-hal/src/lib.rs | 22 +++++ xtask/src/lib.rs | 11 +-- 31 files changed, 374 insertions(+), 20 deletions(-) create mode 100644 nrf-hal-common/src/ppi/event_nrf52805.rs create mode 100644 nrf-hal-common/src/ppi/task_nrf52805.rs create mode 100644 nrf52805-hal/Cargo.toml create mode 100644 nrf52805-hal/build.rs create mode 100644 nrf52805-hal/memory.x create mode 100644 nrf52805-hal/src/lib.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 7239d9d1..1776e81b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Unreleased -(no changes) +- add support for nRF52805 ## [0.16.0] diff --git a/Cargo.ci.toml b/Cargo.ci.toml index 764c4b7c..2c0b5bde 100644 --- a/Cargo.ci.toml +++ b/Cargo.ci.toml @@ -2,6 +2,7 @@ resolver = "2" members = [ "xtask", + "nrf52805-hal", "nrf52810-hal", "nrf52811-hal", "nrf52832-hal", diff --git a/Cargo.example.toml b/Cargo.example.toml index 1214d9fc..eff0b1df 100644 --- a/Cargo.example.toml +++ b/Cargo.example.toml @@ -16,6 +16,7 @@ resolver = "2" members = [ # Uncomment ONLY ONE of the hals below, depending on your target +# "nrf52805-hal", # "nrf52810-hal", # "nrf52811-hal", # "nrf52832-hal", diff --git a/README.md b/README.md index bc8e1182..654b5a64 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Every nRF chip has its own crate, listed below: | 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` | @@ -28,6 +29,7 @@ Every nRF chip has its own crate, listed below: | 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) | diff --git a/examples/ccm-demo/Cargo.toml b/examples/ccm-demo/Cargo.toml index 76340438..5ea1c0b9 100644 --- a/examples/ccm-demo/Cargo.toml +++ b/examples/ccm-demo/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.7.0" rtt-target = { version = "0.3.1", features = ["cortex-m"] } rand_core = "0.6.3" +nrf52805-hal = { path = "../../nrf52805-hal", features = ["rt"], optional = true } nrf52810-hal = { path = "../../nrf52810-hal", features = ["rt"], optional = true } nrf52811-hal = { path = "../../nrf52811-hal", features = ["rt"], optional = true } nrf52832-hal = { path = "../../nrf52832-hal", features = ["rt"], optional = true } @@ -23,6 +24,7 @@ doc = false test = false [features] +52805 = ["nrf52805-hal"] 52810 = ["nrf52810-hal"] 52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] diff --git a/examples/ccm-demo/README.md b/examples/ccm-demo/README.md index ce9ff6ec..16f36bc9 100644 --- a/examples/ccm-demo/README.md +++ b/examples/ccm-demo/README.md @@ -5,6 +5,7 @@ This CCM (cipher block chaining) encryption demo initialises a text message of t ## How to run Choose the microcontroller with one of the following features: +- 52805 - 52810 - 52811 - 52832 diff --git a/examples/ccm-demo/src/main.rs b/examples/ccm-demo/src/main.rs index 3086019c..4f1343f5 100644 --- a/examples/ccm-demo/src/main.rs +++ b/examples/ccm-demo/src/main.rs @@ -2,6 +2,8 @@ #![no_main] // Import the right HAL/PAC crate, depending on the target chip +#[cfg(feature = "52805")] +pub use nrf52805_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; #[cfg(feature = "52811")] diff --git a/examples/ecb-demo/Cargo.toml b/examples/ecb-demo/Cargo.toml index 7917a041..21bd6bf4 100644 --- a/examples/ecb-demo/Cargo.toml +++ b/examples/ecb-demo/Cargo.toml @@ -10,6 +10,7 @@ cortex-m = "0.7.3" cortex-m-rt = "0.7.0" rtt-target = { version = "0.3.1", features = ["cortex-m"] } +nrf52805-hal = { path = "../../nrf52805-hal", features = ["rt"], optional = true } nrf52810-hal = { path = "../../nrf52810-hal", features = ["rt"], optional = true } nrf52811-hal = { path = "../../nrf52811-hal", features = ["rt"], optional = true } nrf52832-hal = { path = "../../nrf52832-hal", features = ["rt"], optional = true } @@ -24,6 +25,7 @@ test = false [features] 51 = ["nrf51-hal"] +52805 = ["nrf52805-hal"] 52810 = ["nrf52810-hal"] 52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] diff --git a/examples/ecb-demo/README.md b/examples/ecb-demo/README.md index 976426bc..88b95c84 100644 --- a/examples/ecb-demo/README.md +++ b/examples/ecb-demo/README.md @@ -6,6 +6,7 @@ The AES electronic codebook mode (ECB) demo demonstrates a blocking 128-bit AES Choose the microcontroller with one of the following features: - 51 +- 52805 - 52810 - 52811 - 52832 diff --git a/examples/ecb-demo/src/main.rs b/examples/ecb-demo/src/main.rs index 9033f2ca..cb96459c 100644 --- a/examples/ecb-demo/src/main.rs +++ b/examples/ecb-demo/src/main.rs @@ -4,6 +4,8 @@ // Import the right HAL/PAC crate, depending on the target chip #[cfg(feature = "51")] pub use nrf51_hal as hal; +#[cfg(feature = "52805")] +pub use nrf52805_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; #[cfg(feature = "52811")] diff --git a/examples/ppi-demo/Cargo.toml b/examples/ppi-demo/Cargo.toml index ac40c497..be506514 100644 --- a/examples/ppi-demo/Cargo.toml +++ b/examples/ppi-demo/Cargo.toml @@ -10,6 +10,7 @@ cortex-m = "0.7.3" cortex-m-rt = "0.7.0" rtt-target = { version = "0.3.1", features = ["cortex-m"] } +nrf52805-hal = { path = "../../nrf52805-hal", features = ["rt"], optional = true } nrf52810-hal = { path = "../../nrf52810-hal", features = ["rt"], optional = true } nrf52811-hal = { path = "../../nrf52811-hal", features = ["rt"], optional = true } nrf52832-hal = { path = "../../nrf52832-hal", features = ["rt"], optional = true } @@ -24,6 +25,7 @@ test = false [features] 51 = ["nrf51-hal"] +52805 = ["nrf52805-hal"] 52810 = ["nrf52810-hal"] 52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] diff --git a/examples/ppi-demo/README.md b/examples/ppi-demo/README.md index 1c3c51c5..a64a64fa 100644 --- a/examples/ppi-demo/README.md +++ b/examples/ppi-demo/README.md @@ -2,10 +2,11 @@ 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. -## How to run +## How to run Choose the microcontroller with one of the following features: - 51 +- 52805 - 52810 - 52811 - 52832 diff --git a/examples/ppi-demo/src/main.rs b/examples/ppi-demo/src/main.rs index d8ef6cc7..9e7a6fd6 100644 --- a/examples/ppi-demo/src/main.rs +++ b/examples/ppi-demo/src/main.rs @@ -3,6 +3,7 @@ #[cfg(not(any( feature = "51", + feature = "52805", feature = "52810", feature = "52811", feature = "52832", @@ -12,6 +13,7 @@ compile_error!( "This example requires one of the following device features enabled: 51 + 52805 52810 52811 52832 @@ -22,6 +24,8 @@ compile_error!( // Import the right HAL/PAC crate, depending on the target chip #[cfg(feature = "51")] pub use nrf51_hal as hal; +#[cfg(feature = "52805")] +pub use nrf52805_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; #[cfg(feature = "52811")] diff --git a/examples/rtic-demo/Cargo.toml b/examples/rtic-demo/Cargo.toml index 249bb3ed..9f68b241 100644 --- a/examples/rtic-demo/Cargo.toml +++ b/examples/rtic-demo/Cargo.toml @@ -14,6 +14,10 @@ cortex-m-semihosting = "0.3.5" path = "../../nrf51-hal" optional = true +[dependencies.nrf52805-hal] +path = "../../nrf52805-hal" +optional = true + [dependencies.nrf52810-hal] path = "../../nrf52810-hal" optional = true @@ -32,6 +36,7 @@ optional = true [features] 51 = ["nrf51-hal"] +52805 = ["nrf52805-hal"] 52810 = ["nrf52810-hal"] 52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] diff --git a/examples/rtic-demo/src/main.rs b/examples/rtic-demo/src/main.rs index 28b040fa..9a3ba917 100644 --- a/examples/rtic-demo/src/main.rs +++ b/examples/rtic-demo/src/main.rs @@ -9,6 +9,9 @@ use rtic::app; #[cfg(feature = "51")] use nrf51_hal as hal; +#[cfg(feature = "52805")] +use nrf52805_hal as hal; + #[cfg(feature = "52810")] use nrf52810_hal as hal; diff --git a/nrf-hal-common/Cargo.toml b/nrf-hal-common/Cargo.toml index 5fa5e603..b3946ed7 100644 --- a/nrf-hal-common/Cargo.toml +++ b/nrf-hal-common/Cargo.toml @@ -40,6 +40,10 @@ version = "0.3.0" optional = true version = "0.12.2" +[dependencies.nrf52805-pac] +optional = true +version = "0.12.2" + [dependencies.nrf52810-pac] optional = true version = "0.12.2" @@ -83,6 +87,7 @@ version = "0.2.4" [features] doc = [] 51 = ["nrf51-pac"] +52805 = ["nrf52805-pac"] 52810 = ["nrf52810-pac"] 52811 = ["nrf52811-pac"] 52832 = ["nrf52832-pac"] diff --git a/nrf-hal-common/src/ccm.rs b/nrf-hal-common/src/ccm.rs index d972169a..ed1941a9 100644 --- a/nrf-hal-common/src/ccm.rs +++ b/nrf-hal-common/src/ccm.rs @@ -272,6 +272,7 @@ impl Ccm { feature = "52833", feature = "52811", feature = "52810", + feature = "52805", feature = "5340-net" ))] // NOTE(unsafe) Any 8bits pattern is safe to write to this register @@ -402,6 +403,7 @@ impl Ccm { feature = "52833", feature = "52811", feature = "52810", + feature = "52805", feature = "5340-net" ))] // NOTE(unsafe) Any 8bits pattern is safe to write to this register diff --git a/nrf-hal-common/src/lib.rs b/nrf-hal-common/src/lib.rs index 4c2fd8c3..14ff2dc7 100644 --- a/nrf-hal-common/src/lib.rs +++ b/nrf-hal-common/src/lib.rs @@ -9,6 +9,9 @@ use embedded_hal as hal; #[cfg(feature = "51")] pub use nrf51_pac as pac; +#[cfg(feature = "52805")] +pub use nrf52805_pac as pac; + #[cfg(feature = "52810")] pub use nrf52810_pac as pac; @@ -40,6 +43,7 @@ pub mod ccm; pub mod clocks; #[cfg(not(any( feature = "51", + feature = "52805", feature = "9160", feature = "5340-app", feature = "5340-net" @@ -54,6 +58,7 @@ pub mod gpio; pub mod gpiote; #[cfg(not(any( feature = "51", + feature = "52805", feature = "52810", feature = "52811", feature = "5340-net" @@ -62,8 +67,9 @@ pub mod i2s; #[cfg(any(feature = "52833", feature = "52840"))] pub mod ieee802154; #[cfg(not(any( - feature = "52811", + feature = "52805", feature = "52810", + feature = "52811", feature = "9160", feature = "5340-app", feature = "5340-net" @@ -73,7 +79,7 @@ pub mod lpcomp; pub mod nvmc; #[cfg(not(any(feature = "9160", feature = "5340-app", feature = "5340-net")))] pub mod ppi; -#[cfg(not(any(feature = "51", feature = "5340-net")))] +#[cfg(not(any(feature = "51", feature = "52805", feature = "5340-net")))] pub mod pwm; #[cfg(not(any( feature = "51", @@ -149,9 +155,9 @@ pub mod target_constants { pub const SRAM_LOWER: usize = 0x2000_0000; pub const SRAM_UPPER: usize = 0x3000_0000; - #[cfg(any(feature = "51", feature = "52810", feature = "52832"))] + #[cfg(any(feature = "51", feature = "52805", feature = "52810", feature = "52832"))] pub const FORCE_COPY_BUFFER_SIZE: usize = 255; - #[cfg(not(any(feature = "51", feature = "52810", feature = "52832")))] + #[cfg(not(any(feature = "51", feature = "52805", feature = "52810", feature = "52832")))] pub const FORCE_COPY_BUFFER_SIZE: usize = 1024; const _CHECK_FORCE_COPY_BUFFER_SIZE: usize = EASY_DMA_SIZE - FORCE_COPY_BUFFER_SIZE; // ERROR: FORCE_COPY_BUFFER_SIZE must be <= EASY_DMA_SIZE diff --git a/nrf-hal-common/src/nvmc.rs b/nrf-hal-common/src/nvmc.rs index 3ff55087..c1e1984a 100644 --- a/nrf-hal-common/src/nvmc.rs +++ b/nrf-hal-common/src/nvmc.rs @@ -186,6 +186,7 @@ where // // 2. The nRF52820 supports 2 writes per word but doesn't have an associated feature. #[cfg(any( + feature = "52805", feature = "52810", feature = "52811", feature = "52833", diff --git a/nrf-hal-common/src/ppi/event_nrf52805.rs b/nrf-hal-common/src/ppi/event_nrf52805.rs new file mode 100644 index 00000000..a6f1371f --- /dev/null +++ b/nrf-hal-common/src/ppi/event_nrf52805.rs @@ -0,0 +1,102 @@ +use crate::ppi::Event; + +// Event impls +// +// To reproduce, in the pac crate, search +// `rg 'type EVENTS_.*crate::Reg' --type rust` +// Find (regex): +// `^src/(.*)\.rs:pub type (.*) = .*$` +// Replace (regex): +// `impl Event for crate::pac::$1::$2 { }` +impl Event for crate::pac::rng::EVENTS_VALRDY {} +impl Event for crate::pac::timer0::EVENTS_COMPARE {} +impl Event for crate::pac::spis0::EVENTS_END {} +impl Event for crate::pac::spis0::EVENTS_ENDRX {} +impl Event for crate::pac::spis0::EVENTS_ACQUIRED {} +impl Event for crate::pac::gpiote::EVENTS_IN {} +impl Event for crate::pac::gpiote::EVENTS_PORT {} +impl Event for crate::pac::uart0::EVENTS_CTS {} +impl Event for crate::pac::uart0::EVENTS_NCTS {} +impl Event for crate::pac::uart0::EVENTS_RXDRDY {} +impl Event for crate::pac::uart0::EVENTS_TXDRDY {} +impl Event for crate::pac::uart0::EVENTS_ERROR {} +impl Event for crate::pac::uart0::EVENTS_RXTO {} +impl Event for crate::pac::clock::EVENTS_HFCLKSTARTED {} +impl Event for crate::pac::clock::EVENTS_LFCLKSTARTED {} +impl Event for crate::pac::clock::EVENTS_DONE {} +impl Event for crate::pac::clock::EVENTS_CTTO {} +impl Event for crate::pac::power::EVENTS_POFWARN {} +impl Event for crate::pac::power::EVENTS_SLEEPENTER {} +impl Event for crate::pac::power::EVENTS_SLEEPEXIT {} +impl Event for crate::pac::spim0::EVENTS_STOPPED {} +impl Event for crate::pac::spim0::EVENTS_ENDRX {} +impl Event for crate::pac::spim0::EVENTS_END {} +impl Event for crate::pac::spim0::EVENTS_ENDTX {} +impl Event for crate::pac::spim0::EVENTS_STARTED {} +impl Event for crate::pac::spi0::EVENTS_READY {} +impl Event for crate::pac::twim0::EVENTS_STOPPED {} +impl Event for crate::pac::twim0::EVENTS_ERROR {} +impl Event for crate::pac::twim0::EVENTS_SUSPENDED {} +impl Event for crate::pac::twim0::EVENTS_RXSTARTED {} +impl Event for crate::pac::twim0::EVENTS_TXSTARTED {} +impl Event for crate::pac::twim0::EVENTS_LASTRX {} +impl Event for crate::pac::twim0::EVENTS_LASTTX {} +impl Event for crate::pac::twi0::EVENTS_STOPPED {} +impl Event for crate::pac::twi0::EVENTS_RXDREADY {} +impl Event for crate::pac::twi0::EVENTS_TXDSENT {} +impl Event for crate::pac::twi0::EVENTS_ERROR {} +impl Event for crate::pac::twi0::EVENTS_BB {} +impl Event for crate::pac::twi0::EVENTS_SUSPENDED {} +impl Event for crate::pac::egu0::EVENTS_TRIGGERED {} +impl Event for crate::pac::ecb::EVENTS_ENDECB {} +impl Event for crate::pac::ecb::EVENTS_ERRORECB {} +impl Event for crate::pac::rtc0::EVENTS_TICK {} +impl Event for crate::pac::rtc0::EVENTS_OVRFLW {} +impl Event for crate::pac::rtc0::EVENTS_COMPARE {} +impl Event for crate::pac::wdt::EVENTS_TIMEOUT {} +impl Event for crate::pac::radio::EVENTS_READY {} +impl Event for crate::pac::radio::EVENTS_ADDRESS {} +impl Event for crate::pac::radio::EVENTS_PAYLOAD {} +impl Event for crate::pac::radio::EVENTS_END {} +impl Event for crate::pac::radio::EVENTS_DISABLED {} +impl Event for crate::pac::radio::EVENTS_DEVMATCH {} +impl Event for crate::pac::radio::EVENTS_DEVMISS {} +impl Event for crate::pac::radio::EVENTS_RSSIEND {} +impl Event for crate::pac::radio::EVENTS_BCMATCH {} +impl Event for crate::pac::radio::EVENTS_CRCOK {} +impl Event for crate::pac::radio::EVENTS_CRCERROR {} +impl Event for crate::pac::temp::EVENTS_DATARDY {} +impl Event for crate::pac::ccm::EVENTS_ENDKSGEN {} +impl Event for crate::pac::ccm::EVENTS_ENDCRYPT {} +impl Event for crate::pac::ccm::EVENTS_ERROR {} +impl Event for crate::pac::twis0::EVENTS_STOPPED {} +impl Event for crate::pac::twis0::EVENTS_ERROR {} +impl Event for crate::pac::twis0::EVENTS_RXSTARTED {} +impl Event for crate::pac::twis0::EVENTS_TXSTARTED {} +impl Event for crate::pac::twis0::EVENTS_WRITE {} +impl Event for crate::pac::twis0::EVENTS_READ {} +impl Event for crate::pac::uarte0::EVENTS_CTS {} +impl Event for crate::pac::uarte0::EVENTS_NCTS {} +impl Event for crate::pac::uarte0::EVENTS_RXDRDY {} +impl Event for crate::pac::uarte0::EVENTS_ENDRX {} +impl Event for crate::pac::uarte0::EVENTS_TXDRDY {} +impl Event for crate::pac::uarte0::EVENTS_ENDTX {} +impl Event for crate::pac::uarte0::EVENTS_ERROR {} +impl Event for crate::pac::uarte0::EVENTS_RXTO {} +impl Event for crate::pac::uarte0::EVENTS_RXSTARTED {} +impl Event for crate::pac::uarte0::EVENTS_TXSTARTED {} +impl Event for crate::pac::uarte0::EVENTS_TXSTOPPED {} +impl Event for crate::pac::qdec::EVENTS_SAMPLERDY {} +impl Event for crate::pac::qdec::EVENTS_REPORTRDY {} +impl Event for crate::pac::qdec::EVENTS_ACCOF {} +impl Event for crate::pac::qdec::EVENTS_DBLRDY {} +impl Event for crate::pac::qdec::EVENTS_STOPPED {} +impl Event for crate::pac::aar::EVENTS_END {} +impl Event for crate::pac::aar::EVENTS_RESOLVED {} +impl Event for crate::pac::aar::EVENTS_NOTRESOLVED {} +impl Event for crate::pac::saadc::EVENTS_STARTED {} +impl Event for crate::pac::saadc::EVENTS_END {} +impl Event for crate::pac::saadc::EVENTS_DONE {} +impl Event for crate::pac::saadc::EVENTS_RESULTDONE {} +impl Event for crate::pac::saadc::EVENTS_CALIBRATEDONE {} +impl Event for crate::pac::saadc::EVENTS_STOPPED {} diff --git a/nrf-hal-common/src/ppi/mod.rs b/nrf-hal-common/src/ppi/mod.rs index a40ae163..59cf159f 100644 --- a/nrf-hal-common/src/ppi/mod.rs +++ b/nrf-hal-common/src/ppi/mod.rs @@ -17,6 +17,9 @@ cfg_if! { if #[cfg(feature = "51")] { mod event_nrf51; mod task_nrf51; + } else if #[cfg(feature = "52805")] { + mod event_nrf52805; + mod task_nrf52805; } else if #[cfg(feature = "52810")] { mod event_nrf52810; mod task_nrf52810; diff --git a/nrf-hal-common/src/ppi/task_nrf52805.rs b/nrf-hal-common/src/ppi/task_nrf52805.rs new file mode 100644 index 00000000..563dc0d7 --- /dev/null +++ b/nrf-hal-common/src/ppi/task_nrf52805.rs @@ -0,0 +1,95 @@ +use crate::ppi::Task; + +// Task Impls +// +// To reproduce, in the pac crate, search +// `rg 'type TASKS_.*crate::Reg' --type rust` +// Find (regex): +// `^src/(.*)\.rs:pub type (.*) = .*$` +// Replace (regex): +// `impl Task for crate::pac::$1::$2 { }` +impl Task for crate::pac::spim0::TASKS_START {} +impl Task for crate::pac::spim0::TASKS_STOP {} +impl Task for crate::pac::spim0::TASKS_SUSPEND {} +impl Task for crate::pac::spim0::TASKS_RESUME {} +impl Task for crate::pac::rng::TASKS_START {} +impl Task for crate::pac::rng::TASKS_STOP {} +impl Task for crate::pac::timer0::TASKS_START {} +impl Task for crate::pac::timer0::TASKS_STOP {} +impl Task for crate::pac::timer0::TASKS_COUNT {} +impl Task for crate::pac::timer0::TASKS_CLEAR {} +impl Task for crate::pac::timer0::TASKS_SHUTDOWN {} +impl Task for crate::pac::timer0::TASKS_CAPTURE {} +impl Task for crate::pac::spis0::TASKS_ACQUIRE {} +impl Task for crate::pac::spis0::TASKS_RELEASE {} +impl Task for crate::pac::uart0::TASKS_STARTRX {} +impl Task for crate::pac::uart0::TASKS_STOPRX {} +impl Task for crate::pac::uart0::TASKS_STARTTX {} +impl Task for crate::pac::uart0::TASKS_STOPTX {} +impl Task for crate::pac::uart0::TASKS_SUSPEND {} +impl Task for crate::pac::gpiote::TASKS_OUT {} +impl Task for crate::pac::gpiote::TASKS_SET {} +impl Task for crate::pac::gpiote::TASKS_CLR {} +impl Task for crate::pac::clock::TASKS_HFCLKSTART {} +impl Task for crate::pac::clock::TASKS_HFCLKSTOP {} +impl Task for crate::pac::clock::TASKS_LFCLKSTART {} +impl Task for crate::pac::clock::TASKS_LFCLKSTOP {} +impl Task for crate::pac::clock::TASKS_CAL {} +impl Task for crate::pac::clock::TASKS_CTSTART {} +impl Task for crate::pac::clock::TASKS_CTSTOP {} +impl Task for crate::pac::power::TASKS_CONSTLAT {} +impl Task for crate::pac::power::TASKS_LOWPWR {} +impl Task for crate::pac::egu0::TASKS_TRIGGER {} +impl Task for crate::pac::twim0::TASKS_STARTRX {} +impl Task for crate::pac::twim0::TASKS_STARTTX {} +impl Task for crate::pac::twim0::TASKS_STOP {} +impl Task for crate::pac::twim0::TASKS_SUSPEND {} +impl Task for crate::pac::twim0::TASKS_RESUME {} +impl Task for crate::pac::ecb::TASKS_STARTECB {} +impl Task for crate::pac::ecb::TASKS_STOPECB {} +impl Task for crate::pac::twi0::TASKS_STARTRX {} +impl Task for crate::pac::twi0::TASKS_STARTTX {} +impl Task for crate::pac::twi0::TASKS_STOP {} +impl Task for crate::pac::twi0::TASKS_SUSPEND {} +impl Task for crate::pac::twi0::TASKS_RESUME {} +impl Task for crate::pac::wdt::TASKS_START {} +impl Task for crate::pac::rtc0::TASKS_START {} +impl Task for crate::pac::rtc0::TASKS_STOP {} +impl Task for crate::pac::rtc0::TASKS_CLEAR {} +impl Task for crate::pac::rtc0::TASKS_TRIGOVRFLW {} +impl Task for crate::pac::radio::TASKS_TXEN {} +impl Task for crate::pac::radio::TASKS_RXEN {} +impl Task for crate::pac::radio::TASKS_START {} +impl Task for crate::pac::radio::TASKS_STOP {} +impl Task for crate::pac::radio::TASKS_DISABLE {} +impl Task for crate::pac::radio::TASKS_RSSISTART {} +impl Task for crate::pac::radio::TASKS_RSSISTOP {} +impl Task for crate::pac::radio::TASKS_BCSTART {} +impl Task for crate::pac::radio::TASKS_BCSTOP {} +impl Task for crate::pac::temp::TASKS_START {} +impl Task for crate::pac::temp::TASKS_STOP {} +impl Task for crate::pac::ccm::TASKS_KSGEN {} +impl Task for crate::pac::ccm::TASKS_CRYPT {} +impl Task for crate::pac::ccm::TASKS_STOP {} +impl Task for crate::pac::ccm::TASKS_RATEOVERRIDE {} +impl Task for crate::pac::uarte0::TASKS_STARTRX {} +impl Task for crate::pac::uarte0::TASKS_STOPRX {} +impl Task for crate::pac::uarte0::TASKS_STARTTX {} +impl Task for crate::pac::uarte0::TASKS_STOPTX {} +impl Task for crate::pac::uarte0::TASKS_FLUSHRX {} +impl Task for crate::pac::twis0::TASKS_STOP {} +impl Task for crate::pac::twis0::TASKS_SUSPEND {} +impl Task for crate::pac::twis0::TASKS_RESUME {} +impl Task for crate::pac::twis0::TASKS_PREPARERX {} +impl Task for crate::pac::twis0::TASKS_PREPARETX {} +impl Task for crate::pac::aar::TASKS_START {} +impl Task for crate::pac::aar::TASKS_STOP {} +impl Task for crate::pac::qdec::TASKS_START {} +impl Task for crate::pac::qdec::TASKS_STOP {} +impl Task for crate::pac::qdec::TASKS_READCLRACC {} +impl Task for crate::pac::qdec::TASKS_RDCLRACC {} +impl Task for crate::pac::qdec::TASKS_RDCLRDBL {} +impl Task for crate::pac::saadc::TASKS_START {} +impl Task for crate::pac::saadc::TASKS_SAMPLE {} +impl Task for crate::pac::saadc::TASKS_STOP {} +impl Task for crate::pac::saadc::TASKS_CALIBRATEOFFSET {} diff --git a/nrf-hal-common/src/spi.rs b/nrf-hal-common/src/spi.rs index a678458d..edc4a8e3 100644 --- a/nrf-hal-common/src/spi.rs +++ b/nrf-hal-common/src/spi.rs @@ -173,9 +173,9 @@ mod sealed { impl sealed::Sealed for SPI0 {} impl Instance for SPI0 {} -#[cfg(not(feature = "52810"))] +#[cfg(not(any(feature = "52805", feature = "52810")))] impl sealed::Sealed for crate::pac::SPI1 {} -#[cfg(not(feature = "52810"))] +#[cfg(not(any(feature = "52805", feature = "52810")))] impl Instance for crate::pac::SPI1 {} #[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] diff --git a/nrf-hal-common/src/spis.rs b/nrf-hal-common/src/spis.rs index cbc962ab..6f9354b8 100644 --- a/nrf-hal-common/src/spis.rs +++ b/nrf-hal-common/src/spis.rs @@ -620,7 +620,8 @@ mod sealed { feature = "9160", feature = "5340-app", feature = "5340-net", - feature = "52810" + feature = "52810", + feature = "52805" )))] impl Sealed for super::SPIS1 {} #[cfg(not(any( @@ -628,7 +629,8 @@ mod sealed { feature = "5340-app", feature = "5340-net", feature = "52811", - feature = "52810" + feature = "52810", + feature = "52805" )))] impl Sealed for super::SPIS2 {} } @@ -643,14 +645,15 @@ impl Instance for SPIS0 { feature = "5340-app", feature = "5340-net", feature = "52811", - feature = "52810" + feature = "52810", + feature = "52805" )))] const INTERRUPT: Interrupt = Interrupt::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0; #[cfg(feature = "9160")] const INTERRUPT: Interrupt = Interrupt::UARTE0_SPIM0_SPIS0_TWIM0_TWIS0; #[cfg(any(feature = "5340-app", feature = "5340-net"))] const INTERRUPT: Interrupt = Interrupt::SERIAL0; - #[cfg(feature = "52810")] + #[cfg(any(feature = "52805", feature = "52810"))] const INTERRUPT: Interrupt = Interrupt::SPIM0_SPIS0_SPI0; #[cfg(feature = "52811")] const INTERRUPT: Interrupt = Interrupt::TWIM0_TWIS0_TWI0_SPIM0_SPIS0_SPI0; @@ -660,7 +663,8 @@ impl Instance for SPIS0 { feature = "9160", feature = "5340-app", feature = "5340-net", - feature = "52810" + feature = "52810", + feature = "52805" )))] impl Instance for SPIS1 { #[cfg(not(feature = "52811"))] @@ -674,7 +678,8 @@ impl Instance for SPIS1 { feature = "5340-app", feature = "5340-net", feature = "52811", - feature = "52810" + feature = "52810", + feature = "52805" )))] impl Instance for SPIS2 { const INTERRUPT: Interrupt = Interrupt::SPIM2_SPIS2_SPI2; diff --git a/nrf-hal-common/src/twis.rs b/nrf-hal-common/src/twis.rs index 4b50f64d..09ae9833 100644 --- a/nrf-hal-common/src/twis.rs +++ b/nrf-hal-common/src/twis.rs @@ -552,6 +552,7 @@ impl Instance for TWIS0 { feature = "9160", feature = "5340-app", feature = "5340-net", + feature = "52805", feature = "52810", feature = "52811" )))] @@ -560,7 +561,7 @@ impl Instance for TWIS0 { const INTERRUPT: Interrupt = Interrupt::SERIAL0; #[cfg(feature = "9160")] const INTERRUPT: Interrupt = Interrupt::UARTE0_SPIM0_SPIS0_TWIM0_TWIS0; - #[cfg(feature = "52810")] + #[cfg(any(feature = "52805", feature = "52810"))] const INTERRUPT: Interrupt = Interrupt::TWIM0_TWIS0_TWI0; #[cfg(feature = "52811")] const INTERRUPT: Interrupt = Interrupt::TWIM0_TWIS0_TWI0_SPIM0_SPIS0_SPI0; diff --git a/nrf-hal-common/src/uicr.rs b/nrf-hal-common/src/uicr.rs index d83c7e01..4ad81841 100644 --- a/nrf-hal-common/src/uicr.rs +++ b/nrf-hal-common/src/uicr.rs @@ -2,6 +2,7 @@ //! //! See product specification: //! +//! - nrf52805: Section 4.5 //! - nrf52810: Section 4.5 //! - nrf52811: Section 4.5 //! - nrf52832: Section 14 diff --git a/nrf52805-hal/Cargo.toml b/nrf52805-hal/Cargo.toml new file mode 100644 index 00000000..f2e9c5e8 --- /dev/null +++ b/nrf52805-hal/Cargo.toml @@ -0,0 +1,36 @@ +[package] +name = "nrf52805-hal" +version = "0.16.0" +edition = "2018" +description = "HAL for nRF52805 microcontrollers" +readme = "../README.md" + +repository = "https://github.com/nrf-rs/nrf-hal" +authors = [ + "James Munns ", + "Hanno Braun ", + "John Scarrott ", + "Wez Furlong ", + "Ferdia McKeogh ", +] +categories = ["embedded", "hardware-support", "no-std"] +keywords = ["arm", "cortex-m", "nrf52", "hal", "nrf52805"] +license = "MIT OR Apache-2.0" + +[dependencies] +nrf52805-pac = "0.12.2" + +[dependencies.nrf-hal-common] +path = "../nrf-hal-common" +default-features = false +features = ["52805"] +version = "=0.16.0" + +[dependencies.embedded-hal] +features = ["unproven"] +version = "0.2.3" + +[features] +doc = [] +rt = ["nrf52805-pac/rt"] +default = ["rt"] diff --git a/nrf52805-hal/build.rs b/nrf52805-hal/build.rs new file mode 100644 index 00000000..c1a6e3ef --- /dev/null +++ b/nrf52805-hal/build.rs @@ -0,0 +1,22 @@ +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + let target = env::var("TARGET").unwrap(); + if target.ends_with("eabihf") { + panic!("attempting to build nrf52805-hal for target `{}`, but the nRF52805 does not have an FPU", target); + } + + // Put the linker script somewhere the linker can find it + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-changed=memory.x"); +} diff --git a/nrf52805-hal/memory.x b/nrf52805-hal/memory.x new file mode 100644 index 00000000..bbb40a74 --- /dev/null +++ b/nrf52805-hal/memory.x @@ -0,0 +1,23 @@ +/* Linker script for the nRF52 - WITHOUT SOFT DEVICE */ +MEMORY +{ + /* NOTE K = KiBi = 1024 bytes */ + FLASH : ORIGIN = 0x00000000, LENGTH = 192K + RAM : ORIGIN = 0x20000000, LENGTH = 24K +} + +/* This is where the call stack will be allocated. */ +/* The stack is of the full descending type. */ +/* You may want to use this variable to locate the call stack and static + variables in different memory regions. Below is shown the default value */ +/* _stack_start = ORIGIN(RAM) + LENGTH(RAM); */ + +/* You can use this symbol to customize the location of the .text section */ +/* If omitted the .text section will be placed right after the .vector_table + section */ +/* This is required only on microcontrollers that store some configuration right + after the vector table */ +/* _stext = ORIGIN(FLASH) + 0x400; */ + +/* Size of the heap (in bytes) */ +/* _heap_size = 1024; */ \ No newline at end of file diff --git a/nrf52805-hal/src/lib.rs b/nrf52805-hal/src/lib.rs new file mode 100644 index 00000000..6d61d85c --- /dev/null +++ b/nrf52805-hal/src/lib.rs @@ -0,0 +1,22 @@ +#![no_std] +#![doc(html_root_url = "https://docs.rs/nrf52805-hal/0.16.0")] + +use embedded_hal as hal; +pub use nrf_hal_common::*; + +pub mod prelude { + pub use crate::hal::prelude::*; + pub use nrf_hal_common::prelude::*; + + pub use crate::time::U32Ext; +} + +pub use crate::ccm::Ccm; +pub use crate::clocks::Clocks; +pub use crate::delay::Delay; +pub use crate::ecb::Ecb; +pub use crate::saadc::Saadc; +pub use crate::spim::Spim; +pub use crate::temp::Temp; +pub use crate::timer::Timer; +pub use crate::uarte::Uarte; diff --git a/xtask/src/lib.rs b/xtask/src/lib.rs index c853fb0d..c958e12e 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -5,6 +5,7 @@ pub static HALS: &[(&str, &str)] = &[ ("nrf9160-hal", "thumbv8m.main-none-eabihf"), ("nrf5340-app-hal", "thumbv8m.main-none-eabihf"), ("nrf5340-net-hal", "thumbv8m.main-none-eabihf"), + ("nrf52805-hal", "thumbv7em-none-eabi"), ("nrf52810-hal", "thumbv7em-none-eabi"), ("nrf52811-hal", "thumbv7em-none-eabi"), ("nrf52832-hal", "thumbv7em-none-eabihf"), @@ -14,11 +15,11 @@ pub static HALS: &[(&str, &str)] = &[ pub static EXAMPLES: &[(&str, &[&str])] = &[ ("blinky-button-demo", &[]), - ("ccm-demo", &["52810", "52811", "52832", "52833", "52840"]), + ("ccm-demo", &["52805", "52810", "52811", "52832", "52833", "52840"]), ("comp-demo", &[]), ( "ecb-demo", - &["51", "52810", "52811", "52832", "52833", "52840"], + &["51", "52805", "52810", "52811", "52832", "52833", "52840"], ), ("hello-world", &["52840", "9160"]), ("gpiote-demo", &[]), @@ -27,14 +28,14 @@ pub static EXAMPLES: &[(&str, &[&str])] = &[ ("lpcomp-demo", &[]), ( "ppi-demo", - &["51", "52810", "52811", "52832", "52833", "52840"], + &["51", "52805", "52810", "52811", "52832", "52833", "52840"], ), ("nvmc-demo", &["52840"]), ("pwm-blinky-demo", &["52840"]), ("pwm-demo", &[]), ("qdec-demo", &[]), ("rtc-demo", &[]), - ("rtic-demo", &["51", "52810", "52811", "52832", "52840"]), + ("rtic-demo", &["51", "52805", "52810", "52811", "52832", "52840"]), ("spi-demo", &[]), ("spis-demo", &[]), ("twi-ssd1306", &["52832", "52840"]), @@ -48,7 +49,7 @@ pub static EXAMPLES: &[(&str, &[&str])] = &[ pub fn feature_to_target(feat: &str) -> &str { match feat { "51" => "thumbv6m-none-eabi", - "52810" | "52811" => "thumbv7em-none-eabi", + "52805" | "52810" | "52811" => "thumbv7em-none-eabi", "9160" | "5340-app" | "5340-net" => "thumbv8m.main-none-eabihf", _ if feat.starts_with("52") => "thumbv7em-none-eabihf", _ => panic!("unknown Cargo feature `{}`", feat),