[−][src]Struct lpc81x_hal::i2c::I2C
Represents the I2C peripheral.
The I2C peripheral starts in an inactive state, not connected to
any pins. To use it, call activate
to activate the peripheral and assign
it external pins for the SCL and SDA signals.
The I2C peripheral has three modes that can each be independently activated:
- Host mode: initiates communication with devices on the bus; enable with
enable_host_mode
. - Device mode: responds to communication requests from hosts on the bus; enable with
enable_device_mdoe
. - Monitor mode: monitors communications on the bus without transmitting anything; enable with
enable_monitor_mode
.
With no modes activated, the I2C peripheral is powered but cannot transmit or recieve any data.
Methods
impl I2C<Unassigned, Unassigned, HostInactive, DeviceInactive, MonitorInactive>
[src]
pub fn activate<SCL: UnassignedPin, SDA: UnassignedPin>(
self,
scl: SCL,
sda: SDA
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostInactive, DeviceInactive, MonitorInactive>
[src]
self,
scl: SCL,
sda: SDA
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostInactive, DeviceInactive, MonitorInactive>
Consumes the inactive I2C bus and returns it with host mode enabled, using the given pins for SCL and SDA.
Only pins 10 and 11 (in either order) can provide fully I2C-compliant behavior, but other pins can be used with some caveats. See the LPC81x user manual for more information and caveats.
impl<SCL, SDA, DS, MS> I2C<Assigned<SCL>, Assigned<SDA>, HostInactive, DS, MS> where
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
pub fn enable_host_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS>
Consumes the active I2C bus and returns it with host mode activated, and thus with the host-mode-only methods available.
impl<SCL, SDA, HS, MS> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceInactive, MS> where
SCL: Pin,
SDA: Pin,
HS: HostStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
HS: HostStatus,
MS: MonitorStatus,
pub fn enable_device_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceActive, MS>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceActive, MS>
Consumes the active I2C bus and returns it with device mode activated, and thus with the device-mode-only methods available.
impl<SCL, SDA, HS, DS> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorInactive> where
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
[src]
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
pub fn enable_monitor_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorActive>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorActive>
Consumes the active I2C bus and returns it with monitor mode activated, and thus with the monitor-mode-only methods available.
impl<SCL, SDA, DS, MS> I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS> where
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
Host mode methods
These methods are available only once host mode is active.
pub fn disable_host_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostInactive, DS, MS>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostInactive, DS, MS>
Consumes the active I2C bus and returns it with host mode deactivated.
impl<SCL, SDA, HS, MS> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceActive, MS> where
SCL: Pin,
SDA: Pin,
HS: HostStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
HS: HostStatus,
MS: MonitorStatus,
Device mode methods
These methods are available only once device mode is active.
pub fn disable_device_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceInactive, MS>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceInactive, MS>
Consumes the active I2C bus and returns it with device mode deactivated.
impl<SCL, SDA, HS, DS> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorActive> where
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
[src]
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
Monitor mode methods
These methods are available only once monitor mode is active.
pub fn disable_monitor_mode(
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorInactive>
[src]
&self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorInactive>
Consumes the active I2C bus and returns it with monitor mode deactivated.
impl<SCL, SDA, HS, DS, MS> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MS> where
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
HS: HostStatus,
DS: DeviceStatus,
MS: MonitorStatus,
pub fn deactivate(
self
) -> (I2C<Unassigned, Unassigned, HostInactive, DeviceInactive, MonitorInactive>, SCL, SDA)
[src]
self
) -> (I2C<Unassigned, Unassigned, HostInactive, DeviceInactive, MonitorInactive>, SCL, SDA)
Consumes the active I2C bus and returns it deactivated, along with the now-unused pins that were used for SCL and SDA.
Trait Implementations
impl<SCL: Debug, SDA: Debug, HS: Debug, DS: Debug, MS: Debug> Debug for I2C<SCL, SDA, HS, DS, MS> where
SCL: PinAssignment,
SDA: PinAssignment,
HS: HostStatus,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: PinAssignment,
SDA: PinAssignment,
HS: HostStatus,
DS: DeviceStatus,
MS: MonitorStatus,
impl<SCL, SDA, HS, DS, MS> !Sync for I2C<SCL, SDA, HS, DS, MS>
[src]
impl<SCL, SDA, DS, MS> Write for I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS> where
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
type Error = HostError
Error type
fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>
[src]
impl<SCL, SDA, DS, MS> WriteRead for I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS> where
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
[src]
SCL: Pin,
SDA: Pin,
DS: DeviceStatus,
MS: MonitorStatus,
Auto Trait Implementations
impl<SCL, SDA, HS, DS, MS> Unpin for I2C<SCL, SDA, HS, DS, MS> where
DS: Unpin,
HS: Unpin,
MS: Unpin,
SCL: Unpin,
SDA: Unpin,
DS: Unpin,
HS: Unpin,
MS: Unpin,
SCL: Unpin,
SDA: Unpin,
impl<SCL, SDA, HS, DS, MS> Send for I2C<SCL, SDA, HS, DS, MS> where
DS: Send,
HS: Send,
MS: Send,
SCL: Send,
SDA: Send,
DS: Send,
HS: Send,
MS: Send,
SCL: Send,
SDA: Send,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
type Output = T
Should always be Self