[][src]Struct lpc81x_hal::i2c::I2C

pub struct I2C<SCL, SDA, HS, DS, MS> where
    SCL: PinAssignment,
    SDA: PinAssignment,
    HS: HostStatus,
    DS: DeviceStatus,
    MS: MonitorStatus
{ /* fields omitted */ }

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]

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]

pub fn enable_host_mode(
    &self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HostActive, DS, MS>
[src]

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]

pub fn enable_device_mode(
    &self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DeviceActive, MS>
[src]

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]

pub fn enable_monitor_mode(
    &self
) -> I2C<Assigned<SCL>, Assigned<SDA>, HS, DS, MonitorActive>
[src]

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]

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]

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]

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]

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]

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]

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]

pub fn deactivate(
    self
) -> (I2C<Unassigned, Unassigned, HostInactive, DeviceInactive, MonitorInactive>, SCL, SDA)
[src]

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, SDA, HS, DS, MS> !Sync for I2C<SCL, SDA, HS, DS, MS>[src]

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]

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]

type Error = HostError

Error type

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]

type Error = HostError

Error type

Auto Trait Implementations

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

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

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self