aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xci.sh1
-rw-r--r--embassy-stm32/src/gpio.rs27
-rw-r--r--examples/stm32h7/src/bin/signal.rs41
3 files changed, 61 insertions, 8 deletions
diff --git a/ci.sh b/ci.sh
index 1085ad960..ff33c8ad1 100755
--- a/ci.sh
+++ b/ci.sh
@@ -59,6 +59,7 @@ cargo batch \
59 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ 59 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \
60 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ 60 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wle5ub,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \
61 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \ 61 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f107vc,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \
62 --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f103re,defmt,exti,time-driver-any,embassy/time-tick-32768hz,unstable-traits \
62 --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ 63 --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \
63 --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \ 64 --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \
64 --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ 65 --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs
index b6982e91a..f7a5da0a8 100644
--- a/embassy-stm32/src/gpio.rs
+++ b/embassy-stm32/src/gpio.rs
@@ -424,9 +424,14 @@ pub(crate) mod sealed {
424 } 424 }
425 } 425 }
426 426
427 #[inline]
428 unsafe fn set_as_af(&self, af_num: u8, af_type: AFType) {
429 self.set_as_af_pull(af_num, af_type, Pull::None);
430 }
431
427 #[cfg(gpio_v1)] 432 #[cfg(gpio_v1)]
428 #[inline] 433 #[inline]
429 unsafe fn set_as_af(&self, _af_num: u8, af_type: AFType) { 434 unsafe fn set_as_af_pull(&self, _af_num: u8, af_type: AFType, pull: Pull) {
430 // F1 uses the AFIO register for remapping. 435 // F1 uses the AFIO register for remapping.
431 // For now, this is not implemented, so af_num is ignored 436 // For now, this is not implemented, so af_num is ignored
432 // _af_num should be zero here, since it is not set by stm32-data 437 // _af_num should be zero here, since it is not set by stm32-data
@@ -435,9 +440,21 @@ pub(crate) mod sealed {
435 let crlh = if n < 8 { 0 } else { 1 }; 440 let crlh = if n < 8 { 0 } else { 1 };
436 match af_type { 441 match af_type {
437 AFType::Input => { 442 AFType::Input => {
443 let cnf = match pull {
444 Pull::Up => {
445 r.bsrr().write(|w| w.set_bs(n, true));
446 vals::CnfIn::PULL
447 }
448 Pull::Down => {
449 r.bsrr().write(|w| w.set_br(n, true));
450 vals::CnfIn::PULL
451 }
452 Pull::None => vals::CnfIn::FLOATING,
453 };
454
438 r.cr(crlh).modify(|w| { 455 r.cr(crlh).modify(|w| {
439 w.set_mode(n % 8, vals::Mode::INPUT); 456 w.set_mode(n % 8, vals::Mode::INPUT);
440 w.set_cnf_in(n % 8, vals::CnfIn::FLOATING); 457 w.set_cnf_in(n % 8, cnf);
441 }); 458 });
442 } 459 }
443 AFType::OutputPushPull => { 460 AFType::OutputPushPull => {
@@ -457,12 +474,6 @@ pub(crate) mod sealed {
457 474
458 #[cfg(gpio_v2)] 475 #[cfg(gpio_v2)]
459 #[inline] 476 #[inline]
460 unsafe fn set_as_af(&self, af_num: u8, af_type: AFType) {
461 self.set_as_af_pull(af_num, af_type, Pull::None);
462 }
463
464 #[cfg(gpio_v2)]
465 #[inline]
466 unsafe fn set_as_af_pull(&self, af_num: u8, af_type: AFType, pull: Pull) { 477 unsafe fn set_as_af_pull(&self, af_num: u8, af_type: AFType, pull: Pull) {
467 let pin = self._pin() as usize; 478 let pin = self._pin() as usize;
468 let block = self.block(); 479 let block = self.block();
diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs
new file mode 100644
index 000000000..d2531b2ba
--- /dev/null
+++ b/examples/stm32h7/src/bin/signal.rs
@@ -0,0 +1,41 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5// global logger
6use defmt::{info, unwrap};
7use defmt_rtt as _;
8
9use panic_probe as _;
10
11use embassy::channel::Signal;
12use embassy::executor::Spawner;
13use embassy::time::{Duration, Timer};
14
15use embassy_stm32::Peripherals;
16
17static SIGNAL: Signal<u32> = Signal::new();
18
19#[embassy::task]
20async fn my_sending_task() {
21 let mut counter: u32 = 0;
22
23 loop {
24 Timer::after(Duration::from_secs(1)).await;
25
26 SIGNAL.signal(counter);
27
28 counter = counter.wrapping_add(1);
29 }
30}
31
32#[embassy::main]
33async fn main(spawner: Spawner, _p: Peripherals) {
34 unwrap!(spawner.spawn(my_sending_task()));
35
36 loop {
37 let received_counter = SIGNAL.wait().await;
38
39 info!("signalled, counter: {}", received_counter);
40 }
41}