Skip to content

Commit db8050b

Browse files
bors[bot]Dirbaio
andauthored
Merge #627
627: Update Rust nightly, embedded-hal 1.0, embedded-hal-async. r=Dirbaio a=Dirbaio Includes the SpiDevice/SpiBus split. rust-embedded/embedded-hal#351 Includes the GAT where clause location change. rust-lang/rust#89122 Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 828cdb2 + 9bad936 commit db8050b

File tree

33 files changed

+714
-837
lines changed

33 files changed

+714
-837
lines changed

embassy-hal-common/src/peripheral.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a, S: PeripheralState> PeripheralMutex<'a, S> {
9797
// Interrupts' priorities can only be changed with raw embassy `Interrupts`,
9898
// which can't safely store a `PeripheralMutex` across invocations.
9999
// - We can't have preempted a with() call because the irq is disabled during it.
100-
let state = unsafe { &mut *(p as *mut S) };
100+
let state = &mut *(p as *mut S);
101101
state.on_interrupt();
102102
});
103103
irq.set_handler_context(state_ptr as *mut ());

embassy-lora/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ log = { version = "0.4.14", optional = true }
1818

1919
embassy = { version = "0.1.0", path = "../embassy", default-features = false }
2020
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
21-
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.6", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy", optional = true}
22-
embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy"}
21+
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true}
22+
embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2"}
2323
embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false }
2424
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
2525
embedded-hal = { version = "0.2", features = ["unproven"] }

