Merge branch 'master' of https://github.com/embassy-rs/embassy into embassy-stm32/rtc

This commit is contained in:
Mathias 2022-09-30 06:15:12 +02:00
commit 62c0b18f10
34 changed files with 191 additions and 104 deletions

View File

@ -18,8 +18,8 @@ nightly = ["embedded-hal-async", "embedded-storage-async"]
[dependencies] [dependencies]
embassy-sync = { version = "0.1.0", path = "../embassy-sync" } embassy-sync = { version = "0.1.0", path = "../embassy-sync" }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true } embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true }
embedded-storage = "0.3.0" embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.3.0", optional = true } embedded-storage-async = { version = "0.3.0", optional = true }
nb = "1.0.0" nb = "1.0.0"

View File

@ -29,7 +29,7 @@ use core::future::Future;
use embassy_sync::blocking_mutex::raw::RawMutex; use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::mutex::Mutex; use embassy_sync::mutex::Mutex;
use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi::ErrorType; use embedded_hal_1::spi::ErrorType;
use embedded_hal_async::spi; use embedded_hal_async::spi;
@ -57,7 +57,7 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<M, BUS, CS> spi::SpiDevice for SpiDevice<'_, M, BUS, CS> unsafe impl<M, BUS, CS> spi::SpiDevice for SpiDevice<'_, M, BUS, CS>
where where
M: RawMutex + 'static, M: RawMutex + 'static,
BUS: spi::SpiBusFlush + 'static, BUS: spi::SpiBusFlush + 'static,
@ -122,7 +122,7 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<M, BUS, CS> spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> unsafe impl<M, BUS, CS> spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS>
where where
M: RawMutex + 'static, M: RawMutex + 'static,
BUS: spi::SpiBusFlush + SetConfig + 'static, BUS: spi::SpiBusFlush + SetConfig + 'static,

View File

@ -20,8 +20,7 @@ use core::cell::RefCell;
use embassy_sync::blocking_mutex::raw::RawMutex; use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::blocking_mutex::Mutex; use embassy_sync::blocking_mutex::Mutex;
use embedded_hal_1::i2c::blocking::{I2c, Operation}; use embedded_hal_1::i2c::{ErrorType, I2c, Operation};
use embedded_hal_1::i2c::ErrorType;
use crate::shared_bus::I2cDeviceError; use crate::shared_bus::I2cDeviceError;
use crate::SetConfig; use crate::SetConfig;

View File

@ -22,9 +22,9 @@ use core::cell::RefCell;
use embassy_sync::blocking_mutex::raw::RawMutex; use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_sync::blocking_mutex::Mutex; use embassy_sync::blocking_mutex::Mutex;
use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi; use embedded_hal_1::spi;
use embedded_hal_1::spi::blocking::SpiBusFlush; use embedded_hal_1::spi::SpiBusFlush;
use crate::shared_bus::SpiDeviceError; use crate::shared_bus::SpiDeviceError;
use crate::SetConfig; use crate::SetConfig;
@ -50,7 +50,7 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<BUS, M, CS> embedded_hal_1::spi::blocking::SpiDevice for SpiDevice<'_, M, BUS, CS> impl<BUS, M, CS> embedded_hal_1::spi::SpiDevice for SpiDevice<'_, M, BUS, CS>
where where
M: RawMutex, M: RawMutex,
BUS: SpiBusFlush, BUS: SpiBusFlush,
@ -146,7 +146,7 @@ where
type Error = SpiDeviceError<BUS::Error, CS::Error>; type Error = SpiDeviceError<BUS::Error, CS::Error>;
} }
impl<BUS, M, CS> embedded_hal_1::spi::blocking::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS> impl<BUS, M, CS> embedded_hal_1::spi::SpiDevice for SpiDeviceWithConfig<'_, M, BUS, CS>
where where
M: RawMutex, M: RawMutex,
BUS: SpiBusFlush + SetConfig, BUS: SpiBusFlush + SetConfig,

View File

@ -28,8 +28,8 @@ log = { version = "0.4.14", optional = true }
embassy-time = { version = "0.1.0", path = "../embassy-time" } embassy-time = { version = "0.1.0", path = "../embassy-time" }
embassy-sync = { version = "0.1.0", path = "../embassy-sync" } embassy-sync = { version = "0.1.0", path = "../embassy-sync" }
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true } embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32", default-features = false, optional = true }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" } embedded-hal-async = { version = "=0.1.0-alpha.2" }
embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false } embassy-hal-common = { version = "0.1.0", path = "../embassy-hal-common", default-features = false }
futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] } futures = { version = "0.3.17", default-features = false, features = [ "async-await" ] }
embedded-hal = { version = "0.2", features = ["unproven"] } embedded-hal = { version = "0.2", features = ["unproven"] }

