diff --git a/CHANGELOG.md b/CHANGELOG.md index 06836e73..da5e227a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - PWM module ([#200]). - I2S module ([#201]). - SPIS module ([#226]). +- Add support for the nRF52811 ([#227]). ### Fixes diff --git a/Cargo.toml b/Cargo.toml index b7855903..a6b0b921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ members = [ "xtask", "nrf52810-hal", + "nrf52811-hal", "nrf52832-hal", "nrf52833-hal", "nrf52840-hal", diff --git a/README.md b/README.md index fa2d48e1..dda8abb3 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Every nRF chip has its own crate, listed below: |-------|------|-----------| | [`nrf51-hal`](./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) | | [`nrf52810-hal`](./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) | +| [`nrf52811-hal`](./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) | | [`nrf52832-hal`](./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) | | [`nrf52833-hal`](./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) | | [`nrf52840-hal`](./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) | @@ -28,6 +29,7 @@ Every nRF chip has its own crate, listed below: | Device | Product Specification | DK Reference Guide | |-------|------|-----------| | [`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) | diff --git a/examples/ccm-demo/Cargo.toml b/examples/ccm-demo/Cargo.toml index 2c6d6050..914db149 100644 --- a/examples/ccm-demo/Cargo.toml +++ b/examples/ccm-demo/Cargo.toml @@ -12,6 +12,7 @@ rtt-target = {version = "0.2.0", features = ["cortex-m"] } rand_core = "0.5.1" 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 } nrf52840-hal = { path = "../../nrf52840-hal", features = ["rt"], optional = true } nrf52833-hal = { path = "../../nrf52833-hal", features = ["rt"], optional = true } @@ -23,6 +24,7 @@ test = false [features] 52810 = ["nrf52810-hal"] +52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] 52840 = ["nrf52840-hal"] 52833 = ["nrf52833-hal"] diff --git a/examples/ccm-demo/README.md b/examples/ccm-demo/README.md index 6c7f68cd..6728902d 100644 --- a/examples/ccm-demo/README.md +++ b/examples/ccm-demo/README.md @@ -2,6 +2,7 @@ Choose the microcontroller with one of the following features: - 52810 +- 52811 - 52832 - 52840 diff --git a/examples/ccm-demo/src/main.rs b/examples/ccm-demo/src/main.rs index ebbd4aee..3086019c 100644 --- a/examples/ccm-demo/src/main.rs +++ b/examples/ccm-demo/src/main.rs @@ -4,6 +4,8 @@ // Import the right HAL/PAC crate, depending on the target chip #[cfg(feature = "52810")] pub use nrf52810_hal as hal; +#[cfg(feature = "52811")] +pub use nrf52811_hal as hal; #[cfg(feature = "52832")] pub use nrf52832_hal as hal; #[cfg(feature = "52833")] diff --git a/examples/ecb-demo/Cargo.toml b/examples/ecb-demo/Cargo.toml index 3fa0c6c5..53286825 100644 --- a/examples/ecb-demo/Cargo.toml +++ b/examples/ecb-demo/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.6.12" rtt-target = {version = "0.2.0", features = ["cortex-m"] } 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 } nrf52840-hal = { path = "../../nrf52840-hal", features = ["rt"], optional = true } nrf52833-hal = { path = "../../nrf52833-hal", features = ["rt"], optional = true } @@ -24,6 +25,7 @@ test = false [features] 51 = ["nrf51-hal"] 52810 = ["nrf52810-hal"] +52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] 52840 = ["nrf52840-hal"] 52833 = ["nrf52833-hal"] diff --git a/examples/ecb-demo/README.md b/examples/ecb-demo/README.md index af4c3e76..e2460508 100644 --- a/examples/ecb-demo/README.md +++ b/examples/ecb-demo/README.md @@ -3,6 +3,7 @@ Choose the microcontroller with one of the following features: - 51 - 52810 +- 52811 - 52832 - 52840 diff --git a/examples/ecb-demo/src/main.rs b/examples/ecb-demo/src/main.rs index 9a9f7dc3..9033f2ca 100644 --- a/examples/ecb-demo/src/main.rs +++ b/examples/ecb-demo/src/main.rs @@ -6,6 +6,8 @@ pub use nrf51_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; +#[cfg(feature = "52811")] +pub use nrf52811_hal as hal; #[cfg(feature = "52832")] pub use nrf52832_hal as hal; #[cfg(feature = "52833")] diff --git a/examples/ppi-demo/Cargo.toml b/examples/ppi-demo/Cargo.toml index cbc6684f..3ee99e2a 100644 --- a/examples/ppi-demo/Cargo.toml +++ b/examples/ppi-demo/Cargo.toml @@ -11,6 +11,7 @@ cortex-m-rt = "0.6.12" rtt-target = {version = "0.2.0", features = ["cortex-m"] } 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 } nrf52840-hal = { path = "../../nrf52840-hal", features = ["rt"], optional = true } nrf52833-hal = { path = "../../nrf52833-hal", features = ["rt"], optional = true } @@ -24,6 +25,7 @@ test = false [features] 51 = ["nrf51-hal"] 52810 = ["nrf52810-hal"] +52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] 52840 = ["nrf52840-hal"] 52833 = ["nrf52833-hal"] diff --git a/examples/ppi-demo/README.md b/examples/ppi-demo/README.md index 49ded381..e09ded2b 100644 --- a/examples/ppi-demo/README.md +++ b/examples/ppi-demo/README.md @@ -3,6 +3,7 @@ Choose the microcontroller with one of the following features: - 51 - 52810 +- 52811 - 52832 - 52840 diff --git a/examples/ppi-demo/src/main.rs b/examples/ppi-demo/src/main.rs index c52c9d8a..d8ef6cc7 100644 --- a/examples/ppi-demo/src/main.rs +++ b/examples/ppi-demo/src/main.rs @@ -4,6 +4,7 @@ #[cfg(not(any( feature = "51", feature = "52810", + feature = "52811", feature = "52832", feature = "52833", feature = "52840" @@ -12,6 +13,7 @@ compile_error!( "This example requires one of the following device features enabled: 51 52810 + 52811 52832 52833 52840" @@ -22,6 +24,8 @@ compile_error!( pub use nrf51_hal as hal; #[cfg(feature = "52810")] pub use nrf52810_hal as hal; +#[cfg(feature = "52811")] +pub use nrf52811_hal as hal; #[cfg(feature = "52832")] pub use nrf52832_hal as hal; #[cfg(feature = "52833")] diff --git a/examples/rtic-demo/Cargo.toml b/examples/rtic-demo/Cargo.toml index 15f22877..31c885ab 100644 --- a/examples/rtic-demo/Cargo.toml +++ b/examples/rtic-demo/Cargo.toml @@ -18,6 +18,10 @@ optional = true path = "../../nrf52810-hal" optional = true +[dependencies.nrf52811-hal] +path = "../../nrf52811-hal" +optional = true + [dependencies.nrf52832-hal] path = "../../nrf52832-hal" optional = true @@ -29,5 +33,6 @@ optional = true [features] 51 = ["nrf51-hal"] 52810 = ["nrf52810-hal"] +52811 = ["nrf52811-hal"] 52832 = ["nrf52832-hal"] 52840 = ["nrf52840-hal"] diff --git a/examples/rtic-demo/src/main.rs b/examples/rtic-demo/src/main.rs index 66c7344a..6b5e7b98 100644 --- a/examples/rtic-demo/src/main.rs +++ b/examples/rtic-demo/src/main.rs @@ -13,6 +13,9 @@ use nrf51_hal as hal; #[cfg(feature = "52810")] use nrf52810_hal as hal; +#[cfg(feature = "52811")] +use nrf52811_hal as hal; + #[cfg(feature = "52832")] use nrf52832_hal as hal; diff --git a/nrf-hal-common/Cargo.toml b/nrf-hal-common/Cargo.toml index f6fbc950..544a11b2 100644 --- a/nrf-hal-common/Cargo.toml +++ b/nrf-hal-common/Cargo.toml @@ -42,6 +42,10 @@ version = "0.9.0" optional = true version = "0.9.0" +[dependencies.nrf52811-pac] +optional = true +version = "0.9.0" + [dependencies.nrf52832-pac] optional = true version = "0.9.0" @@ -66,6 +70,7 @@ version = "0.2.4" doc = [] 51 = ["nrf51"] 52810 = ["nrf52810-pac"] +52811 = ["nrf52811-pac"] 52832 = ["nrf52832-pac"] 52833 = ["nrf52833-pac"] 52840 = ["nrf52840-pac"] diff --git a/nrf-hal-common/src/ccm.rs b/nrf-hal-common/src/ccm.rs index 05463a04..d25221fd 100644 --- a/nrf-hal-common/src/ccm.rs +++ b/nrf-hal-common/src/ccm.rs @@ -249,7 +249,12 @@ impl Ccm { let length_variant = if payload_len <= MAXIMUM_LENGTH_5BITS - MIC_SIZE { LENGTH_A::DEFAULT } else { - #[cfg(any(feature = "52840", feature = "52833", feature = "52810"))] + #[cfg(any( + feature = "52840", + feature = "52833", + feature = "52811", + feature = "52810" + ))] // NOTE(unsafe) Any 8bits pattern is safe to write to this register self.regs .maxpacketsize @@ -373,7 +378,12 @@ impl Ccm { let length_variant = if payload_len <= MAXIMUM_LENGTH_5BITS { LENGTH_A::DEFAULT } else { - #[cfg(any(feature = "52840", feature = "52833", feature = "52810"))] + #[cfg(any( + feature = "52840", + feature = "52833", + feature = "52811", + feature = "52810" + ))] // NOTE(unsafe) Any 8bits pattern is safe to write to this register self.regs .maxpacketsize diff --git a/nrf-hal-common/src/comp.rs b/nrf-hal-common/src/comp.rs index f3a8187b..9627d1e3 100644 --- a/nrf-hal-common/src/comp.rs +++ b/nrf-hal-common/src/comp.rs @@ -293,7 +293,7 @@ comp_ref_pins! { P0_31> => EXTREFSEL_A::ANALOGREFERENCE7, } -#[cfg(not(feature = "52810"))] +#[cfg(not(any(feature = "52811", feature = "52810")))] comp_input_pins! { P0_02> => PSEL_A::ANALOGINPUT0, P0_03> => PSEL_A::ANALOGINPUT1, @@ -305,7 +305,7 @@ comp_input_pins! { P0_31> => PSEL_A::ANALOGINPUT7, } -#[cfg(feature = "52810")] +#[cfg(any(feature = "52811", feature = "52810"))] comp_input_pins! { P0_02> => PSEL_A::ANALOGINPUT0, P0_03> => PSEL_A::ANALOGINPUT1, diff --git a/nrf-hal-common/src/lib.rs b/nrf-hal-common/src/lib.rs index e710a0d7..54924aa4 100644 --- a/nrf-hal-common/src/lib.rs +++ b/nrf-hal-common/src/lib.rs @@ -12,6 +12,9 @@ pub use nrf51 as pac; #[cfg(feature = "52810")] pub use nrf52810_pac as pac; +#[cfg(feature = "52811")] +pub use nrf52811_pac as pac; + #[cfg(feature = "52832")] pub use nrf52832_pac as pac; @@ -38,9 +41,9 @@ pub mod ecb; pub mod gpio; #[cfg(not(feature = "9160"))] pub mod gpiote; -#[cfg(not(any(feature = "51", feature = "52810")))] +#[cfg(not(any(feature = "51", feature = "52810", feature = "52811")))] pub mod i2s; -#[cfg(not(any(feature = "52810", feature = "9160")))] +#[cfg(not(any(feature = "52811", feature = "52810", feature = "9160")))] pub mod lpcomp; #[cfg(not(feature = "9160"))] pub mod ppi; @@ -88,7 +91,12 @@ pub mod prelude { } /// Length of Nordic EasyDMA differs for MCUs -#[cfg(any(feature = "52810", feature = "52832", feature = "51"))] +#[cfg(any( + feature = "52810", + feature = "52811", + feature = "52832", + feature = "51" +))] pub mod target_constants { // NRF52832 8 bits1..0xFF pub const EASY_DMA_SIZE: usize = 255; diff --git a/nrf-hal-common/src/ppi/event_nrf52811.rs b/nrf-hal-common/src/ppi/event_nrf52811.rs new file mode 100644 index 00000000..f4bdcd86 --- /dev/null +++ b/nrf-hal-common/src/ppi/event_nrf52811.rs @@ -0,0 +1,126 @@ +use crate::ppi::Event; + +// Event impls +// +// To reproduce, in the pac crate, search +// `rg 'type EVENTS_.*crate::Reg' --type rust --no-heading --no-line-number` +// Find (regex): +// `^src/(.*)\.rs:pub type (.*) = .*$` +// Replace (regex): +// `impl Event for crate::pac::$1::$2 { }` +impl Event for crate::pac::egu0::EVENTS_TRIGGERED {} +impl Event for crate::pac::gpiote::EVENTS_IN {} +impl Event for crate::pac::gpiote::EVENTS_PORT {} +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::spi0::EVENTS_READY {} +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::spis0::EVENTS_END {} +impl Event for crate::pac::spis0::EVENTS_ENDRX {} +impl Event for crate::pac::spis0::EVENTS_ACQUIRED {} +impl Event for crate::pac::ecb::EVENTS_ENDECB {} +impl Event for crate::pac::ecb::EVENTS_ERRORECB {} +impl Event for crate::pac::timer0::EVENTS_COMPARE {} +impl Event for crate::pac::wdt::EVENTS_TIMEOUT {} +impl Event for crate::pac::pdm::EVENTS_STARTED {} +impl Event for crate::pac::pdm::EVENTS_STOPPED {} +impl Event for crate::pac::pdm::EVENTS_END {} +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::ccm::EVENTS_ENDKSGEN {} +impl Event for crate::pac::ccm::EVENTS_ENDCRYPT {} +impl Event for crate::pac::ccm::EVENTS_ERROR {} +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::rtc0::EVENTS_TICK {} +impl Event for crate::pac::rtc0::EVENTS_OVRFLW {} +impl Event for crate::pac::rtc0::EVENTS_COMPARE {} +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::radio::EVENTS_FRAMESTART {} +impl Event for crate::pac::radio::EVENTS_EDEND {} +impl Event for crate::pac::radio::EVENTS_EDSTOPPED {} +impl Event for crate::pac::radio::EVENTS_CCAIDLE {} +impl Event for crate::pac::radio::EVENTS_CCABUSY {} +impl Event for crate::pac::radio::EVENTS_CCASTOPPED {} +impl Event for crate::pac::radio::EVENTS_RATEBOOST {} +impl Event for crate::pac::radio::EVENTS_TXREADY {} +impl Event for crate::pac::radio::EVENTS_RXREADY {} +impl Event for crate::pac::radio::EVENTS_MHRMATCH {} +impl Event for crate::pac::radio::EVENTS_PHYEND {} +impl Event for crate::pac::radio::EVENTS_CTEPRESENT {} +impl Event for crate::pac::comp::EVENTS_READY {} +impl Event for crate::pac::comp::EVENTS_DOWN {} +impl Event for crate::pac::comp::EVENTS_UP {} +impl Event for crate::pac::comp::EVENTS_CROSS {} +impl Event for crate::pac::pwm0::EVENTS_STOPPED {} +impl Event for crate::pac::pwm0::EVENTS_SEQSTARTED {} +impl Event for crate::pac::pwm0::EVENTS_SEQEND {} +impl Event for crate::pac::pwm0::EVENTS_PWMPERIODEND {} +impl Event for crate::pac::pwm0::EVENTS_LOOPSDONE {} +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::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 {} +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::power::EVENTS_POFWARN {} +impl Event for crate::pac::power::EVENTS_SLEEPENTER {} +impl Event for crate::pac::power::EVENTS_SLEEPEXIT {} +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::temp::EVENTS_DATARDY {} +impl Event for crate::pac::rng::EVENTS_VALRDY {} diff --git a/nrf-hal-common/src/ppi/mod.rs b/nrf-hal-common/src/ppi/mod.rs index b6a3af79..1b258c42 100644 --- a/nrf-hal-common/src/ppi/mod.rs +++ b/nrf-hal-common/src/ppi/mod.rs @@ -21,6 +21,9 @@ cfg_if! { } else if #[cfg(feature = "52810")] { mod event_nrf52810; mod task_nrf52810; + } else if #[cfg(feature = "52811")] { + mod event_nrf52811; + mod task_nrf52811; } else if #[cfg(feature = "52832")] { mod event_nrf52832; mod task_nrf52832; diff --git a/nrf-hal-common/src/ppi/task_nrf52811.rs b/nrf-hal-common/src/ppi/task_nrf52811.rs new file mode 100644 index 00000000..7b810294 --- /dev/null +++ b/nrf-hal-common/src/ppi/task_nrf52811.rs @@ -0,0 +1,103 @@ +use crate::ppi::Task; + +// Task Impls +// +// To reproduce, in the pac crate, search +// `rg 'type TASKS_.*crate::Reg' --type rust --no-heading --no-line-number` +// 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::pdm::TASKS_START {} +impl Task for crate::pac::pdm::TASKS_STOP {} +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::comp::TASKS_START {} +impl Task for crate::pac::comp::TASKS_STOP {} +impl Task for crate::pac::comp::TASKS_SAMPLE {} +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 {} +impl Task for crate::pac::pwm0::TASKS_STOP {} +impl Task for crate::pac::pwm0::TASKS_SEQSTART {} +impl Task for crate::pac::pwm0::TASKS_NEXTSTEP {} diff --git a/nrf-hal-common/src/pwm.rs b/nrf-hal-common/src/pwm.rs index 5e04d007..e49535cb 100644 --- a/nrf-hal-common/src/pwm.rs +++ b/nrf-hal-common/src/pwm.rs @@ -977,13 +977,13 @@ pub trait Instance: private::Sealed {} impl Instance for PWM0 {} -#[cfg(not(any(feature = "52810")))] +#[cfg(not(any(feature = "52810", feature = "52811")))] impl Instance for PWM1 {} -#[cfg(not(any(feature = "52810")))] +#[cfg(not(any(feature = "52810", feature = "52811")))] impl Instance for PWM2 {} -#[cfg(not(any(feature = "52810", feature = "52832")))] +#[cfg(not(any(feature = "52810", feature = "52811", feature = "52832")))] impl Instance for PWM3 {} mod private { @@ -991,12 +991,12 @@ mod private { impl Sealed for crate::pwm::PWM0 {} - #[cfg(not(any(feature = "52810")))] + #[cfg(not(any(feature = "52810", feature = "52811")))] impl Sealed for crate::pwm::PWM1 {} - #[cfg(not(any(feature = "52810")))] + #[cfg(not(any(feature = "52810", feature = "52811")))] impl Sealed for crate::pwm::PWM2 {} - #[cfg(not(any(feature = "52810", feature = "52832")))] + #[cfg(not(any(feature = "52810", feature = "52811", feature = "52832")))] impl Sealed for crate::pwm::PWM3 {} } diff --git a/nrf-hal-common/src/spim.rs b/nrf-hal-common/src/spim.rs index 8c792402..a066ea8d 100644 --- a/nrf-hal-common/src/spim.rs +++ b/nrf-hal-common/src/spim.rs @@ -16,6 +16,9 @@ pub use spim0::frequency::FREQUENCY_A as Frequency; use core::iter::repeat_with; +#[cfg(feature = "52811")] +use crate::pac::SPIM1; + #[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] use crate::pac::{SPIM1, SPIM2}; @@ -395,7 +398,12 @@ pub trait Instance: Deref {} impl Instance for SPIM0 {} -#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] +#[cfg(any( + feature = "52832", + feature = "52833", + feature = "52840", + feature = "52811" +))] impl Instance for SPIM1 {} #[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 518f4285..13370acd 100644 --- a/nrf-hal-common/src/spis.rs +++ b/nrf-hal-common/src/spis.rs @@ -21,6 +21,9 @@ use crate::pac::{ SPIS0, }; +#[cfg(feature = "52811")] +use crate::pac::SPIS1; + #[cfg(any(feature = "52832", feature = "52833", feature = "52840"))] use crate::pac::{SPIS1, SPIS2}; @@ -598,7 +601,7 @@ mod sealed { impl Sealed for super::SPIS0 {} #[cfg(not(any(feature = "9160", feature = "52810")))] impl Sealed for super::SPIS1 {} - #[cfg(not(any(feature = "9160", feature = "52810")))] + #[cfg(not(any(feature = "9160", feature = "52811", feature = "52810")))] impl Sealed for super::SPIS2 {} } @@ -607,20 +610,25 @@ pub trait Instance: sealed::Sealed + Deref { } impl Instance for SPIS0 { - #[cfg(not(any(feature = "9160", feature = "52810")))] + #[cfg(not(any(feature = "9160", feature = "52811", feature = "52810")))] const INTERRUPT: Interrupt = Interrupt::SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0; #[cfg(feature = "9160")] const INTERRUPT: Interrupt = Interrupt::UARTE0_SPIM0_SPIS0_TWIM0_TWIS0; #[cfg(feature = "52810")] const INTERRUPT: Interrupt = Interrupt::SPIM0_SPIS0_SPI0; + #[cfg(feature = "52811")] + const INTERRUPT: Interrupt = Interrupt::TWIM0_TWIS0_TWI0_SPIM0_SPIS0_SPI0; } #[cfg(not(any(feature = "9160", feature = "52810")))] impl Instance for SPIS1 { + #[cfg(not(feature = "52811"))] const INTERRUPT: Interrupt = Interrupt::SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1; + #[cfg(feature = "52811")] + const INTERRUPT: Interrupt = Interrupt::SPIM1_SPIS1_SPI1; } -#[cfg(not(any(feature = "9160", feature = "52810")))] +#[cfg(not(any(feature = "9160", feature = "52811", feature = "52810")))] impl Instance for SPIS2 { const INTERRUPT: Interrupt = Interrupt::SPIM2_SPIS2_SPI2; } diff --git a/nrf-hal-common/src/uicr.rs b/nrf-hal-common/src/uicr.rs index 5cb02dc0..d83c7e01 100644 --- a/nrf-hal-common/src/uicr.rs +++ b/nrf-hal-common/src/uicr.rs @@ -3,6 +3,7 @@ //! See product specification: //! //! - nrf52810: Section 4.5 +//! - nrf52811: Section 4.5 //! - nrf52832: Section 14 //! - nrf52840: Section 4.5 use crate::pac::{NVMC, UICR}; diff --git a/nrf52811-hal/Cargo.toml b/nrf52811-hal/Cargo.toml new file mode 100644 index 00000000..9ed4c04c --- /dev/null +++ b/nrf52811-hal/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "nrf52811-hal" +version = "0.11.1" +edition = "2018" +description = "HAL for nRF52811 microcontrollers" +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", "nrf52811"] +license = "MIT OR Apache-2.0" + +[dependencies] +nrf52811-pac = "0.9.1" + +[dependencies.nrf-hal-common] +path = "../nrf-hal-common" +default-features = false +features = ["52811"] +version = "=0.11.1" + +[dependencies.embedded-hal] +features = ["unproven"] +version = "0.2.3" + +[features] +rt = ["nrf52811-pac/rt"] +default = ["rt"] diff --git a/nrf52811-hal/build.rs b/nrf52811-hal/build.rs new file mode 100644 index 00000000..fc8a63ea --- /dev/null +++ b/nrf52811-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 nrf52811-hal for target `{}`, but the nRF52811 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/nrf52811-hal/memory.x b/nrf52811-hal/memory.x new file mode 100644 index 00000000..bbb40a74 --- /dev/null +++ b/nrf52811-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/nrf52811-hal/src/lib.rs b/nrf52811-hal/src/lib.rs new file mode 100644 index 00000000..105f70dd --- /dev/null +++ b/nrf52811-hal/src/lib.rs @@ -0,0 +1,22 @@ +#![no_std] +#![doc(html_root_url = "https://docs.rs/nrf52811-hal/0.11.1")] + +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 bb4d52f1..4cb96db5 100644 --- a/xtask/src/lib.rs +++ b/xtask/src/lib.rs @@ -4,6 +4,7 @@ pub static HALS: &[(&str, &str)] = &[ ("nrf51-hal", "thumbv6m-none-eabi"), ("nrf9160-hal", "thumbv8m.main-none-eabihf"), ("nrf52810-hal", "thumbv7em-none-eabi"), + ("nrf52811-hal", "thumbv7em-none-eabi"), ("nrf52832-hal", "thumbv7em-none-eabihf"), ("nrf52833-hal", "thumbv7em-none-eabihf"), ("nrf52840-hal", "thumbv7em-none-eabihf"), @@ -11,17 +12,23 @@ pub static HALS: &[(&str, &str)] = &[ pub static EXAMPLES: &[(&str, &[&str])] = &[ ("blinky-button-demo", &[]), - ("ccm-demo", &["52810", "52832", "52833", "52840"]), + ("ccm-demo", &["52810", "52811", "52832", "52833", "52840"]), ("comp-demo", &[]), - ("ecb-demo", &["51", "52810", "52832", "52833", "52840"]), + ( + "ecb-demo", + &["51", "52810", "52811", "52832", "52833", "52840"], + ), ("gpiote-demo", &[]), ("i2s-controller-demo", &[]), ("i2s-peripheral-demo", &[]), ("lpcomp-demo", &[]), - ("ppi-demo", &["51", "52810", "52832", "52833", "52840"]), + ( + "ppi-demo", + &["51", "52810", "52811", "52832", "52833", "52840"], + ), ("pwm-demo", &[]), ("qdec-demo", &[]), - ("rtic-demo", &["51", "52810", "52832", "52840"]), + ("rtic-demo", &["51", "52810", "52811", "52832", "52840"]), ("spi-demo", &[]), ("spis-demo", &[]), ("twi-ssd1306", &["52832", "52840"]), @@ -33,7 +40,7 @@ pub static EXAMPLES: &[(&str, &[&str])] = &[ pub fn feature_to_target(feat: &str) -> &str { match feat { "51" => "thumbv6m-none-eabi", - "52810" => "thumbv7em-none-eabi", + "52810" | "52811" => "thumbv7em-none-eabi", _ if feat.starts_with("52") => "thumbv7em-none-eabihf", _ => panic!("unknown Cargo feature `{}`", feat), }