embassy-lora/src/stm32wl/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'a> SubGhzRadio<'a> {
7878
// This is safe because we only get interrupts when configured for, so
7979
// the radio will be awaiting on the signal at this point. If not, the ISR will
8080
// anyway only adjust the state in the IRQ signal state.
81-
let state = unsafe { &mut *(p as *mut StateInner<'a>) };
81+
let state = &mut *(p as *mut StateInner<'a>);
8282
state.on_interrupt();
8383
});
8484
irq.set_handler_context(state_ptr as *mut ());

embassy-lora/src/sx127x/mod.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub trait RadioSwitch {
2020
/// Semtech Sx127x radio peripheral
2121
pub struct Sx127xRadio<SPI, CS, RESET, E, I, RFS>
2222
where
23-
SPI: ReadWrite<u8, Error = E> + 'static,
23+
SPI: SpiBus<u8, Error = E> + 'static,
2424
E: 'static,
2525
CS: OutputPin + 'static,
2626
RESET: OutputPin + 'static,
@@ -42,7 +42,7 @@ pub enum State {
4242

4343
impl<SPI, CS, RESET, E, I, RFS> Sx127xRadio<SPI, CS, RESET, E, I, RFS>
4444
where
45-
SPI: ReadWrite<u8, Error = E> + 'static,
45+
SPI: SpiBus<u8, Error = E> + 'static,
4646
CS: OutputPin + 'static,
4747
RESET: OutputPin + 'static,
4848
I: Wait + 'static,
@@ -64,7 +64,7 @@ where
6464

6565
impl<SPI, CS, RESET, E, I, RFS> Timings for Sx127xRadio<SPI, CS, RESET, E, I, RFS>
6666
where
67-
SPI: ReadWrite<u8, Error = E> + 'static,
67+
SPI: SpiBus<u8, Error = E> + 'static,
6868
CS: OutputPin + 'static,
6969
RESET: OutputPin + 'static,
7070
I: Wait + 'static,
@@ -80,7 +80,7 @@ where
8080

8181
impl<SPI, CS, RESET, E, I, RFS> PhyRxTx for Sx127xRadio<SPI, CS, RESET, E, I, RFS>
8282
where
83-
SPI: ReadWrite<u8, Error = E> + 'static,
83+
SPI: SpiBus<u8, Error = E> + 'static,
8484
CS: OutputPin + 'static,
8585
E: 'static,
8686
RESET: OutputPin + 'static,
@@ -89,15 +89,14 @@ where
8989
{
9090
type PhyError = Sx127xError;
9191

92-
type TxFuture<'m>
92+
type TxFuture<'m> = impl Future<Output = Result<u32, Self::PhyError>> + 'm
9393
where
9494
SPI: 'm,
9595
CS: 'm,
9696
RESET: 'm,
9797
E: 'm,
9898
I: 'm,
99-
RFS: 'm,
100-
= impl Future<Output = Result<u32, Self::PhyError>> + 'm;
99+
RFS: 'm;
101100

102101
fn tx<'m>(&'m mut self, config: TxConfig, buf: &'m [u8]) -> Self::TxFuture<'m> {
103102
trace!("TX START");
@@ -137,15 +136,14 @@ where
137136
}
138137
}
139138

140-
type RxFuture<'m>
139+
type RxFuture<'m> = impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm
141140
where
142141
SPI: 'm,
143142
CS: 'm,
144143
RESET: 'm,
145144
E: 'm,
146145
I: 'm,
147-
RFS: 'm,
148-
= impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm;
146+
RFS: 'm;
149147

150148
fn rx<'m>(&'m mut self, config: RfConfig, buf: &'m mut [u8]) -> Self::RxFuture<'m> {
151149
trace!("RX START");

embassy-lora/src/sx127x/sx127x_lora/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use bit_field::BitField;
99
use embassy::time::{Duration, Timer};
1010
use embedded_hal::digital::v2::OutputPin;
11-
use embedded_hal_async::spi::ReadWrite;
11+
use embedded_hal_async::spi::SpiBus;
1212

1313
mod register;
1414
use self::register::PaConfig;
@@ -48,7 +48,7 @@ const VERSION_CHECK: u8 = 0x09;
4848

4949
impl<SPI, CS, RESET, E> LoRa<SPI, CS, RESET>
5050
where
51-
SPI: ReadWrite<u8, Error = E>,
51+
SPI: SpiBus<u8, Error = E>,
5252
CS: OutputPin,
5353
RESET: OutputPin,
5454
{

embassy-nrf/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ embassy-macros = { version = "0.1.0", path = "../embassy-macros", features = ["n
6363
embassy-hal-common = {version = "0.1.0", path = "../embassy-hal-common" }
6464

6565
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
66-
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.6", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy", optional = true}
67-
embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy", optional = true}
66+
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.7", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true}
67+
embedded-hal-async = { version = "0.0.1", git = "https://github.com/embassy-rs/embedded-hal", branch = "embassy2", optional = true}
6868

6969
defmt = { version = "0.3", optional = true }
7070
log = { version = "0.4.14", optional = true }

embassy-nrf/src/gpiote.rs

Lines changed: 46 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ unsafe fn handle_gpiote_interrupt() {
108108

109109
for i in 0..CHANNEL_COUNT {
110110
if g.events_in[i].read().bits() != 0 {
111-
g.intenclr.write(|w| unsafe { w.bits(1 << i) });
111+
g.intenclr.write(|w| w.bits(1 << i));
112112
CHANNEL_WAKERS[i].wake();
113113
}
114114
}
@@ -481,102 +481,72 @@ mod eh1 {
481481
}
482482
}
483483

484-
#[cfg(all(feature = "unstable-traits", feature = "nightly"))]
485-
mod eh1a {
486-
use super::*;
487-
use futures::FutureExt;
484+
cfg_if::cfg_if! {
485+
if #[cfg(all(feature = "unstable-traits", feature = "nightly"))] {
486+
use futures::FutureExt;
488487

489-
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
490-
type WaitForHighFuture<'a>
491-
where
492-
Self: 'a,
493-
= impl Future<Output = Result<(), Self::Error>> + 'a;
488+
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Input<'d, T> {
489+
type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
494490

495-
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
496-
self.wait_for_high().map(Ok)
497-
}
491+
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
492+
self.wait_for_high().map(Ok)
493+
}
498494

499-
type WaitForLowFuture<'a>
500-
where
501-
Self: 'a,
502-
= impl Future<Output = Result<(), Self::Error>> + 'a;
495+
type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
503496

504-
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
505-
self.wait_for_low().map(Ok)
506-
}
497+
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
498+
self.wait_for_low().map(Ok)
499+
}
507500

508-
type WaitForRisingEdgeFuture<'a>
509-
where
510-
Self: 'a,
511-
= impl Future<Output = Result<(), Self::Error>> + 'a;
501+
type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
512502

513-
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
514-
self.wait_for_rising_edge().map(Ok)
515-
}
503+
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
504+
self.wait_for_rising_edge().map(Ok)
505+
}
516506

517-
type WaitForFallingEdgeFuture<'a>
518-
where
519-
Self: 'a,
520-
= impl Future<Output = Result<(), Self::Error>> + 'a;
507+
type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
521508

522-
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
523-
self.wait_for_falling_edge().map(Ok)
524-
}
509+
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
510+
self.wait_for_falling_edge().map(Ok)
511+
}
525512

526-
type WaitForAnyEdgeFuture<'a>
527-
where
528-
Self: 'a,
529-
= impl Future<Output = Result<(), Self::Error>> + 'a;
513+
type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
530514

531-
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
532-
self.wait_for_any_edge().map(Ok)
515+
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
516+
self.wait_for_any_edge().map(Ok)
517+
}
533518
}
534-
}
535519

