792: Add example for using a Signal. r=Dirbaio a=hydra

I didn't find an example, so I created one for the STM32H7.  Code based on the nrf mutex.rs example.

794: Fix F1 compilation by implementig AF pullup r=Dirbaio a=chemicstry

Embassy fails to compile on `STM32F103RET6`, because `set_as_af_pull` function is missing for GPIOv1:

```
error[E0599]: no method named `set_as_af_pull` found for mutable reference `&mut CLK` in the current scope
    --> C:\Users\chemi\.cargo\git\checkouts\embassy-0cff10c9b9902273\46473ae\embassy-stm32\src\sdmmc\mod.rs:1390:21
     |
1390 |             clk_pin.set_as_af_pull(clk_pin.af_num(), AFType::OutputPushPull, Pull::None);
     |                     ^^^^^^^^^^^^^^ method not found in `&mut CLK`
```

GPIOv1 actually supports pullups in AF mode, but only for inputs. The `sdmmc` driver, which was causing compile errors uses pullups for push-pull outputs and this will silently fail. But IMO not adding pullups to sdmmc interface is a hardware design problem, not HAL.

Co-authored-by: Dominic Clifton <me@dominicclifton.name>
Co-authored-by: chemicstry <chemicstry@gmail.com>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
bors[bot] 2022-06-06 15:45:03 +00:00 committed by GitHub
commit 62add4b2ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 61 additions and 8 deletions

1
ci.sh
View File

@ -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 \

View File

@ -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) {

View File

@ -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<u32> = 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);
}
}