aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/lib.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-10-28 03:07:06 +0200
committerDario Nieuwenhuis <[email protected]>2021-10-28 03:36:25 +0200
commit663141b4e456bbfacaaff8decdba6840c76a136b (patch)
tree8d151a795b008ab0791a6faa5dbd36e5b83522b5 /embassy-nrf/src/lib.rs
parentc995a97f2032d329c2955c79054b7e466b0b423b (diff)
nrf: add initial nrf5340 support
Diffstat (limited to 'embassy-nrf/src/lib.rs')
-rw-r--r--embassy-nrf/src/lib.rs27
1 files changed, 15 insertions, 12 deletions
diff --git a/embassy-nrf/src/lib.rs b/embassy-nrf/src/lib.rs
index 05bdd1904..5a73b87e0 100644
--- a/embassy-nrf/src/lib.rs
+++ b/embassy-nrf/src/lib.rs
@@ -12,7 +12,8 @@
12 feature = "nrf52832", 12 feature = "nrf52832",
13 feature = "nrf52833", 13 feature = "nrf52833",
14 feature = "nrf52840", 14 feature = "nrf52840",
15 feature = "nrf5340-app", 15 feature = "nrf5340-app-s",
16 feature = "nrf5340-app-ns",
16 feature = "nrf5340-net", 17 feature = "nrf5340-net",
17 feature = "nrf9160-s", 18 feature = "nrf9160-s",
18 feature = "nrf9160-ns", 19 feature = "nrf9160-ns",
@@ -30,23 +31,24 @@ pub mod buffered_uarte;
30pub mod gpio; 31pub mod gpio;
31#[cfg(feature = "gpiote")] 32#[cfg(feature = "gpiote")]
32pub mod gpiote; 33pub mod gpiote;
33#[cfg(not(feature = "_nrf9160"))] 34#[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
34pub mod nvmc; 35pub mod nvmc;
35pub mod ppi; 36pub mod ppi;
36#[cfg(not(any(feature = "nrf52805", feature = "nrf52820")))] 37#[cfg(not(any(feature = "nrf52805", feature = "nrf52820", feature = "_nrf5340-net")))]
37pub mod pwm; 38pub mod pwm;
38#[cfg(feature = "nrf52840")] 39#[cfg(feature = "nrf52840")]
39pub mod qspi; 40pub mod qspi;
40#[cfg(not(feature = "_nrf9160"))] 41#[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
41pub mod rng; 42pub mod rng;
42#[cfg(not(feature = "nrf52820"))] 43#[cfg(not(any(feature = "nrf52820", feature = "_nrf5340-net")))]
43pub mod saadc; 44pub mod saadc;
44pub mod spim; 45pub mod spim;
45#[cfg(not(feature = "_nrf9160"))] 46#[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
46pub mod temp; 47pub mod temp;
47pub mod timer; 48pub mod timer;
48pub mod twim; 49pub mod twim;
49pub mod uarte; 50pub mod uarte;
51#[cfg(not(feature = "_nrf5340"))]
50pub mod wdt; 52pub mod wdt;
51 53
52// This mod MUST go last, so that it sees all the `impl_foo!` macros 54// This mod MUST go last, so that it sees all the `impl_foo!` macros
@@ -57,6 +59,8 @@ pub mod wdt;
57#[cfg_attr(feature = "nrf52832", path = "chips/nrf52832.rs")] 59#[cfg_attr(feature = "nrf52832", path = "chips/nrf52832.rs")]
58#[cfg_attr(feature = "nrf52833", path = "chips/nrf52833.rs")] 60#[cfg_attr(feature = "nrf52833", path = "chips/nrf52833.rs")]
59#[cfg_attr(feature = "nrf52840", path = "chips/nrf52840.rs")] 61#[cfg_attr(feature = "nrf52840", path = "chips/nrf52840.rs")]
62#[cfg_attr(feature = "_nrf5340-app", path = "chips/nrf5340_app.rs")]
63#[cfg_attr(feature = "_nrf5340-net", path = "chips/nrf5340_net.rs")]
60#[cfg_attr(feature = "_nrf9160", path = "chips/nrf9160.rs")] 64#[cfg_attr(feature = "_nrf9160", path = "chips/nrf9160.rs")]
61mod chip; 65mod chip;
62 66
@@ -67,7 +71,6 @@ pub use chip::pac;
67#[cfg(not(feature = "unstable-pac"))] 71#[cfg(not(feature = "unstable-pac"))]
68pub(crate) use chip::pac; 72pub(crate) use chip::pac;
69 73
70use crate::pac::CLOCK;
71pub use chip::{peripherals, Peripherals}; 74pub use chip::{peripherals, Peripherals};
72 75
73pub mod interrupt { 76pub mod interrupt {
@@ -86,12 +89,12 @@ pub mod config {
86 89
87 pub enum LfclkSource { 90 pub enum LfclkSource {
88 InternalRC, 91 InternalRC,
89 #[cfg(not(feature = "_nrf9160"))] 92 #[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
90 Synthesized, 93 Synthesized,
91 ExternalXtal, 94 ExternalXtal,
92 #[cfg(not(feature = "_nrf9160"))] 95 #[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
93 ExternalLowSwing, 96 ExternalLowSwing,
94 #[cfg(not(feature = "_nrf9160"))] 97 #[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
95 ExternalFullSwing, 98 ExternalFullSwing,
96 } 99 }
97 100
@@ -127,7 +130,7 @@ pub fn init(config: config::Config) -> Peripherals {
127 // before doing anything important. 130 // before doing anything important.
128 let peripherals = Peripherals::take(); 131 let peripherals = Peripherals::take();
129 132
130 let r = unsafe { &*CLOCK::ptr() }; 133 let r = unsafe { &*pac::CLOCK::ptr() };
131 134
132 // Start HFCLK. 135 // Start HFCLK.
133 match config.hfclk_source { 136 match config.hfclk_source {
@@ -141,7 +144,7 @@ pub fn init(config: config::Config) -> Peripherals {
141 } 144 }
142 145
143 // Configure LFCLK. 146 // Configure LFCLK.
144 #[cfg(not(feature = "_nrf9160"))] 147 #[cfg(not(any(feature = "_nrf5340", feature = "_nrf9160")))]
145 match config.lfclk_source { 148 match config.lfclk_source {
146 config::LfclkSource::InternalRC => r.lfclksrc.write(|w| w.src().rc()), 149 config::LfclkSource::InternalRC => r.lfclksrc.write(|w| w.src().rc()),
147 config::LfclkSource::Synthesized => r.lfclksrc.write(|w| w.src().synth()), 150 config::LfclkSource::Synthesized => r.lfclksrc.write(|w| w.src().synth()),