536-
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> {
537-
type WaitForHighFuture<'a>
538-
where
539-
Self: 'a,
540-
= impl Future<Output = Result<(), Self::Error>> + 'a;
520+
impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for Flex<'d, T> {
521+
type WaitForHighFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
541522

542-
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
543-
self.wait_for_high().map(Ok)
544-
}
523+
fn wait_for_high<'a>(&'a mut self) -> Self::WaitForHighFuture<'a> {
524+
self.wait_for_high().map(Ok)
525+
}
545526

546-
type WaitForLowFuture<'a>
547-
where
548-
Self: 'a,
549-
= impl Future<Output = Result<(), Self::Error>> + 'a;
527+
type WaitForLowFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
550528

551-
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
552-
self.wait_for_low().map(Ok)
553-
}
529+
fn wait_for_low<'a>(&'a mut self) -> Self::WaitForLowFuture<'a> {
530+
self.wait_for_low().map(Ok)
531+
}
554532

555-
type WaitForRisingEdgeFuture<'a>
556-
where
557-
Self: 'a,
558-
= impl Future<Output = Result<(), Self::Error>> + 'a;
533+
type WaitForRisingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
559534

560-
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
561-
self.wait_for_rising_edge().map(Ok)
562-
}
535+
fn wait_for_rising_edge<'a>(&'a mut self) -> Self::WaitForRisingEdgeFuture<'a> {
536+
self.wait_for_rising_edge().map(Ok)
537+
}
563538

564-
type WaitForFallingEdgeFuture<'a>
565-
where
566-
Self: 'a,
567-
= impl Future<Output = Result<(), Self::Error>> + 'a;
539+
type WaitForFallingEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
568540

569-
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
570-
self.wait_for_falling_edge().map(Ok)
571-
}
541+
fn wait_for_falling_edge<'a>(&'a mut self) -> Self::WaitForFallingEdgeFuture<'a> {
542+
self.wait_for_falling_edge().map(Ok)
543+
}
572544

573-
type WaitForAnyEdgeFuture<'a>
574-
where
575-
Self: 'a,
576-
= impl Future<Output = Result<(), Self::Error>> + 'a;
545+
type WaitForAnyEdgeFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
577546

578-
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
579-
self.wait_for_any_edge().map(Ok)
547+
fn wait_for_any_edge<'a>(&'a mut self) -> Self::WaitForAnyEdgeFuture<'a> {
548+
self.wait_for_any_edge().map(Ok)
549+
}
580550
}
581551
}
582552
}

0 commit comments

Comments
 (0)