Merge branch 'main' into hash
This commit is contained in:
commit
e1f6f4b31d
9 changed files with 146 additions and 29 deletions
6
ci.sh
6
ci.sh
|
@ -47,6 +47,7 @@ cargo batch \
|
|||
--- build --release --manifest-path embassy-net/Cargo.toml --target thumbv7em-none-eabi --features defmt,tcp,udp,dns,proto-ipv4,proto-ipv6,medium-ip \
|
||||
--- 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 \
|
||||
--- 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 \
|
||||
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv6m-none-eabi --features nrf51,gpiote,time,time-driver-rtc1 \
|
||||
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52805,gpiote,time,time-driver-rtc1 \
|
||||
--- build --release --manifest-path embassy-nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52810,gpiote,time,time-driver-rtc1 \
|
||||
--- 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 \
|
|||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f038f6,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f042g4,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f072c8,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \
|
||||
--- 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 \
|
|||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l431cb,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \
|
||||
--- 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 \
|
|||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f100c4,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h503rb,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32h562ag,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32wb35ce,defmt,exti,time-driver-any,time \
|
||||
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features ''\
|
||||
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'log' \
|
||||
--- build --release --manifest-path cyw43/Cargo.toml --target thumbv6m-none-eabi --features 'defmt' \
|
||||
|
|
|
@ -13,6 +13,10 @@ use crate::interrupt::InterruptExt;
|
|||
use crate::ppi::{Event, Task};
|
||||
use crate::{interrupt, pac, peripherals};
|
||||
|
||||
#[cfg(feature = "nrf51")]
|
||||
/// Amount of GPIOTE channels in the chip.
|
||||
const CHANNEL_COUNT: usize = 4;
|
||||
#[cfg(not(feature = "_nrf51"))]
|
||||
/// Amount of GPIOTE channels in the chip.
|
||||
const CHANNEL_COUNT: usize = 8;
|
||||
|
||||
|
@ -61,16 +65,20 @@ fn regs() -> &'static pac::gpiote::RegisterBlock {
|
|||
}
|
||||
|
||||
pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
|
||||
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
|
||||
let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] };
|
||||
#[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))]
|
||||
let ports = unsafe { &[&*pac::P0::ptr()] };
|
||||
// no latched GPIO detect in nrf51.
|
||||
#[cfg(not(feature = "_nrf51"))]
|
||||
{
|
||||
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
|
||||
let ports = unsafe { &[&*pac::P0::ptr(), &*pac::P1::ptr()] };
|
||||
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
|
||||
let ports = unsafe { &[&*pac::P0::ptr()] };
|
||||
|
||||
for &p in ports {
|
||||
// Enable latched detection
|
||||
p.detectmode.write(|w| w.detectmode().ldetect());
|
||||
// Clear latch
|
||||
p.latch.write(|w| unsafe { w.bits(0xFFFFFFFF) })
|
||||
for &p in ports {
|
||||
// Enable latched detection
|
||||
p.detectmode.write(|w| w.detectmode().ldetect());
|
||||
// Clear latch
|
||||
p.latch.write(|w| unsafe { w.bits(0xFFFFFFFF) })
|
||||
}
|
||||
}
|
||||
|
||||
// Enable interrupts
|
||||
|
@ -78,7 +86,7 @@ pub(crate) fn init(irq_prio: crate::interrupt::Priority) {
|
|||
let irq = interrupt::GPIOTE0;
|
||||
#[cfg(any(feature = "nrf5340-app-ns", feature = "nrf9160-ns"))]
|
||||
let irq = interrupt::GPIOTE1;
|
||||
#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))]
|
||||
#[cfg(any(feature = "_nrf51", feature = "_nrf52", feature = "nrf5340-net"))]
|
||||
let irq = interrupt::GPIOTE;
|
||||
|
||||
irq.unpend();
|
||||
|
@ -103,7 +111,7 @@ fn GPIOTE1() {
|
|||
unsafe { handle_gpiote_interrupt() };
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "_nrf52", feature = "nrf5340-net"))]
|
||||
#[cfg(any(feature = "_nrf51", feature = "_nrf52", feature = "nrf5340-net"))]
|
||||
#[cfg(feature = "rt")]
|
||||
#[interrupt]
|
||||
fn GPIOTE() {
|
||||
|
@ -125,9 +133,29 @@ unsafe fn handle_gpiote_interrupt() {
|
|||
|
||||
#[cfg(any(feature = "nrf52833", feature = "nrf52840"))]
|
||||
let ports = &[&*pac::P0::ptr(), &*pac::P1::ptr()];
|
||||
#[cfg(not(any(feature = "nrf52833", feature = "nrf52840")))]
|
||||
#[cfg(not(any(feature = "_nrf51", feature = "nrf52833", feature = "nrf52840")))]
|
||||
let ports = &[&*pac::P0::ptr()];
|
||||
#[cfg(feature = "_nrf51")]
|
||||
let ports = unsafe { &[&*pac::GPIO::ptr()] };
|
||||
|
||||
#[cfg(feature = "_nrf51")]
|
||||
for (port, &p) in ports.iter().enumerate() {
|
||||
let inp = p.in_.read().bits();
|
||||
for pin in 0..32 {
|
||||
let fired = match p.pin_cnf[pin as usize].read().sense().variant() {
|
||||
Some(pac::gpio::pin_cnf::SENSE_A::HIGH) => inp & (1 << pin) != 0,
|
||||
Some(pac::gpio::pin_cnf::SENSE_A::LOW) => inp & (1 << pin) == 0,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
if fired {
|
||||
PORT_WAKERS[port * 32 + pin as usize].wake();
|
||||
p.pin_cnf[pin as usize].modify(|_, w| w.sense().disabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "_nrf51"))]
|
||||
for (port, &p) in ports.iter().enumerate() {
|
||||
let bits = p.latch.read().bits();
|
||||
for pin in BitIter(bits) {
|
||||
|
@ -476,9 +504,13 @@ impl_channel!(GPIOTE_CH0, 0);
|
|||
impl_channel!(GPIOTE_CH1, 1);
|
||||
impl_channel!(GPIOTE_CH2, 2);
|
||||
impl_channel!(GPIOTE_CH3, 3);
|
||||
#[cfg(not(feature = "nrf51"))]
|
||||
impl_channel!(GPIOTE_CH4, 4);
|
||||
#[cfg(not(feature = "nrf51"))]
|
||||
impl_channel!(GPIOTE_CH5, 5);
|
||||
#[cfg(not(feature = "nrf51"))]
|
||||
impl_channel!(GPIOTE_CH6, 6);
|
||||
#[cfg(not(feature = "nrf51"))]
|
||||
impl_channel!(GPIOTE_CH7, 7);
|
||||
|
||||
// ====================
|
||||
|
|
|
@ -68,7 +68,7 @@ rand_core = "0.6.3"
|
|||
sdio-host = "0.5.0"
|
||||
critical-section = "1.1"
|
||||
#stm32-metapac = { version = "15" }
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-0cb3a4fcaec702c93b3700715de796636d562b15" }
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-aa5dbf859fae743306f5d816905f166de824241f" }
|
||||
vcell = "0.1.3"
|
||||
bxcan = "0.7.0"
|
||||
nb = "1.0.0"
|
||||
|
@ -89,7 +89,7 @@ critical-section = { version = "1.1", features = ["std"] }
|
|||
proc-macro2 = "1.0.36"
|
||||
quote = "1.0.15"
|
||||
#stm32-metapac = { version = "15", default-features = false, features = ["metadata"]}
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-0cb3a4fcaec702c93b3700715de796636d562b15", default-features = false, features = ["metadata"]}
|
||||
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-aa5dbf859fae743306f5d816905f166de824241f", default-features = false, features = ["metadata"]}
|
||||
|
||||
|
||||
[features]
|
||||
|
|
|
@ -11,14 +11,13 @@ pub const HSI_FREQ: Hertz = Hertz(8_000_000);
|
|||
///
|
||||
/// hse takes precedence over hsi48 if both are enabled
|
||||
#[non_exhaustive]
|
||||
#[derive(Default)]
|
||||
pub struct Config {
|
||||
pub hse: Option<Hertz>,
|
||||
pub bypass_hse: bool,
|
||||
pub usb_pll: bool,
|
||||
|
||||
#[cfg(not(stm32f0x0))]
|
||||
pub hsi48: bool,
|
||||
#[cfg(crs)]
|
||||
pub hsi48: Option<super::Hsi48Config>,
|
||||
|
||||
pub sys_ck: Option<Hertz>,
|
||||
pub hclk: Option<Hertz>,
|
||||
|
@ -27,12 +26,32 @@ pub struct Config {
|
|||
pub ls: super::LsConfig,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
hse: Default::default(),
|
||||
bypass_hse: Default::default(),
|
||||
usb_pll: Default::default(),
|
||||
#[cfg(crs)]
|
||||
hsi48: Some(Default::default()),
|
||||
sys_ck: Default::default(),
|
||||
hclk: Default::default(),
|
||||
pclk: Default::default(),
|
||||
ls: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn init(config: Config) {
|
||||
let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0);
|
||||
|
||||
#[cfg(crs)]
|
||||
let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
|
||||
#[cfg(not(crs))]
|
||||
let hsi48: Option<Hertz> = None;
|
||||
|
||||
let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| {
|
||||
#[cfg(not(stm32f0x0))]
|
||||
if config.hsi48 {
|
||||
if hsi48.is_some() {
|
||||
return (48_000_000, true);
|
||||
}
|
||||
(HSI_FREQ.0, false)
|
||||
|
@ -169,5 +188,9 @@ pub(crate) unsafe fn init(config: Config) {
|
|||
pclk2_tim: Some(Hertz(pclk * timer_mul)),
|
||||
hclk1: Some(Hertz(hclk)),
|
||||
rtc: rtc,
|
||||
hsi48: hsi48,
|
||||
|
||||
// TODO:
|
||||
pll1_p: None,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -215,12 +215,9 @@ pub(crate) unsafe fn init(config: Config) {
|
|||
});
|
||||
|
||||
#[cfg(crs)]
|
||||
let _hsi48 = config.hsi48.map(|config| {
|
||||
//
|
||||
super::init_hsi48(config)
|
||||
});
|
||||
let hsi48 = config.hsi48.map(|config| super::init_hsi48(config));
|
||||
#[cfg(not(crs))]
|
||||
let _hsi48: Option<Hertz> = None;
|
||||
let hsi48: Option<Hertz> = None;
|
||||
|
||||
let _plls = [
|
||||
&config.pll,
|
||||
|
@ -274,12 +271,12 @@ pub(crate) unsafe fn init(config: Config) {
|
|||
RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src));
|
||||
#[cfg(any(rcc_l0_v2))]
|
||||
let clk48 = match config.clk48_src {
|
||||
Clk48Src::HSI48 => _hsi48,
|
||||
Clk48Src::HSI48 => hsi48,
|
||||
Clk48Src::PLL1_VCO_DIV_2 => pll.clk48,
|
||||
};
|
||||
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
||||
let clk48 = match config.clk48_src {
|
||||
Clk48Src::HSI48 => _hsi48,
|
||||
Clk48Src::HSI48 => hsi48,
|
||||
Clk48Src::MSI => msi,
|
||||
Clk48Src::PLLSAI1_Q => pllsai1.q,
|
||||
Clk48Src::PLL1_Q => pll.q,
|
||||
|
@ -393,6 +390,7 @@ pub(crate) unsafe fn init(config: Config) {
|
|||
msi: msi,
|
||||
#[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))]
|
||||
clk48: clk48,
|
||||
hsi48: hsi48,
|
||||
|
||||
#[cfg(not(any(stm32l0, stm32l1)))]
|
||||
pll1_p: pll.p,
|
||||
|
@ -407,6 +405,13 @@ pub(crate) unsafe fn init(config: Config) {
|
|||
#[cfg(any(stm32l4, stm32l5, stm32wb))]
|
||||
pllsai1_r: pllsai1.r,
|
||||
|
||||
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||
pllsai2_p: None,
|
||||
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||
pllsai2_q: None,
|
||||
#[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))]
|
||||
pllsai2_r: None,
|
||||
|
||||
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
||||
pllsai2_p: pllsai2.p,
|
||||
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
use core::mem::MaybeUninit;
|
||||
|
||||
mod bd;
|
||||
mod mco;
|
||||
pub use bd::*;
|
||||
|
||||
#[cfg(any(mco, mco1, mco2))]
|
||||
mod mco;
|
||||
#[cfg(any(mco, mco1, mco2))]
|
||||
pub use mco::*;
|
||||
|
||||
#[cfg(crs)]
|
||||
|
|
|
@ -7,7 +7,7 @@ license = "MIT OR Apache-2.0"
|
|||
[dependencies]
|
||||
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-4096", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
|
||||
embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "rt"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "gpiote", "time-driver-rtc1", "unstable-pac", "time", "rt"] }
|
||||
|
||||
defmt = "0.3"
|
||||
defmt-rtt = "0.4"
|
||||
|
|
|
@ -7,10 +7,11 @@ license = "MIT OR Apache-2.0"
|
|||
[dependencies]
|
||||
teleprobe-meta = "1"
|
||||
|
||||
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
||||
embassy-sync = { version = "0.5.0", path = "../../embassy-sync", features = ["defmt", ] }
|
||||
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
|
||||
embassy-time = { version = "0.3.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
|
||||
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
||||
embedded-hal-async = { version = "1.0" }
|
||||
|
||||
|
|
47
tests/nrf51422/src/bin/gpiote.rs
Normal file
47
tests/nrf51422/src/bin/gpiote.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
teleprobe_meta::target!(b"nrf51-dk");
|
||||
|
||||
use defmt::{assert, info};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_futures::join::join;
|
||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||
use embassy_time::{Duration, Instant, Timer};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
let mut input = Input::new(p.P0_13, Pull::Up);
|
||||
let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
|
||||
|
||||
let fut1 = async {
|
||||
Timer::after_millis(100).await;
|
||||
output.set_high();
|
||||
};
|
||||
let fut2 = async {
|
||||
let start = Instant::now();
|
||||
input.wait_for_high().await;
|
||||
let dur = Instant::now() - start;
|
||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||
};
|
||||
|
||||
join(fut1, fut2).await;
|
||||
|
||||
let fut1 = async {
|
||||
Timer::after_millis(100).await;
|
||||
output.set_low();
|
||||
};
|
||||
let fut2 = async {
|
||||
let start = Instant::now();
|
||||
input.wait_for_low().await;
|
||||
let dur = Instant::now() - start;
|
||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||
};
|
||||
|
||||
join(fut1, fut2).await;
|
||||
|
||||
info!("Test OK");
|
||||
cortex_m::asm::bkpt();
|
||||
}
|
Loading…
Reference in a new issue