View File

@ -234,15 +234,15 @@ fn configure_radio(radio: &mut SubGhz<'_, NoDma, NoDma>, config: SubGhzRadioConf
Ok(()) Ok(())
} }
impl<RS: RadioSwitch> PhyRxTx for SubGhzRadio<'static, RS> { impl<'d, RS: RadioSwitch> PhyRxTx for SubGhzRadio<'d, RS> {
type PhyError = RadioError; type PhyError = RadioError;
type TxFuture<'m> = impl Future<Output = Result<u32, Self::PhyError>> + 'm where RS: 'm; type TxFuture<'m> = impl Future<Output = Result<u32, Self::PhyError>> + 'm where Self: 'm;
fn tx<'m>(&'m mut self, config: TxConfig, buf: &'m [u8]) -> Self::TxFuture<'m> { fn tx<'m>(&'m mut self, config: TxConfig, buf: &'m [u8]) -> Self::TxFuture<'m> {
async move { self.do_tx(config, buf).await } async move { self.do_tx(config, buf).await }
} }
type RxFuture<'m> = impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm where RS: 'm; type RxFuture<'m> = impl Future<Output = Result<(usize, RxQuality), Self::PhyError>> + 'm where Self: 'm;
fn rx<'m>(&'m mut self, config: RfConfig, buf: &'m mut [u8]) -> Self::RxFuture<'m> { fn rx<'m>(&'m mut self, config: RfConfig, buf: &'m mut [u8]) -> Self::RxFuture<'m> {
async move { self.do_rx(config, buf).await } async move { self.do_rx(config, buf).await }
} }

View File

@ -73,8 +73,8 @@ embassy-embedded-hal = {version = "0.1.0", path = "../embassy-embedded-hal" }
embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional=true }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true}
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true}
embedded-io = { version = "0.3.0", features = ["async"], optional = true } embedded-io = { version = "0.3.0", features = ["async"], optional = true }
defmt = { version = "0.3", optional = true } defmt = { version = "0.3", optional = true }

View File

@ -574,7 +574,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::InputPin for Input<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high()) Ok(self.is_high())
} }
@ -588,7 +588,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::OutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
fn set_high(&mut self) -> Result<(), Self::Error> { fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(self.set_high()) Ok(self.set_high())
} }
@ -598,7 +598,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::StatefulOutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
fn is_set_high(&self) -> Result<bool, Self::Error> { fn is_set_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_set_high()) Ok(self.is_set_high())
} }
@ -615,7 +615,7 @@ mod eh1 {
/// Implement [`InputPin`] for [`Flex`]; /// Implement [`InputPin`] for [`Flex`];
/// ///
/// If the pin is not in input mode the result is unspecified. /// If the pin is not in input mode the result is unspecified.
impl<'d, T: Pin> embedded_hal_1::digital::blocking::InputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high()) Ok(self.is_high())
} }
@ -625,7 +625,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::OutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
fn set_high(&mut self) -> Result<(), Self::Error> { fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(self.set_high()) Ok(self.set_high())
} }
@ -635,7 +635,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::StatefulOutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
fn is_set_high(&self) -> Result<bool, Self::Error> { fn is_set_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_set_high()) Ok(self.is_set_high())
} }

View File

@ -457,7 +457,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::blocking::InputPin for InputChannel<'d, C, T> { impl<'d, C: Channel, T: GpioPin> embedded_hal_1::digital::InputPin for InputChannel<'d, C, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.pin.is_high()) Ok(self.pin.is_high())
} }

View File

@ -446,25 +446,25 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::spi::blocking::SpiBusFlush for Spim<'d, T> { impl<'d, T: Instance> embedded_hal_1::spi::SpiBusFlush for Spim<'d, T> {
fn flush(&mut self) -> Result<(), Self::Error> { fn flush(&mut self) -> Result<(), Self::Error> {
Ok(()) Ok(())
} }
} }
impl<'d, T: Instance> embedded_hal_1::spi::blocking::SpiBusRead<u8> for Spim<'d, T> { impl<'d, T: Instance> embedded_hal_1::spi::SpiBusRead<u8> for Spim<'d, T> {
fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_transfer(words, &[]) self.blocking_transfer(words, &[])
} }
} }
impl<'d, T: Instance> embedded_hal_1::spi::blocking::SpiBusWrite<u8> for Spim<'d, T> { impl<'d, T: Instance> embedded_hal_1::spi::SpiBusWrite<u8> for Spim<'d, T> {
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(words) self.blocking_write(words)
} }
} }
impl<'d, T: Instance> embedded_hal_1::spi::blocking::SpiBus<u8> for Spim<'d, T> { impl<'d, T: Instance> embedded_hal_1::spi::SpiBus<u8> for Spim<'d, T> {
fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
self.blocking_transfer(read, write) self.blocking_transfer(read, write)
} }

