Initial support for nrf9160
This commit is contained in:
@ -34,6 +34,7 @@ pub mod ppi;
|
||||
pub mod pwm;
|
||||
#[cfg(feature = "nrf52840")]
|
||||
pub mod qspi;
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
pub mod rng;
|
||||
#[cfg(not(feature = "nrf52820"))]
|
||||
pub mod saadc;
|
||||
@ -65,6 +66,9 @@ mod chip;
|
||||
#[cfg(feature = "nrf52840")]
|
||||
#[path = "chips/nrf52840.rs"]
|
||||
mod chip;
|
||||
#[cfg(feature = "nrf9160")]
|
||||
#[path = "chips/nrf9160.rs"]
|
||||
mod chip;
|
||||
|
||||
pub use chip::EASY_DMA_SIZE;
|
||||
|
||||
@ -75,6 +79,11 @@ pub(crate) use chip::pac;
|
||||
|
||||
pub use chip::{peripherals, Peripherals};
|
||||
|
||||
#[cfg(feature = "nrf9160")]
|
||||
use crate::pac::CLOCK_NS as CLOCK;
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
use crate::pac::CLOCK;
|
||||
|
||||
pub mod interrupt {
|
||||
pub use crate::chip::irqs::*;
|
||||
pub use cortex_m::interrupt::{CriticalSection, Mutex};
|
||||
@ -91,9 +100,12 @@ pub mod config {
|
||||
|
||||
pub enum LfclkSource {
|
||||
InternalRC,
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
Synthesized,
|
||||
ExternalXtal,
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
ExternalLowSwing,
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
ExternalFullSwing,
|
||||
}
|
||||
|
||||
@ -129,7 +141,7 @@ pub fn init(config: config::Config) -> Peripherals {
|
||||
// before doing anything important.
|
||||
let peripherals = Peripherals::take();
|
||||
|
||||
let r = unsafe { &*pac::CLOCK::ptr() };
|
||||
let r = unsafe { &*CLOCK::ptr() };
|
||||
|
||||
// Start HFCLK.
|
||||
match config.hfclk_source {
|
||||
@ -143,6 +155,7 @@ pub fn init(config: config::Config) -> Peripherals {
|
||||
}
|
||||
|
||||
// Configure LFCLK.
|
||||
#[cfg(not(feature = "nrf9160"))]
|
||||
match config.lfclk_source {
|
||||
config::LfclkSource::InternalRC => r.lfclksrc.write(|w| w.src().rc()),
|
||||
config::LfclkSource::Synthesized => r.lfclksrc.write(|w| w.src().synth()),
|
||||
@ -162,6 +175,11 @@ pub fn init(config: config::Config) -> Peripherals {
|
||||
w
|
||||
}),
|
||||
}
|
||||
#[cfg(feature = "nrf9160")]
|
||||
match config.lfclk_source {
|
||||
config::LfclkSource::InternalRC => r.lfclksrc.write(|w| w.src().lfrc()),
|
||||
config::LfclkSource::ExternalXtal => r.lfclksrc.write(|w| w.src().lfxo()),
|
||||
}
|
||||
|
||||
// Start LFCLK.
|
||||
// Datasheet says this could take 100us from synth source
|
||||
|
Reference in New Issue
Block a user