Skip to main content

I2CMaster3

Struct I2CMaster3 

Source
pub struct I2CMaster3<P0, P1>
where P0: CompatiblePad<Sercom = SERCOM3, PadNum = Pad0>, P1: CompatiblePad<Sercom = SERCOM3, PadNum = Pad1>,
{ /* private fields */ }
Expand description

Represents the Sercom instance configured to act as an I2C Master. The embedded_hal blocking I2C traits are implemented by this instance.

Implementations§

Source§

impl<P0, P1> I2CMaster3<P0, P1>
where P1: CompatiblePad<Sercom = SERCOM3, PadNum = Pad1>, P0: CompatiblePad<Sercom = SERCOM3, PadNum = Pad0>,

Source

pub fn new<F>( clock: &Sercom3CoreClock, freq: F, sercom: SERCOM3, mclk: &mut MCLK, sda: P0, scl: P1, ) -> I2CMaster3<P0, P1>
where F: Into<Hertz>,

Configures the sercom instance to work as an I2C Master. The clock is obtained via the GenericClockGenerator type. freq specifies the bus frequency to use for I2C communication. There are typically a handful of values that tend to be supported; standard mode is 100.khz(), full speed mode is 400.khz(). The hardware in the atsamd device supports fast mode at 1.mhz() and fast mode, but there may be additional hardware configuration missing from the current software implementation that prevents that from working as-written today.

let mut i2c = I2CMaster3::new(
    &clocks.sercom3_core(&gclk0).unwrap(),
    400.khz(),
    p.device.SERCOM3,
    &mut p.device.MCLK,
    // Metro M0 express has I2C on pins PA22, PA23
    pins.pa22.into_pad(&mut pins.port),
    pins.pa23.into_pad(&mut pins.port),
);
Source

pub fn free(self) -> (P0, P1, SERCOM3)

Breaks the sercom device up into its constituent pins and the SERCOM instance. Does not make any changes to power management.

Trait Implementations§

Source§

impl<P0, P1> Read for I2CMaster3<P0, P1>
where P1: CompatiblePad<Sercom = SERCOM3, PadNum = Pad1>, P0: CompatiblePad<Sercom = SERCOM3, PadNum = Pad0>,

Source§

type Error = I2CError

Error type
Source§

fn read( &mut self, addr: u8, buffer: &mut [u8], ) -> Result<(), <I2CMaster3<P0, P1> as Read>::Error>

Reads enough bytes from slave with address to fill buffer Read more
Source§

impl<P0, P1> Write for I2CMaster3<P0, P1>
where P1: CompatiblePad<Sercom = SERCOM3, PadNum = Pad1>, P0: CompatiblePad<Sercom = SERCOM3, PadNum = Pad0>,

Source§

fn write( &mut self, addr: u8, bytes: &[u8], ) -> Result<(), <I2CMaster3<P0, P1> as Write>::Error>

Sends bytes to slave with address addr

Source§

type Error = I2CError

Error type
Source§

impl<P0, P1> WriteRead for I2CMaster3<P0, P1>
where P1: CompatiblePad<Sercom = SERCOM3, PadNum = Pad1>, P0: CompatiblePad<Sercom = SERCOM3, PadNum = Pad0>,

Source§

type Error = I2CError

Error type
Source§

fn write_read( &mut self, addr: u8, bytes: &[u8], buffer: &mut [u8], ) -> Result<(), <I2CMaster3<P0, P1> as WriteRead>::Error>

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more

Auto Trait Implementations§

§

impl<P0, P1> !Sync for I2CMaster3<P0, P1>

§

impl<P0, P1> Freeze for I2CMaster3<P0, P1>
where P0: Freeze, P1: Freeze,

§

impl<P0, P1> RefUnwindSafe for I2CMaster3<P0, P1>

§

impl<P0, P1> Send for I2CMaster3<P0, P1>
where P0: Send, P1: Send,

§

impl<P0, P1> Unpin for I2CMaster3<P0, P1>
where P0: Unpin, P1: Unpin,

§

impl<P0, P1> UnsafeUnpin for I2CMaster3<P0, P1>
where P0: UnsafeUnpin, P1: UnsafeUnpin,

§

impl<P0, P1> UnwindSafe for I2CMaster3<P0, P1>
where P0: UnwindSafe, P1: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.