View File

@ -793,7 +793,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::i2c::blocking::I2c for Twim<'d, T> { impl<'d, T: Instance> embedded_hal_1::i2c::I2c for Twim<'d, T> {
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_read(address, buffer) self.blocking_read(address, buffer)
} }
@ -823,14 +823,14 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
_address: u8, _address: u8,
_operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], _operations: &mut [embedded_hal_1::i2c::Operation<'a>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
todo!(); todo!();
} }
fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error> fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error>
where where
O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>, O: IntoIterator<Item = embedded_hal_1::i2c::Operation<'a>>,
{ {
todo!(); todo!();
} }

View File

@ -1040,7 +1040,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for Uarte<'d, T> { impl<'d, T: Instance> embedded_hal_1::serial::Write for Uarte<'d, T> {
fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(buffer) self.blocking_write(buffer)
} }
@ -1054,7 +1054,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::serial::blocking::Write for UarteTx<'d, T> { impl<'d, T: Instance> embedded_hal_1::serial::Write for UarteTx<'d, T> {
fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(buffer) self.blocking_write(buffer)
} }

View File

@ -31,7 +31,7 @@ nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "
# Implement embedded-hal 1.0 alpha traits. # Implement embedded-hal 1.0 alpha traits.
# Implement embedded-hal-async traits if `nightly` is set as well. # Implement embedded-hal-async traits if `nightly` is set as well.
unstable-traits = ["embedded-hal-1"] unstable-traits = ["embedded-hal-1", "embedded-hal-nb"]
[dependencies] [dependencies]
embassy-sync = { version = "0.1.0", path = "../embassy-sync" } embassy-sync = { version = "0.1.0", path = "../embassy-sync" }
@ -58,5 +58,6 @@ rp2040-pac2 = { git = "https://github.com/embassy-rs/rp2040-pac2", rev="017e3c90
#rp2040-pac2 = { path = "../../rp2040-pac2", features = ["rt"] } #rp2040-pac2 = { path = "../../rp2040-pac2", features = ["rt"] }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true}
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true}
embedded-hal-nb = { version = "=1.0.0-alpha.1", optional = true}

View File

@ -867,7 +867,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::InputPin for Input<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Input<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high()) Ok(self.is_high())
} }
@ -881,7 +881,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::OutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Output<'d, T> {
fn set_high(&mut self) -> Result<(), Self::Error> { fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(self.set_high()) Ok(self.set_high())
} }
@ -891,7 +891,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::StatefulOutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Output<'d, T> {
fn is_set_high(&self) -> Result<bool, Self::Error> { fn is_set_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_set_high()) Ok(self.is_set_high())
} }
@ -901,7 +901,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::ToggleableOutputPin for Output<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Output<'d, T> {
fn toggle(&mut self) -> Result<(), Self::Error> { fn toggle(&mut self) -> Result<(), Self::Error> {
Ok(self.toggle()) Ok(self.toggle())
} }
@ -911,7 +911,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::OutputPin for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for OutputOpenDrain<'d, T> {
fn set_high(&mut self) -> Result<(), Self::Error> { fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(self.set_high()) Ok(self.set_high())
} }
@ -921,7 +921,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::StatefulOutputPin for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for OutputOpenDrain<'d, T> {
fn is_set_high(&self) -> Result<bool, Self::Error> { fn is_set_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_set_high()) Ok(self.is_set_high())
} }
@ -931,7 +931,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::ToggleableOutputPin for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for OutputOpenDrain<'d, T> {
fn toggle(&mut self) -> Result<(), Self::Error> { fn toggle(&mut self) -> Result<(), Self::Error> {
Ok(self.toggle()) Ok(self.toggle())
} }
@ -941,7 +941,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::InputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::InputPin for Flex<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high()) Ok(self.is_high())
} }
@ -951,7 +951,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::OutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::OutputPin for Flex<'d, T> {
fn set_high(&mut self) -> Result<(), Self::Error> { fn set_high(&mut self) -> Result<(), Self::Error> {
Ok(self.set_high()) Ok(self.set_high())
} }
@ -961,7 +961,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::StatefulOutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::StatefulOutputPin for Flex<'d, T> {
fn is_set_high(&self) -> Result<bool, Self::Error> { fn is_set_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_set_high()) Ok(self.is_set_high())
} }
@ -971,7 +971,7 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::blocking::ToggleableOutputPin for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::ToggleableOutputPin for Flex<'d, T> {
fn toggle(&mut self) -> Result<(), Self::Error> { fn toggle(&mut self) -> Result<(), Self::Error> {
Ok(self.toggle()) Ok(self.toggle())
} }

