aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaleb Garrett <[email protected]>2024-02-04 17:24:11 -0500
committerGitHub <[email protected]>2024-02-04 17:24:11 -0500
commite1f6f4b31d3c8e4b892b6277fe1f53a85d0f456c (patch)
tree2f60bff5c7dbc39d39435d8f23beae48411875f7
parenta260c0a701b0385691b57a22a19d86d7ce4788b8 (diff)
parentfc8b1646e741aa525d6188d61fa1dddb32f94217 (diff)
Merge branch 'main' into hash
-rwxr-xr-xci.sh6
-rw-r--r--embassy-nrf/src/gpiote.rs58
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/src/rcc/f0.rs33
-rw-r--r--embassy-stm32/src/rcc/l.rs19
-rw-r--r--embassy-stm32/src/rcc/mod.rs5
-rw-r--r--examples/nrf51/Cargo.toml2
-rw-r--r--tests/nrf51422/Cargo.toml3
-rw-r--r--tests/nrf51422/src/bin/gpiote.rs47
9 files changed, 147 insertions, 30 deletions
diff --git a/ci.sh b/ci.sh
index 6a5e6e3f5..df9e09848 100755
--- a/ci.sh
+++ b/ci.sh
@@ -47,6 +47,7 @@ cargo batch \
47 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip \ 47 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip \
48 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet \ 48 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet \
49 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154 \ 49 --- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip,medium-ethernet,medium-ieee802154 \
50 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv6m-none-eabi --features nrf51,gpiote,time,time-driver-rtc1 \
50 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time,time-driver-rtc1 \ 51 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time,time-driver-rtc1 \
51 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time,time-driver-rtc1 \ 52 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time,time-driver-rtc1 \
52 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time,time-driver-rtc1 \ 53 --- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52811,gpiote,time,time-driver-rtc1 \
@@ -84,6 +85,9 @@ cargo batch \
84 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \ 85 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
85 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \ 86 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \
86 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \ 87 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \
88 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f038f6,defmt,exti,time-driver-any,time \
89 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f042g4,defmt,exti,time-driver-any,time \
90 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f072c8,defmt,exti,time-driver-any,time \
87 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \ 91 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \
88 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \ 92 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \
89 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \ 93 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \
@@ -110,6 +114,7 @@ cargo batch \
110 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \ 114 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
111 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \ 115 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \
112 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \ 116 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \
117 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l431cb,defmt,exti,time-driver-any,time \
113 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \ 118 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
114 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \ 119 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \
115 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \ 120 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \
@@ -132,6 +137,7 @@ cargo batch \
132 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f100c4,defmt,exti,time-driver-any,time \ 137 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f100c4,defmt,exti,time-driver-any,time \
133 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h503rb,defmt,exti,time-driver-any,time \ 138 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h503rb,defmt,exti,time-driver-any,time \
134 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h562ag,defmt,exti,time-driver-any,time \ 139 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h562ag,defmt,exti,time-driver-any,time \
140 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32wb35ce,defmt,exti,time-driver-any,time \
135 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features ''\ 141 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features ''\
136 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'log' \ 142 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'log' \
137 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt' \ 143 --- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt' \
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs
index a459446a2..12f4ed0a0 100644
--- a/embassy-nrf/src/gpiote.rs
+++ b/embassy-nrf/src/gpiote.rs
@@ -13,6 +13,10 @@ use crate::interrupt::InterruptExt;
13use crate::ppi::{Event, Task}; 13use crate::ppi::{Event, Task};
14use crate::{interrupt, pac, peripherals}; 14use crate::{interrupt, pac, peripherals};
15 15
16#[cfg(feature = "nrf51")]
17/// Amount of GPIOTE channels in the chip.
18const CHANNEL_COUNT: usize = 4;
19#[cfg(not(feature = "_nrf51"))]
16/// Amount of GPIOTE channels in the chip. 20/// Amount of GPIOTE channels in the chip.
17const CHANNEL_COUNT: usize = 8; 21const CHANNEL_COUNT: usize = 8;
18 22
@@ -61,16 +65,20 @@ fn regs() -> &'static pac::gpiote::RegisterBlock {
61} 65}
62 66
63pub(crate) fn init(irq_prio: crate::interrupt::Priority) { 67pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
64 #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] 68 // no latched GPIO detect in nrf51.
65 let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] }; 69 #[cfg(not(feature = "_nrf51"))]
66 #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] 70 {
67 let ports = unsafe { &[&*pac::P0::ptr()] }; 71 #[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
68 72 let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] };
69 for &p in ports { 73 #[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
70 // Enable latched detection 74 let ports = unsafe { &[&*pac::P0::ptr()] };
71 p.detectmode.write(|w| w.detectmode().ldetect()); 75
72 // Clear latch 76 for &p in ports {
73 p.latch.write(|w| unsafe { w.bits(0xFFFFFFFF) }) 77 // Enable latched detection
78 p.detectmode.write(|w| w.detectmode().ldetect());
79 // Clear latch
80 p.latch.write(|w| unsafe { w.bits(0xFFFFFFFF) })
81 }
74 } 82 }
75 83
76 // Enable interrupts 84 // Enable interrupts
@@ -78,7 +86,7 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
78 let irq = interrupt::GPIOTE0; 86 let irq = interrupt::GPIOTE0;
79 #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))] 87 #[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))]
80 let irq = interrupt::GPIOTE1; 88 let irq = interrupt::GPIOTE1;
81 #[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] 89 #[cfg(any(feature = "_nrf51", feature = "_nrf52", feature = "nrf5340-net"))]
82 let irq = interrupt::GPIOTE; 90 let irq = interrupt::GPIOTE;
83 91
84 irq.unpend(); 92 irq.unpend();
@@ -103,7 +111,7 @@ fn GPIOTE1() {
103 unsafe { handle_gpiote_interrupt() }; 111 unsafe { handle_gpiote_interrupt() };
104} 112}
105 113
106#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))] 114#[cfg(any(feature = "_nrf51", feature = "_nrf52", feature = "nrf5340-net"))]
107#[cfg(feature = "rt")] 115#[cfg(feature = "rt")]
108#[interrupt] 116#[interrupt]
109fn GPIOTE() { 117fn GPIOTE() {
@@ -125,9 +133,29 @@ unsafe fn handle_gpiote_interrupt() {
125 133
126 #[cfg(any(feature = "nrf52833", feature = "nrf52840"))] 134 #[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
127 let ports = &[&*pac::P0::ptr(), &*pac::P1::ptr()]; 135 let ports = &[&*pac::P0::ptr(), &*pac::P1::ptr()];
128 #[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))] 136 #[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
129 let ports = &[&*pac::P0::ptr()]; 137 let ports = &[&*pac::P0::ptr()];
138 #[cfg(feature = "_nrf51")]
139 let ports = unsafe { &[&*pac::GPIO::ptr()] };
140
141 #[cfg(feature = "_nrf51")]
142 for (port, &p) in ports.iter().enumerate() {
143 let inp = p.in_.read().bits();
144 for pin in 0..32 {
145 let fired = match p.pin_cnf[pin as usize].read().sense().variant() {
146 Some(pac::gpio::pin_cnf::SENSE_A::HIGH) => inp & (1 << pin) != 0,
147 Some(pac::gpio::pin_cnf::SENSE_A::LOW) => inp & (1 << pin) == 0,
148 _ => false,
149 };
150
151 if fired {
152 PORT_WAKERS[port * 32 + pin as usize].wake();
153 p.pin_cnf[pin as usize].modify(|_, w| w.sense().disabled());
154 }
155 }
156 }
130 157
158 #[cfg(not(feature = "_nrf51"))]
131 for (port, &p) in ports.iter().enumerate() { 159 for (port, &p) in ports.iter().enumerate() {
132 let bits = p.latch.read().bits(); 160 let bits = p.latch.read().bits();
133 for pin in BitIter(bits) { 161 for pin in BitIter(bits) {
@@ -476,9 +504,13 @@ impl_channel!(GPIOTE_CH0, 0);
476impl_channel!(GPIOTE_CH1, 1); 504impl_channel!(GPIOTE_CH1, 1);
477impl_channel!(GPIOTE_CH2, 2); 505impl_channel!(GPIOTE_CH2, 2);
478impl_channel!(GPIOTE_CH3, 3); 506impl_channel!(GPIOTE_CH3, 3);
507#[cfg(not(feature = "nrf51"))]
479impl_channel!(GPIOTE_CH4, 4); 508impl_channel!(GPIOTE_CH4, 4);
509#[cfg(not(feature = "nrf51"))]
480impl_channel!(GPIOTE_CH5, 5); 510impl_channel!(GPIOTE_CH5, 5);
511#[cfg(not(feature = "nrf51"))]
481impl_channel!(GPIOTE_CH6, 6); 512impl_channel!(GPIOTE_CH6, 6);
513#[cfg(not(feature = "nrf51"))]
482impl_channel!(GPIOTE_CH7, 7); 514impl_channel!(GPIOTE_CH7, 7);
483 515
484// ==================== 516// ====================
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index 698febf71..63bc32197 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -68,7 +68,7 @@ rand_core = "0.6.3"
68sdio-host = "0.5.0" 68sdio-host = "0.5.0"
69critical-section = "1.1" 69critical-section = "1.1"
70#stm32-metapac = { version = "15" } 70#stm32-metapac = { version = "15" }
71stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-0cb3a4fcaec702c93b3700715de796636d562b15" } 71stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-aa5dbf859fae743306f5d816905f166de824241f" }
72vcell = "0.1.3" 72vcell = "0.1.3"
73bxcan = "0.7.0" 73bxcan = "0.7.0"
74nb = "1.0.0" 74nb = "1.0.0"
@@ -89,7 +89,7 @@ critical-section = { version = "1.1", features = ["std"] }
89proc-macro2 = "1.0.36" 89proc-macro2 = "1.0.36"
90quote = "1.0.15" 90quote = "1.0.15"
91#stm32-metapac = { version = "15", default-features = false, features = ["metadata"]} 91#stm32-metapac = { version = "15", default-features = false, features = ["metadata"]}
92stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-0cb3a4fcaec702c93b3700715de796636d562b15", default-features = false, features = ["metadata"]} 92stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-aa5dbf859fae743306f5d816905f166de824241f", default-features = false, features = ["metadata"]}
93 93
94 94
95[features] 95[features]
diff --git a/embassy-stm32/src/rcc/f0.rs b/embassy-stm32/src/rcc/f0.rs
index a6b627887..1042a1cb2 100644
--- a/embassy-stm32/src/rcc/f0.rs
+++ b/embassy-stm32/src/rcc/f0.rs
@@ -11,14 +11,13 @@ pub const HSI_FREQ: Hertz = Hertz(8_000_000);
11/// 11///
12/// hse takes precedence over hsi48 if both are enabled 12/// hse takes precedence over hsi48 if both are enabled
13#[non_exhaustive] 13#[non_exhaustive]
14#[derive(Default)]
15pub struct Config { 14pub struct Config {
16 pub hse: Option<Hertz>, 15 pub hse: Option<Hertz>,
17 pub bypass_hse: bool, 16 pub bypass_hse: bool,
18 pub usb_pll: bool, 17 pub usb_pll: bool,
19 18
20 #[cfg(not(stm32f0x0))] 19 #[cfg(crs)]
21 pub hsi48: bool, 20 pub hsi48: Option<super::Hsi48Config>,
22 21
23 pub sys_ck: Option<Hertz>, 22 pub sys_ck: Option<Hertz>,
24 pub hclk: Option<Hertz>, 23 pub hclk: Option<Hertz>,
@@ -27,12 +26,32 @@ pub struct Config {
27 pub ls: super::LsConfig, 26 pub ls: super::LsConfig,
28} 27}
29 28
29impl Default for Config {
30 fn default() -> Self {
31 Self {
32 hse: Default::default(),
33 bypass_hse: Default::default(),
34 usb_pll: Default::default(),
35 #[cfg(crs)]
36 hsi48: Some(Default::default()),
37 sys_ck: Default::default(),
38 hclk: Default::default(),
39 pclk: Default::default(),
40 ls: Default::default(),
41 }
42 }
43}
44
30pub(crate) unsafe fn init(config: Config) { 45pub(crate) unsafe fn init(config: Config) {
31 let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0); 46 let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0);
32 47
48 #[cfg(crs)]
49 let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
50 #[cfg(not(crs))]
51 let hsi48: Option<Hertz> = None;
52
33 let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| { 53 let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| {
34 #[cfg(not(stm32f0x0))] 54 if hsi48.is_some() {
35 if config.hsi48 {
36 return (48_000_000, true); 55 return (48_000_000, true);
37 } 56 }
38 (HSI_FREQ.0, false) 57 (HSI_FREQ.0, false)
@@ -169,5 +188,9 @@ pub(crate) unsafe fn init(config: Config) {
169 pclk2_tim: Some(Hertz(pclk * timer_mul)), 188 pclk2_tim: Some(Hertz(pclk * timer_mul)),
170 hclk1: Some(Hertz(hclk)), 189 hclk1: Some(Hertz(hclk)),
171 rtc: rtc, 190 rtc: rtc,
191 hsi48: hsi48,
192
193 // TODO:
194 pll1_p: None,
172 ); 195 );
173} 196}
diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs
index ab1681dd4..04ea81ec4 100644
--- a/embassy-stm32/src/rcc/l.rs
+++ b/embassy-stm32/src/rcc/l.rs
@@ -215,12 +215,9 @@ pub(crate) unsafe fn init(config: Config) {
215 }); 215 });
216 216
217 #[cfg(crs)] 217 #[cfg(crs)]
218 let _hsi48 = config.hsi48.map(|config| { 218 let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
219 //
220 super::init_hsi48(config)
221 });
222 #[cfg(not(crs))] 219 #[cfg(not(crs))]
223 let _hsi48: Option<Hertz> = None; 220 let hsi48: Option<Hertz> = None;
224 221
225 let _plls = [ 222 let _plls = [
226 &config.pll, 223 &config.pll,
@@ -274,12 +271,12 @@ pub(crate) unsafe fn init(config: Config) {
274 RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src)); 271 RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src));
275 #[cfg(any(rcc_l0_v2))] 272 #[cfg(any(rcc_l0_v2))]
276 let clk48 = match config.clk48_src { 273 let clk48 = match config.clk48_src {
277 Clk48Src::HSI48 => _hsi48, 274 Clk48Src::HSI48 => hsi48,
278 Clk48Src::PLL1_VCO_DIV_2 => pll.clk48, 275 Clk48Src::PLL1_VCO_DIV_2 => pll.clk48,
279 }; 276 };
280 #[cfg(any(stm32l4, stm32l5, stm32wb))] 277 #[cfg(any(stm32l4, stm32l5, stm32wb))]
281 let clk48 = match config.clk48_src { 278 let clk48 = match config.clk48_src {
282 Clk48Src::HSI48 => _hsi48, 279 Clk48Src::HSI48 => hsi48,
283 Clk48Src::MSI => msi, 280 Clk48Src::MSI => msi,
284 Clk48Src::PLLSAI1_Q => pllsai1.q, 281 Clk48Src::PLLSAI1_Q => pllsai1.q,
285 Clk48Src::PLL1_Q => pll.q, 282 Clk48Src::PLL1_Q => pll.q,
@@ -393,6 +390,7 @@ pub(crate) unsafe fn init(config: Config) {
393 msi: msi, 390 msi: msi,
394 #[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))] 391 #[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))]
395 clk48: clk48, 392 clk48: clk48,
393 hsi48: hsi48,
396 394
397 #[cfg(not(any(stm32l0, stm32l1)))] 395 #[cfg(not(any(stm32l0, stm32l1)))]
398 pll1_p: pll.p, 396 pll1_p: pll.p,
@@ -407,6 +405,13 @@ pub(crate) unsafe fn init(config: Config) {
407 #[cfg(any(stm32l4, stm32l5, stm32wb))] 405 #[cfg(any(stm32l4, stm32l5, stm32wb))]
408 pllsai1_r: pllsai1.r, 406 pllsai1_r: pllsai1.r,
409 407
408 #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
409 pllsai2_p: None,
410 #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
411 pllsai2_q: None,
412 #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
413 pllsai2_r: None,
414
410 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))] 415 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
411 pllsai2_p: pllsai2.p, 416 pllsai2_p: pllsai2.p,
412 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))] 417 #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 280da7ae3..05937cc5d 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -6,8 +6,11 @@
6use core::mem::MaybeUninit; 6use core::mem::MaybeUninit;
7 7
8mod bd; 8mod bd;
9mod mco;
10pub use bd::*; 9pub use bd::*;
10
11#[cfg(any(mco, mco1, mco2))]
12mod mco;
13#[cfg(any(mco, mco1, mco2))]
11pub use mco::*; 14pub use mco::*;
12 15
13#[cfg(crs)] 16#[cfg(crs)]
diff --git a/examples/nrf51/Cargo.toml b/examples/nrf51/Cargo.toml
index d1e919a33..06c3d20cb 100644
--- a/examples/nrf51/Cargo.toml
+++ b/examples/nrf51/Cargo.toml
@@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-4096", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } 8embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-4096", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
9embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 9embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
10embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "rt"] } 10embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] }
11 11
12defmt = "0.3" 12defmt = "0.3"
13defmt-rtt = "0.4" 13defmt-rtt = "0.4"
diff --git a/tests/nrf51422/Cargo.toml b/tests/nrf51422/Cargo.toml
index 2cab20ac0..07236987b 100644
--- a/tests/nrf51422/Cargo.toml
+++ b/tests/nrf51422/Cargo.toml
@@ -7,10 +7,11 @@ license = "MIT OR Apache-2.0"
7[dependencies] 7[dependencies]
8teleprobe-meta = "1" 8teleprobe-meta = "1"
9 9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
10embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] } 11embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] }
11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] } 12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
12embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } 13embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
13embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time"] } 14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
14embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } 15embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
15embedded-hal-async = { version = "1.0" } 16embedded-hal-async = { version = "1.0" }
16 17
diff --git a/tests/nrf51422/src/bin/gpiote.rs b/tests/nrf51422/src/bin/gpiote.rs
new file mode 100644
index 000000000..330fe993e
--- /dev/null
+++ b/tests/nrf51422/src/bin/gpiote.rs
@@ -0,0 +1,47 @@
1#![no_std]
2#![no_main]
3teleprobe_meta::target!(b"nrf51-dk");
4
5use defmt::{assert, info};
6use embassy_executor::Spawner;
7use embassy_futures::join::join;
8use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
9use embassy_time::{Duration, Instant, Timer};
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 let p = embassy_nrf::init(Default::default());
15
16 let mut input = Input::new(p.P0_13, Pull::Up);
17 let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
18
19 let fut1 = async {
20 Timer::after_millis(100).await;
21 output.set_high();
22 };
23 let fut2 = async {
24 let start = Instant::now();
25 input.wait_for_high().await;
26 let dur = Instant::now() - start;
27 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
28 };
29
30 join(fut1, fut2).await;
31
32 let fut1 = async {
33 Timer::after_millis(100).await;
34 output.set_low();
35 };
36 let fut2 = async {
37 let start = Instant::now();
38 input.wait_for_low().await;
39 let dur = Instant::now() - start;
40 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
41 };
42
43 join(fut1, fut2).await;
44
45 info!("Test OK");
46 cortex_m::asm::bkpt();
47}