pub struct Config<P> where
    P: PadSet
{ /* private fields */ }
Expand description

A configurable, disabled I2C peripheral

This struct represents a configurable I2C peripheral in its disabled state. It is generic over the set of Pads. Upon creation, the Config takes ownership of the Sercom and resets it, returning it configured as an I2C peripheral with a default configuration in Master mode.

Config uses a builder-pattern API to configure the peripheral, culminating in a call to enable, which consumes the Config and returns an enabled I2c.

Implementations

Create a new Config in the default configuration

This function will enable the corresponding APB clock, reset the Sercom peripheral, and return a Config in the default configuration. The only available operating mode is currently Master.

Note that Config takes ownership of both the PAC Sercom struct as well as the Pads.

Users must configure GCLK manually. The freq parameter represents the GCLK frequency for this Sercom instance.

Obtain a reference to the PAC SERCOM struct

Safety

Directly accessing the SERCOM could break the invariants of the type-level tracking in this module, so it is unsafe.

Trigger the Sercom’s SWRST and return a Config in the default configuration.

Consume the Config, reset the peripheral, and return the Sercom and Pads

Run in standby mode (builder pattern version)

When set, the I2C peripheral will run in standby mode. See the datasheet for more details.

Run in standby mode (setter version)

When set, the I2C peripheral will run in standby mode. See the datasheet for more details.

Get the current run in standby mode

Set the baud rate (builder pattern version)

This function will calculate the best BAUD register setting based on the stored GCLK frequency and desired baud rate. The maximum baud rate is GCLK frequency/10. Values outside this range will saturate at the maximum supported baud rate.

Note that 3x oversampling is not supported.

Set the baud rate (setter version)

This function will calculate the best BAUD register setting based on the stored GCLK frequency and desired baud rate. The maximum baud rate is GCLK frequency/10. Values outside this range will saturate at the maximum supported baud rate.

Get the contents of the BAUD register and the current baud mode. Note that only the CONTENTS of BAUD are returned, and not the actual baud rate. Refer to the datasheet to convert the BAUD register contents into a baud rate.

Set SCL Low Time-Out (builder pattern version)

If SCL is held low for 25ms-35ms, the master will release its clock hold, if enabled, and complete the current transaction. A stop condition will automatically be transmitted. INTFLAG.SB or INTFLAG.MB will be set as normal, but the clock hold will be released. The STATUS.LOWTOUT and STATUS.BUSERR status bits will be set.

Set SCL Low Time-Out (setter version)

If SCL is held low for 25ms-35ms, the master will release its clock hold, if enabled, and complete the current transaction. A stop condition will automatically be transmitted. INTFLAG.SB or INTFLAG.MB will be set as normal, but the clock hold will be released. The STATUS.LOWTOUT and STATUS.BUSERR status bits will be set.

Get SCL Low Time-Out setting

If SCL is held low for 25ms-35ms, the master will release its clock hold, if enabled, and complete the current transaction. A stop condition will automatically be transmitted. INTFLAG.SB or INTFLAG.MB will be set as normal, but the clock hold will be released. The STATUS.LOWTOUT and STATUS.BUSERR status bits will be set.

Set the inactive timeout (builder pattern version).

Timeout after which the bus state will be set to IDLE. Necessary for SMBus compatibility.

Set the inactive timeout (setter version).

Timeout after which the bus state will be set to IDLE. Necessary for SMBus compatibility.

Get the inactive timeout setting.

Enable the I2C peripheral

I2C transactions are not possible until the peripheral is enabled.

Trait Implementations

Converts this type into a mutable reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.