mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-28 21:01:06 +00:00
Merge pull request #3810 from Freax13/enhancement/invalid-i2c-rp
remove checks for reserved I2c addresses
This commit is contained in:
commit
845da2ced1
@ -1,3 +1,5 @@
|
||||
#![cfg_attr(feature = "defmt", allow(deprecated))] // Suppress warnings for defmt::Format using Error::AddressReserved
|
||||
|
||||
//! I2C driver.
|
||||
use core::future;
|
||||
use core::marker::PhantomData;
|
||||
@ -40,6 +42,7 @@ pub enum Error {
|
||||
/// Target i2c address is out of range
|
||||
AddressOutOfRange(u16),
|
||||
/// Target i2c address is reserved
|
||||
#[deprecated = "embassy_rp no longer prevents accesses to reserved addresses."]
|
||||
AddressReserved(u16),
|
||||
}
|
||||
|
||||
@ -470,10 +473,6 @@ impl<'d, T: Instance + 'd, M: Mode> I2c<'d, T, M> {
|
||||
return Err(Error::AddressOutOfRange(addr));
|
||||
}
|
||||
|
||||
if i2c_reserved_addr(addr) {
|
||||
return Err(Error::AddressReserved(addr));
|
||||
}
|
||||
|
||||
let p = T::regs();
|
||||
p.ic_enable().write(|w| w.set_enable(false));
|
||||
p.ic_tar().write(|w| w.set_ic_tar(addr));
|
||||
@ -680,6 +679,7 @@ impl embedded_hal_1::i2c::Error for Error {
|
||||
Self::InvalidReadBufferLength => embedded_hal_1::i2c::ErrorKind::Other,
|
||||
Self::InvalidWriteBufferLength => embedded_hal_1::i2c::ErrorKind::Other,
|
||||
Self::AddressOutOfRange(_) => embedded_hal_1::i2c::ErrorKind::Other,
|
||||
#[allow(deprecated)]
|
||||
Self::AddressReserved(_) => embedded_hal_1::i2c::ErrorKind::Other,
|
||||
}
|
||||
}
|
||||
@ -775,11 +775,6 @@ impl<'d, T: Instance, M: Mode> embassy_embedded_hal::SetConfig for I2c<'d, T, M>
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if address is reserved.
|
||||
pub fn i2c_reserved_addr(addr: u16) -> bool {
|
||||
((addr & 0x78) == 0 || (addr & 0x78) == 0x78) && addr != 0
|
||||
}
|
||||
|
||||
pub(crate) trait SealedInstance {
|
||||
fn regs() -> crate::pac::i2c::I2c;
|
||||
fn reset() -> crate::pac::resets::regs::Peripherals;
|
||||
|
@ -6,9 +6,7 @@ use core::task::Poll;
|
||||
use embassy_hal_internal::into_ref;
|
||||
use pac::i2c;
|
||||
|
||||
use crate::i2c::{
|
||||
i2c_reserved_addr, set_up_i2c_pin, AbortReason, Instance, InterruptHandler, SclPin, SdaPin, FIFO_SIZE,
|
||||
};
|
||||
use crate::i2c::{set_up_i2c_pin, AbortReason, Instance, InterruptHandler, SclPin, SdaPin, FIFO_SIZE};
|
||||
use crate::interrupt::typelevel::{Binding, Interrupt};
|
||||
use crate::{pac, Peripheral};
|
||||
|
||||
@ -97,7 +95,6 @@ impl<'d, T: Instance> I2cSlave<'d, T> {
|
||||
) -> Self {
|
||||
into_ref!(_peri, scl, sda);
|
||||
|
||||
assert!(!i2c_reserved_addr(config.addr));
|
||||
assert!(config.addr != 0);
|
||||
|
||||
// Configure SCL & SDA pins
|
||||
|
Loading…
x
Reference in New Issue
Block a user