2020-09-22 18:03:43 +02:00
|
|
|
#![no_std]
|
|
|
|
#![feature(generic_associated_types)]
|
|
|
|
#![feature(asm)]
|
2021-03-17 02:48:16 +01:00
|
|
|
#![feature(min_type_alias_impl_trait)]
|
|
|
|
#![feature(impl_trait_in_bindings)]
|
2020-09-22 18:03:43 +02:00
|
|
|
#![feature(type_alias_impl_trait)]
|
2021-02-26 01:06:58 +01:00
|
|
|
#![allow(incomplete_features)]
|
2020-09-22 18:03:43 +02:00
|
|
|
|
|
|
|
#[cfg(not(any(
|
2020-09-24 19:56:47 +02:00
|
|
|
feature = "52810",
|
|
|
|
feature = "52811",
|
|
|
|
feature = "52832",
|
|
|
|
feature = "52833",
|
|
|
|
feature = "52840",
|
2020-09-22 18:03:43 +02:00
|
|
|
)))]
|
2020-09-24 19:56:47 +02:00
|
|
|
compile_error!("No chip feature activated. You must activate exactly one of the following features: 52810, 52811, 52832, 52833, 52840");
|
2020-09-22 18:03:43 +02:00
|
|
|
|
|
|
|
#[cfg(any(
|
2020-09-24 19:56:47 +02:00
|
|
|
all(feature = "52810", feature = "52811"),
|
|
|
|
all(feature = "52810", feature = "52832"),
|
|
|
|
all(feature = "52810", feature = "52833"),
|
|
|
|
all(feature = "52810", feature = "52840"),
|
|
|
|
all(feature = "52811", feature = "52832"),
|
|
|
|
all(feature = "52811", feature = "52833"),
|
|
|
|
all(feature = "52811", feature = "52840"),
|
|
|
|
all(feature = "52832", feature = "52833"),
|
|
|
|
all(feature = "52832", feature = "52840"),
|
|
|
|
all(feature = "52833", feature = "52840"),
|
2020-09-22 18:03:43 +02:00
|
|
|
))]
|
2020-09-24 19:56:47 +02:00
|
|
|
compile_error!("Multile chip features activated. You must activate exactly one of the following features: 52810, 52811, 52832, 52833, 52840");
|
2020-09-22 18:03:43 +02:00
|
|
|
|
2020-09-24 19:56:47 +02:00
|
|
|
#[cfg(feature = "52810")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub use nrf52810_pac as pac;
|
2020-09-24 19:56:47 +02:00
|
|
|
#[cfg(feature = "52811")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub use nrf52811_pac as pac;
|
2020-09-24 19:56:47 +02:00
|
|
|
#[cfg(feature = "52832")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub use nrf52832_pac as pac;
|
2020-09-24 19:56:47 +02:00
|
|
|
#[cfg(feature = "52833")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub use nrf52833_pac as pac;
|
2020-09-24 19:56:47 +02:00
|
|
|
#[cfg(feature = "52840")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub use nrf52840_pac as pac;
|
|
|
|
|
2020-10-31 23:03:09 +01:00
|
|
|
#[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")]
|
|
|
|
pub use nrf52833_hal as hal;
|
|
|
|
#[cfg(feature = "52840")]
|
|
|
|
pub use nrf52840_hal as hal;
|
|
|
|
|
2021-01-18 14:22:55 +01:00
|
|
|
/// Length of Nordic EasyDMA differs for MCUs
|
|
|
|
#[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;
|
|
|
|
// Easy DMA can only read from data ram
|
|
|
|
pub const SRAM_LOWER: usize = 0x2000_0000;
|
|
|
|
pub const SRAM_UPPER: usize = 0x3000_0000;
|
|
|
|
}
|
|
|
|
#[cfg(any(feature = "52840", feature = "52833", feature = "9160"))]
|
|
|
|
pub mod target_constants {
|
|
|
|
// NRF52840 and NRF9160 16 bits 1..0xFFFF
|
|
|
|
pub const EASY_DMA_SIZE: usize = 65535;
|
|
|
|
// Limits for Easy DMA - it can only read from data ram
|
|
|
|
pub const SRAM_LOWER: usize = 0x2000_0000;
|
|
|
|
pub const SRAM_UPPER: usize = 0x3000_0000;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Does this slice reside entirely within RAM?
|
|
|
|
pub(crate) fn slice_in_ram(slice: &[u8]) -> bool {
|
|
|
|
let ptr = slice.as_ptr() as usize;
|
|
|
|
ptr >= target_constants::SRAM_LOWER && (ptr + slice.len()) < target_constants::SRAM_UPPER
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Return an error if slice is not in RAM.
|
|
|
|
#[cfg(not(feature = "51"))]
|
|
|
|
pub(crate) fn slice_in_ram_or<T>(slice: &[u8], err: T) -> Result<(), T> {
|
|
|
|
if slice.len() == 0 || slice_in_ram(slice) {
|
|
|
|
Ok(())
|
|
|
|
} else {
|
|
|
|
Err(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-01 17:46:56 +01:00
|
|
|
// This mod MUST go first, so that the others see its macros.
|
|
|
|
pub(crate) mod fmt;
|
|
|
|
|
2020-12-28 23:57:50 +01:00
|
|
|
pub mod buffered_uarte;
|
2020-09-23 00:32:49 +02:00
|
|
|
pub mod gpiote;
|
2020-09-22 18:03:43 +02:00
|
|
|
pub mod interrupt;
|
2020-10-31 23:03:09 +01:00
|
|
|
#[cfg(feature = "52840")]
|
2020-09-22 18:03:43 +02:00
|
|
|
pub mod qspi;
|
2020-09-24 19:59:20 +02:00
|
|
|
pub mod rtc;
|
2021-01-18 14:22:55 +01:00
|
|
|
pub mod spim;
|
2020-12-23 16:18:29 +01:00
|
|
|
pub mod uarte;
|