Skip to content

Commit

Permalink
support nRF52805
Browse files Browse the repository at this point in the history
  • Loading branch information
placrosse committed Jun 23, 2023
1 parent 939c017 commit e0a770e
Show file tree
Hide file tree
Showing 31 changed files with 374 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Unreleased

(no changes)
- add support for nRF52805

## [0.16.0]

Expand Down
1 change: 1 addition & 0 deletions Cargo.ci.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
resolver = "2"
members = [
"xtask",
"nrf52805-hal",
"nrf52810-hal",
"nrf52811-hal",
"nrf52832-hal",
Expand Down
1 change: 1 addition & 0 deletions Cargo.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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) |
Expand Down
2 changes: 2 additions & 0 deletions examples/ccm-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -23,6 +24,7 @@ doc = false
test = false

[features]
52805 = ["nrf52805-hal"]
52810 = ["nrf52810-hal"]
52811 = ["nrf52811-hal"]
52832 = ["nrf52832-hal"]
Expand Down
1 change: 1 addition & 0 deletions examples/ccm-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/ccm-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions examples/ecb-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -24,6 +25,7 @@ test = false

[features]
51 = ["nrf51-hal"]
52805 = ["nrf52805-hal"]
52810 = ["nrf52810-hal"]
52811 = ["nrf52811-hal"]
52832 = ["nrf52832-hal"]
Expand Down
1 change: 1 addition & 0 deletions examples/ecb-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/ecb-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 2 additions & 0 deletions examples/ppi-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -24,6 +25,7 @@ test = false

[features]
51 = ["nrf51-hal"]
52805 = ["nrf52805-hal"]
52810 = ["nrf52810-hal"]
52811 = ["nrf52811-hal"]
52832 = ["nrf52832-hal"]
Expand Down
3 changes: 2 additions & 1 deletion examples/ppi-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions examples/ppi-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#[cfg(not(any(
feature = "51",
feature = "52805",
feature = "52810",
feature = "52811",
feature = "52832",
Expand All @@ -12,6 +13,7 @@
compile_error!(
"This example requires one of the following device features enabled:
51
52805
52810
52811
52832
Expand All @@ -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")]
Expand Down
5 changes: 5 additions & 0 deletions examples/rtic-demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +36,7 @@ optional = true

[features]
51 = ["nrf51-hal"]
52805 = ["nrf52805-hal"]
52810 = ["nrf52810-hal"]
52811 = ["nrf52811-hal"]
52832 = ["nrf52832-hal"]
Expand Down
3 changes: 3 additions & 0 deletions examples/rtic-demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 5 additions & 0 deletions nrf-hal-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions nrf-hal-common/src/ccm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions nrf-hal-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"
Expand All @@ -54,6 +58,7 @@ pub mod gpio;
pub mod gpiote;
#[cfg(not(any(
feature = "51",
feature = "52805",
feature = "52810",
feature = "52811",
feature = "5340-net"
Expand All @@ -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"
Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions nrf-hal-common/src/nvmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
102 changes: 102 additions & 0 deletions nrf-hal-common/src/ppi/event_nrf52805.rs
Original file line number Diff line number Diff line change
@@ -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 {}
Loading

0 comments on commit e0a770e

Please sign in to comment.