View File

@ -379,7 +379,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::blocking::I2c for I2c<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::i2c::I2c for I2c<'d, T, M> {
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_read(address, buffer) self.blocking_read(address, buffer)
} }
@ -421,16 +421,14 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
address: u8, address: u8,
operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], operations: &mut [embedded_hal_1::i2c::Operation<'a>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
Self::setup(address.into())?; Self::setup(address.into())?;
for i in 0..operations.len() { for i in 0..operations.len() {
let last = i == operations.len() - 1; let last = i == operations.len() - 1;
match &mut operations[i] { match &mut operations[i] {
embedded_hal_1::i2c::blocking::Operation::Read(buf) => { embedded_hal_1::i2c::Operation::Read(buf) => self.read_blocking_internal(buf, false, last)?,
self.read_blocking_internal(buf, false, last)? embedded_hal_1::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?,
}
embedded_hal_1::i2c::blocking::Operation::Write(buf) => self.write_blocking_internal(buf, last)?,
} }
} }
Ok(()) Ok(())
@ -438,17 +436,15 @@ mod eh1 {
fn transaction_iter<'a, O>(&mut self, address: u8, operations: O) -> Result<(), Self::Error> fn transaction_iter<'a, O>(&mut self, address: u8, operations: O) -> Result<(), Self::Error>
where where
O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>, O: IntoIterator<Item = embedded_hal_1::i2c::Operation<'a>>,
{ {
Self::setup(address.into())?; Self::setup(address.into())?;
let mut peekable = operations.into_iter().peekable(); let mut peekable = operations.into_iter().peekable();
while let Some(operation) = peekable.next() { while let Some(operation) = peekable.next() {
let last = peekable.peek().is_none(); let last = peekable.peek().is_none();
match operation { match operation {
embedded_hal_1::i2c::blocking::Operation::Read(buf) => { embedded_hal_1::i2c::Operation::Read(buf) => self.read_blocking_internal(buf, false, last)?,
self.read_blocking_internal(buf, false, last)? embedded_hal_1::i2c::Operation::Write(buf) => self.write_blocking_internal(buf, last)?,
}
embedded_hal_1::i2c::blocking::Operation::Write(buf) => self.write_blocking_internal(buf, last)?,
} }
} }
Ok(()) Ok(())

View File

@ -523,25 +523,25 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::blocking::SpiBusFlush for Spi<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusFlush for Spi<'d, T, M> {
fn flush(&mut self) -> Result<(), Self::Error> { fn flush(&mut self) -> Result<(), Self::Error> {
Ok(()) Ok(())
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::blocking::SpiBusRead<u8> for Spi<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusRead<u8> for Spi<'d, T, M> {
fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_transfer(words, &[]) self.blocking_transfer(words, &[])
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::blocking::SpiBusWrite<u8> for Spi<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBusWrite<u8> for Spi<'d, T, M> {
fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(words) self.blocking_write(words)
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::blocking::SpiBus<u8> for Spi<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::spi::SpiBus<u8> for Spi<'d, T, M> {
fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> { fn transfer(&mut self, read: &mut [u8], write: &[u8]) -> Result<(), Self::Error> {
self.blocking_transfer(read, write) self.blocking_transfer(read, write)
} }

View File

@ -486,7 +486,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::nb::Read for UartRx<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for UartRx<'d, T, M> {
fn read(&mut self) -> nb::Result<u8, Self::Error> { fn read(&mut self) -> nb::Result<u8, Self::Error> {
let r = T::regs(); let r = T::regs();
unsafe { unsafe {
@ -509,7 +509,7 @@ mod eh1 {
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::blocking::Write for UartTx<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::Write for UartTx<'d, T, M> {
fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(buffer) self.blocking_write(buffer)
} }
@ -519,7 +519,7 @@ mod eh1 {
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::nb::Write for UartTx<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for UartTx<'d, T, M> {
fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> {
self.blocking_write(&[char]).map_err(nb::Error::Other) self.blocking_write(&[char]).map_err(nb::Error::Other)
} }
@ -529,13 +529,13 @@ mod eh1 {
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::nb::Read for Uart<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Read for Uart<'d, T, M> {
fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> { fn read(&mut self) -> Result<u8, nb::Error<Self::Error>> {
embedded_hal_02::serial::Read::read(&mut self.rx) embedded_hal_02::serial::Read::read(&mut self.rx)
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::blocking::Write for Uart<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::Write for Uart<'d, T, M> {
fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> { fn write(&mut self, buffer: &[u8]) -> Result<(), Self::Error> {
self.blocking_write(buffer) self.blocking_write(buffer)
} }
@ -545,7 +545,7 @@ mod eh1 {
} }
} }
impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::nb::Write for Uart<'d, T, M> { impl<'d, T: Instance, M: Mode> embedded_hal_nb::serial::Write for Uart<'d, T, M> {
fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> { fn write(&mut self, char: u8) -> nb::Result<(), Self::Error> {
self.blocking_write(&[char]).map_err(nb::Error::Other) self.blocking_write(&[char]).map_err(nb::Error::Other)
} }

View File

@ -42,8 +42,8 @@ embassy-net = { version = "0.1.0", path = "../embassy-net", optional = true }
embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true } embassy-usb-driver = {version = "0.1.0", path = "../embassy-usb-driver", optional = true }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true}
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true}
embedded-storage = "0.3.0" embedded-storage = "0.3.0"
embedded-storage-async = { version = "0.3.0", optional = true } embedded-storage-async = { version = "0.3.0", optional = true }

View File

@ -155,7 +155,7 @@ mod eh1 {
type Error = Infallible; type Error = Infallible;
} }
impl<'d, T: GpioPin> embedded_hal_1::digital::blocking::InputPin for ExtiInput<'d, T> { impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> { fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high()) Ok(self.is_high())
} }

View File

@ -848,8 +848,7 @@ mod eh02 {
#[cfg(feature = "unstable-traits")] #[cfg(feature = "unstable-traits")]
mod eh1 { mod eh1 {
use embedded_hal_1::digital::blocking::{InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin}; use embedded_hal_1::digital::{ErrorType, InputPin, OutputPin, StatefulOutputPin, ToggleableOutputPin};
use embedded_hal_1::digital::ErrorType;
use super::*; use super::*;

View File

@ -334,7 +334,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::i2c::blocking::I2c for I2c<'d, T> { impl<'d, T: Instance> embedded_hal_1::i2c::I2c for I2c<'d, T> {
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_read(address, buffer) self.blocking_read(address, buffer)
} }
@ -364,14 +364,14 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
_address: u8, _address: u8,
_operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], _operations: &mut [embedded_hal_1::i2c::Operation<'a>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
todo!(); todo!();
} }
fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error> fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error>
where where
O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>, O: IntoIterator<Item = embedded_hal_1::i2c::Operation<'a>>,
{ {
todo!(); todo!();
} }

View File

@ -883,7 +883,7 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance> embedded_hal_1::i2c::blocking::I2c for I2c<'d, T, NoDma, NoDma> { impl<'d, T: Instance> embedded_hal_1::i2c::I2c for I2c<'d, T, NoDma, NoDma> {
fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> { fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error> {
self.blocking_read(address, buffer) self.blocking_read(address, buffer)
} }
@ -913,14 +913,14 @@ mod eh1 {
fn transaction<'a>( fn transaction<'a>(
&mut self, &mut self,
_address: u8, _address: u8,
_operations: &mut [embedded_hal_1::i2c::blocking::Operation<'a>], _operations: &mut [embedded_hal_1::i2c::Operation<'a>],
) -> Result<(), Self::Error> { ) -> Result<(), Self::Error> {
todo!(); todo!();
} }
fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error> fn transaction_iter<'a, O>(&mut self, _address: u8, _operations: O) -> Result<(), Self::Error>
where where
O: IntoIterator<Item = embedded_hal_1::i2c::blocking::Operation<'a>>, O: IntoIterator<Item = embedded_hal_1::i2c::Operation<'a>>,
{ {
todo!(); todo!();
} }

View File

@ -843,25 +843,25 @@ mod eh1 {
type Error = Error; type Error = Error;
} }
impl<'d, T: Instance, Tx, Rx> embedded_hal_1::spi::blocking::SpiBusFlush for Spi<'d, T, Tx, Rx> { impl<'d, T: Instance, Tx, Rx> embedded_hal_1::spi::SpiBusFlush for Spi<'d, T, Tx, Rx> {
fn flush(&mut self) -> Result<(), Self::Error> { fn flush(&mut self) -> Result<(), Self::Error> {
Ok(()) Ok(())
} }
} }
impl<'d, T: Instance, W: Word> embedded_hal_1::spi::blocking::SpiBusRead<W> for Spi<'d, T, NoDma, NoDma> { impl<'d, T: Instance, W: Word> embedded_hal_1::spi::SpiBusRead<W> for Spi<'d, T, NoDma, NoDma> {
fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> { fn read(&mut self, words: &mut [W]) -> Result<(), Self::Error> {
self.blocking_read(words) self.blocking_read(words)
} }
} }
impl<'d, T: Instance, W: Word> embedded_hal_1::spi::blocking::SpiBusWrite<W> for Spi<'d, T, NoDma, NoDma> { impl<'d, T: Instance, W: Word> embedded_hal_1::spi::SpiBusWrite<W> for Spi<'d, T, NoDma, NoDma> {
fn write(&mut self, words: &[W]) -> Result<(), Self::Error> { fn write(&mut self, words: &[W]) -> Result<(), Self::Error> {
self.blocking_write(words) self.blocking_write(words)
} }
} }
impl<'d, T: Instance, W: Word> embedded_hal_1::spi::blocking::SpiBus<W> for Spi<'d, T, NoDma, NoDma> { impl<'d, T: Instance, W: Word> embedded_hal_1::spi::SpiBus<W> for Spi<'d, T, NoDma, NoDma> {
fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> { fn transfer(&mut self, read: &mut [W], write: &[W]) -> Result<(), Self::Error> {
self.blocking_transfer(read, write) self.blocking_transfer(read, write)
} }

View File

@ -192,6 +192,10 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi
}) })
} }
fn available(&self, next_message_id: u64) -> u64 {
self.inner.lock(|s| s.borrow().next_message_id - next_message_id)
}
fn publish_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), T> { fn publish_with_context(&self, message: T, cx: Option<&mut Context<'_>>) -> Result<(), T> {
self.inner.lock(|s| { self.inner.lock(|s| {
let mut s = s.borrow_mut(); let mut s = s.borrow_mut();
@ -217,6 +221,13 @@ impl<M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS: usi
}) })
} }
fn space(&self) -> usize {
self.inner.lock(|s| {
let s = s.borrow();
s.queue.capacity() - s.queue.len()
})
}
fn unregister_subscriber(&self, subscriber_next_message_id: u64) { fn unregister_subscriber(&self, subscriber_next_message_id: u64) {
self.inner.lock(|s| { self.inner.lock(|s| {
let mut s = s.borrow_mut(); let mut s = s.borrow_mut();
@ -388,6 +399,10 @@ pub trait PubSubBehavior<T> {
/// If the message is not yet present and a context is given, then its waker is registered in the subsriber wakers. /// If the message is not yet present and a context is given, then its waker is registered in the subsriber wakers.
fn get_message_with_context(&self, next_message_id: &mut u64, cx: Option<&mut Context<'_>>) -> Poll<WaitResult<T>>; fn get_message_with_context(&self, next_message_id: &mut u64, cx: Option<&mut Context<'_>>) -> Poll<WaitResult<T>>;
/// Get the amount of messages that are between the given the next_message_id and the most recent message.
/// This is not necessarily the amount of messages a subscriber can still received as it may have lagged.
fn available(&self, next_message_id: u64) -> u64;
/// Try to publish a message to the queue. /// Try to publish a message to the queue.
/// ///
/// If the queue is full and a context is given, then its waker is registered in the publisher wakers. /// If the queue is full and a context is given, then its waker is registered in the publisher wakers.
@ -396,6 +411,9 @@ pub trait PubSubBehavior<T> {
/// Publish a message immediately /// Publish a message immediately
fn publish_immediate(&self, message: T); fn publish_immediate(&self, message: T);
/// The amount of messages that can still be published without having to wait or without having to lag the subscribers
fn space(&self) -> usize;
/// Let the channel know that a subscriber has dropped /// Let the channel know that a subscriber has dropped
fn unregister_subscriber(&self, subscriber_next_message_id: u64); fn unregister_subscriber(&self, subscriber_next_message_id: u64);
@ -539,4 +557,59 @@ mod tests {
drop(sub0); drop(sub0);
} }
#[futures_test::test]
async fn correct_available() {
let channel = PubSubChannel::<NoopRawMutex, u32, 4, 4, 4>::new();
let sub0 = channel.subscriber().unwrap();
let mut sub1 = channel.subscriber().unwrap();
let pub0 = channel.publisher().unwrap();
assert_eq!(sub0.available(), 0);
assert_eq!(sub1.available(), 0);
pub0.publish(42).await;
assert_eq!(sub0.available(), 1);
assert_eq!(sub1.available(), 1);
sub1.next_message().await;
assert_eq!(sub1.available(), 0);
pub0.publish(42).await;
assert_eq!(sub0.available(), 2);
assert_eq!(sub1.available(), 1);
}
#[futures_test::test]
async fn correct_space() {
let channel = PubSubChannel::<NoopRawMutex, u32, 4, 4, 4>::new();
let mut sub0 = channel.subscriber().unwrap();
let mut sub1 = channel.subscriber().unwrap();
let pub0 = channel.publisher().unwrap();
assert_eq!(pub0.space(), 4);
pub0.publish(42).await;
assert_eq!(pub0.space(), 3);
pub0.publish(42).await;
assert_eq!(pub0.space(), 2);
sub0.next_message().await;
sub0.next_message().await;
assert_eq!(pub0.space(), 2);
sub1.next_message().await;
assert_eq!(pub0.space(), 3);
sub1.next_message().await;
assert_eq!(pub0.space(), 4);
}
} }

View File

@ -42,6 +42,14 @@ impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Pub<'a, PSB, T> {
pub fn try_publish(&self, message: T) -> Result<(), T> { pub fn try_publish(&self, message: T) -> Result<(), T> {
self.channel.publish_with_context(message, None) self.channel.publish_with_context(message, None)
} }
/// The amount of messages that can still be published without having to wait or without having to lag the subscribers
///
/// *Note: In the time between checking this and a publish action, other publishers may have had time to publish something.
/// So checking doesn't give any guarantees.*
pub fn space(&self) -> usize {
self.channel.space()
}
} }
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Pub<'a, PSB, T> { impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Pub<'a, PSB, T> {
@ -158,6 +166,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS:
} }
/// Future for the publisher wait action /// Future for the publisher wait action
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { pub struct PublisherWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
/// The message we need to publish /// The message we need to publish
message: Option<T>, message: Option<T>,

View File

@ -64,6 +64,11 @@ impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Sub<'a, PSB, T> {
} }
} }
} }
/// The amount of messages this subscriber hasn't received yet
pub fn available(&self) -> u64 {
self.channel.available(self.next_message_id)
}
} }
impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Sub<'a, PSB, T> { impl<'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> Drop for Sub<'a, PSB, T> {
@ -135,6 +140,7 @@ impl<'a, M: RawMutex, T: Clone, const CAP: usize, const SUBS: usize, const PUBS:
} }
/// Future for the subscriber wait action /// Future for the subscriber wait action
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> { pub struct SubscriberWaitFuture<'s, 'a, PSB: PubSubBehavior<T> + ?Sized, T: Clone> {
subscriber: &'s mut Sub<'a, PSB, T>, subscriber: &'s mut Sub<'a, PSB, T>,
} }

