diff --git a/ci.sh b/ci.sh index 1085ad96..ff33c8ad 100755 --- a/ci.sh +++ b/ci.sh @@ -59,6 +59,7 @@ cargo batch \ --- 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 \ --- 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 \ --- 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 \ + --- 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 \ --- build --release --manifest-path embassy-boot/nrf/Cargo.toml --target thumbv7em-none-eabi --features embassy-nrf/nrf52840 \ --- build --release --manifest-path embassy-boot/stm32/Cargo.toml --target thumbv7em-none-eabi --features embassy-stm32/stm32wl55jc-cm4,embassy/time-tick-32768hz \ --- 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 b6982e91..f7a5da0a 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -424,9 +424,14 @@ pub(crate) mod sealed { } } + #[inline] + unsafe fn set_as_af(&self, af_num: u8, af_type: AFType) { + self.set_as_af_pull(af_num, af_type, Pull::None); + } + #[cfg(gpio_v1)] #[inline] - unsafe fn set_as_af(&self, _af_num: u8, af_type: AFType) { + unsafe fn set_as_af_pull(&self, _af_num: u8, af_type: AFType, pull: Pull) { // F1 uses the AFIO register for remapping. // For now, this is not implemented, so af_num is ignored // _af_num should be zero here, since it is not set by stm32-data @@ -435,9 +440,21 @@ pub(crate) mod sealed { let crlh = if n < 8 { 0 } else { 1 }; match af_type { AFType::Input => { + let cnf = match pull { + Pull::Up => { + r.bsrr().write(|w| w.set_bs(n, true)); + vals::CnfIn::PULL + } + Pull::Down => { + r.bsrr().write(|w| w.set_br(n, true)); + vals::CnfIn::PULL + } + Pull::None => vals::CnfIn::FLOATING, + }; + r.cr(crlh).modify(|w| { w.set_mode(n % 8, vals::Mode::INPUT); - w.set_cnf_in(n % 8, vals::CnfIn::FLOATING); + w.set_cnf_in(n % 8, cnf); }); } AFType::OutputPushPull => { @@ -455,12 +472,6 @@ pub(crate) mod sealed { } } - #[cfg(gpio_v2)] - #[inline] - unsafe fn set_as_af(&self, af_num: u8, af_type: AFType) { - self.set_as_af_pull(af_num, af_type, Pull::None); - } - #[cfg(gpio_v2)] #[inline] unsafe fn set_as_af_pull(&self, af_num: u8, af_type: AFType, pull: Pull) { diff --git a/examples/stm32h7/src/bin/signal.rs b/examples/stm32h7/src/bin/signal.rs new file mode 100644 index 00000000..d2531b2b --- /dev/null +++ b/examples/stm32h7/src/bin/signal.rs @@ -0,0 +1,41 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +// global logger +use defmt::{info, unwrap}; +use defmt_rtt as _; + +use panic_probe as _; + +use embassy::channel::Signal; +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; + +use embassy_stm32::Peripherals; + +static SIGNAL: Signal = Signal::new(); + +#[embassy::task] +async fn my_sending_task() { + let mut counter: u32 = 0; + + loop { + Timer::after(Duration::from_secs(1)).await; + + SIGNAL.signal(counter); + + counter = counter.wrapping_add(1); + } +} + +#[embassy::main] +async fn main(spawner: Spawner, _p: Peripherals) { + unwrap!(spawner.spawn(my_sending_task())); + + loop { + let received_counter = SIGNAL.wait().await; + + info!("signalled, counter: {}", received_counter); + } +}