View File

@ -105,8 +105,8 @@ defmt = { version = "0.3", optional = true }
log = { version = "0.4.14", optional = true } log = { version = "0.4.14", optional = true }
embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" } embedded-hal-02 = { package = "embedded-hal", version = "0.2.6" }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8", optional = true} embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9", optional = true}
embedded-hal-async = { version = "0.1.0-alpha.1", optional = true} embedded-hal-async = { version = "=0.1.0-alpha.2", optional = true}
futures-util = { version = "0.3.17", default-features = false } futures-util = { version = "0.3.17", default-features = false }
embassy-macros = { version = "0.1.0", path = "../embassy-macros"} embassy-macros = { version = "0.1.0", path = "../embassy-macros"}
@ -117,4 +117,4 @@ cfg-if = "1.0.0"
# WASM dependencies # WASM dependencies
wasm-bindgen = { version = "0.2.81", optional = true } wasm-bindgen = { version = "0.2.81", optional = true }
js-sys = { version = "0.3", optional = true } js-sys = { version = "0.3", optional = true }
wasm-timer = { version = "0.2.5", optional = true } wasm-timer = { version = "0.2.5", optional = true }

View File

@ -18,7 +18,7 @@ pub struct Delay;
mod eh1 { mod eh1 {
use super::*; use super::*;
impl embedded_hal_1::delay::blocking::DelayUs for Delay { impl embedded_hal_1::delay::DelayUs for Delay {
type Error = core::convert::Infallible; type Error = core::convert::Infallible;
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> { fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {

View File

@ -54,12 +54,16 @@ impl From<EndpointAddress> for u8 {
} }
impl EndpointAddress { impl EndpointAddress {
const INBITS: u8 = Direction::In as u8; const INBITS: u8 = 0x80;
/// Constructs a new EndpointAddress with the given index and direction. /// Constructs a new EndpointAddress with the given index and direction.
#[inline] #[inline]
pub fn from_parts(index: usize, dir: Direction) -> Self { pub fn from_parts(index: usize, dir: Direction) -> Self {
EndpointAddress(index as u8 | dir as u8) let dir_u8 = match dir {
Direction::Out => 0x00,
Direction::In => Self::INBITS,
};
EndpointAddress(index as u8 | dir_u8)
} }
/// Gets the direction part of the address. /// Gets the direction part of the address.

View File

@ -108,9 +108,9 @@ mod shared_spi {
use core::cell::RefCell; use core::cell::RefCell;
use core::fmt::Debug; use core::fmt::Debug;
use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi; use embedded_hal_1::spi;
use embedded_hal_1::spi::blocking::SpiDevice; use embedded_hal_1::spi::SpiDevice;
#[derive(Copy, Clone, Eq, PartialEq, Debug)] #[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum SpiDeviceWithCsError<BUS, CS> { pub enum SpiDeviceWithCsError<BUS, CS> {
@ -153,7 +153,7 @@ mod shared_spi {
impl<'a, BUS, CS> SpiDevice for SpiDeviceWithCs<'a, BUS, CS> impl<'a, BUS, CS> SpiDevice for SpiDeviceWithCs<'a, BUS, CS>
where where
BUS: spi::blocking::SpiBusFlush, BUS: spi::SpiBusFlush,
CS: OutputPin, CS: OutputPin,
{ {
type Bus = BUS; type Bus = BUS;
@ -182,7 +182,7 @@ mod shared_spi {
/// Driver for the XPT2046 resistive touchscreen sensor /// Driver for the XPT2046 resistive touchscreen sensor
mod touch { mod touch {
use embedded_hal_1::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice}; use embedded_hal_1::spi::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice};
struct Calibration { struct Calibration {
x1: i32, x1: i32,
@ -246,8 +246,8 @@ mod touch {
mod my_display_interface { mod my_display_interface {
use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand}; use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand};
use embedded_hal_1::digital::blocking::OutputPin; use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi::blocking::{SpiBusWrite, SpiDevice}; use embedded_hal_1::spi::{SpiBusWrite, SpiDevice};
/// SPI display interface. /// SPI display interface.
/// ///

View File

@ -17,8 +17,8 @@ defmt-rtt = "0.3"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0" cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6" embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" } embedded-hal-async = { version = "=0.1.0-alpha.2" }
embedded-nal-async = "0.2.0" embedded-nal-async = "0.2.0"
panic-probe = { version = "0.3", features = ["print-defmt"] } panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] }

View File

@ -18,8 +18,8 @@ defmt-rtt = "0.3"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0" cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6" embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" } embedded-hal-async = { version = "=0.1.0-alpha.2" }
panic-probe = { version = "0.3", features = ["print-defmt"] } panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
heapless = { version = "0.7.5", default-features = false } heapless = { version = "0.7.5", default-features = false }

View File

@ -16,8 +16,8 @@ defmt-rtt = "0.3.0"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0" cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6" embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" } embedded-hal-async = { version = "=0.1.0-alpha.2" }
panic-probe = { version = "0.3.0", features = ["print-defmt"] } panic-probe = { version = "0.3.0", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] } futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
embedded-io = { version = "0.3.0", features = ["async"] } embedded-io = { version = "0.3.0", features = ["async"] }

View File

@ -24,8 +24,8 @@ defmt-rtt = "0.3.0"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0" cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6" embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" } embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" } embedded-hal-async = { version = "=0.1.0-alpha.2" }
panic-probe = { version = "0.3.0", features = ["print-defmt"] } panic-probe = { version = "0.3.0", features = ["print-defmt"] }
[profile.dev] [profile.dev]