# I2C Module

The inter-integrated circuit (I2C) API provides a set of functions to configure the device’s I2C module. The driver supports operation in both master and slave mode and provides functions to initialize the module, to send and receive data, to obtain status information, and to manage interrupts.

group `i2c_api`

  Defines

  `I2C_CONTROLLER_SEND_MODE` 0x0600U

    Controller-transmitter mode.

  `I2C_CONTROLLER_RECEIVE_MODE` 0x0400U

    Controller-receiver mode.

  `I2C_TARGET_SEND_MODE` 0x0200U

    Target-transmitter mode.

  `I2C_TARGET_RECEIVE_MODE` 0x0000U

    Target-receiver mode.

  `I2C_REPEAT_MODE` 0x0080U

    Only applies to Controller mode.

  `I2C_START_BYTE_MODE` 0x0010U

    Enable start byte mode.

  `I2C_FREE_DATA_FORMAT` 0x0008U

    Enable free data (no addr) format.

  `I2C_INT_ARB_LOST` 0x00001U

    Arbitration-lost interrupt.

  `I2C_INT_NO_ACK` 0x00002U

    NACK interrupt.

  `I2C_INT_REG_ACCESS_RDY` 0x00004U

    Register-access-ready interrupt.

  `I2C_INT_RX_DATA_RDY` 0x00008U

    Receive-data-ready interrupt.

  `I2C_INT_TX_DATA_RDY` 0x00010U

    Transmit-data-ready interrupt.

  `I2C_INT_STOP_CONDITION` 0x00020U

    Stop condition detected.

  `I2C_INT_ADDR_TARGET` 0x00200U

    Addressed as target interrupt.

  `I2C_INT_RXFF` 0x10000U

    RX FIFO level interrupt.

  `I2C_INT_TXFF` 0x20000U

    TX FIFO level interrupt.

  `I2C_STR_INTMASK` ((uint16_t)I2C_INT_ARB_LOST

  | \

  (uint16_t)

  I2C_INT_NO_ACK

  | \

  (uint16_t)

  I2C_INT_REG_ACCESS_RDY

  | \

  (uint16_t)

  I2C_INT_RX_DATA_RDY

  | \

  (uint16_t)

  I2C_INT_TX_DATA_RDY

  | \

  (uint16_t)

  I2C_INT_STOP_CONDITION

  | \

  (uint16_t)

  I2C_INT_ADDR_TARGET)
  `I2C_STS_ARB_LOST` 0x0001U

    Arbitration-lost.

  `I2C_STS_NO_ACK` 0x0002U

    No-acknowledgment (NACK)

  `I2C_STS_REG_ACCESS_RDY` 0x0004U

    Register-access-ready (ARDY)

  `I2C_STS_RX_DATA_RDY` 0x0008U

    Receive-data-ready.

  `I2C_STS_TX_DATA_RDY` 0x0010U

    Transmit-data-ready.

  `I2C_STS_STOP_CONDITION` 0x0020U

    Stop condition detected.

  `I2C_STS_BYTE_SENT` 0x0040U

    Byte transmit complete.

  `I2C_STS_ADDR_ZERO` 0x0100U

    Address of all zeros detected.

  `I2C_STS_ADDR_TARGET` 0x0200U

    Addressed as target.

  `I2C_STS_TX_EMPTY` 0x0400U

    Transmit shift register empty.

  `I2C_STS_RX_FULL` 0x0800U

    Receive shift register full.

  `I2C_STS_BUS_BUSY` 0x1000U

    Bus busy, wait for STOP or reset.

  `I2C_STS_NACK_SENT` 0x2000U

    NACK was sent.

  `I2C_STS_TARGET_DIR` 0x4000U

    Addressed as target transmitter.

  Enums

  enum `I2C_InterruptSource`

    I2C interrupts to be returned by I2C_getInterruptSource().

    Values:

    enumerator `I2C_INTSRC_NONE`

      No interrupt pending.

    enumerator `I2C_INTSRC_ARB_LOST`

      Arbitration-lost interrupt.

    enumerator `I2C_INTSRC_NO_ACK`

      NACK interrupt.

    enumerator `I2C_INTSRC_REG_ACCESS_RDY`

      Register-access-ready interrupt.

    enumerator `I2C_INTSRC_RX_DATA_RDY`

      Receive-data-ready interrupt.

    enumerator `I2C_INTSRC_TX_DATA_RDY`

      Transmit-data-ready interrupt.

    enumerator `I2C_INTSRC_STOP_CONDITION`

      Stop condition detected.

    enumerator `I2C_INTSRC_ADDR_TARGET`

      Addressed as target interrupt.

  enum `I2C_TxFIFOLevel`

    Values that can be passed to I2C_setFIFOInterruptLevel() as the txLevel parameter, returned by I2C_getFIFOInterruptLevel() in the txLevel parameter, and returned by I2C_getTxFIFOStatus().

    Values:

    enumerator `I2C_FIFO_TXEMPTY` = 0x0000U

      Transmit FIFO empty.

    enumerator `I2C_FIFO_TX0` = 0x0000U

      Transmit FIFO empty.

    enumerator `I2C_FIFO_TX1` = 0x0001U

      Transmit FIFO 1/16 full.

    enumerator `I2C_FIFO_TX2` = 0x0002U

      Transmit FIFO 2/16 full.

    enumerator `I2C_FIFO_TX3` = 0x0003U

      Transmit FIFO 3/16 full.

    enumerator `I2C_FIFO_TX4` = 0x0004U

      Transmit FIFO 4/16 full.

    enumerator `I2C_FIFO_TX5` = 0x0005U

      Transmit FIFO 5/16 full.

    enumerator `I2C_FIFO_TX6` = 0x0006U

      Transmit FIFO 6/16 full.

    enumerator `I2C_FIFO_TX7` = 0x0007U

      Transmit FIFO 7/16 full.

    enumerator `I2C_FIFO_TX8` = 0x0008U

      Transmit FIFO 8/16 full.

    enumerator `I2C_FIFO_TX9` = 0x0009U

      Transmit FIFO 9/16 full.

    enumerator `I2C_FIFO_TX10` = 0x000AU

      Transmit FIFO 10/16 full.

    enumerator `I2C_FIFO_TX11` = 0x000BU

      Transmit FIFO 11/16 full.

    enumerator `I2C_FIFO_TX12` = 0x000CU

      Transmit FIFO 12/16 full.

    enumerator `I2C_FIFO_TX13` = 0x000DU

      Transmit FIFO 13/16 full.

    enumerator `I2C_FIFO_TX14` = 0x000EU

      Transmit FIFO 14/16 full.

    enumerator `I2C_FIFO_TX15` = 0x000FU

      Transmit FIFO 15/16 full.

    enumerator `I2C_FIFO_TX16` = 0x0010U

      Transmit FIFO full.

    enumerator `I2C_FIFO_TXFULL` = 0x0010U

      Transmit FIFO full.

  enum `I2C_RxFIFOLevel`

    Values that can be passed to I2C_setFIFOInterruptLevel() as the rxLevel parameter, returned by I2C_getFIFOInterruptLevel() in the rxLevel parameter, and returned by I2C_getRxFIFOStatus().

    Values:

    enumerator `I2C_FIFO_RXEMPTY` = 0x0000U

      Receive FIFO empty.

    enumerator `I2C_FIFO_RX0` = 0x0000U

      Receive FIFO empty.

    enumerator `I2C_FIFO_RX1` = 0x0001U

      Receive FIFO 1/16 full.

    enumerator `I2C_FIFO_RX2` = 0x0002U

      Receive FIFO 2/16 full.

    enumerator `I2C_FIFO_RX3` = 0x0003U

      Receive FIFO 3/16 full.

    enumerator `I2C_FIFO_RX4` = 0x0004U

      Receive FIFO 4/16 full.

    enumerator `I2C_FIFO_RX5` = 0x0005U

      Receive FIFO 5/16 full.

    enumerator `I2C_FIFO_RX6` = 0x0006U

      Receive FIFO 6/16 full.

    enumerator `I2C_FIFO_RX7` = 0x0007U

      Receive FIFO 7/16 full.

    enumerator `I2C_FIFO_RX8` = 0x0008U

      Receive FIFO 8/16 full.

    enumerator `I2C_FIFO_RX9` = 0x0009U

      Receive FIFO 9/16 full.

    enumerator `I2C_FIFO_RX10` = 0x000AU

      Receive FIFO 10/16 full.

    enumerator `I2C_FIFO_RX11` = 0x000BU

      Receive FIFO 11/16 full.

    enumerator `I2C_FIFO_RX12` = 0x000CU

      Receive FIFO 12/16 full.

    enumerator `I2C_FIFO_RX13` = 0x000DU

      Receive FIFO 13/16 full.

    enumerator `I2C_FIFO_RX14` = 0x000EU

      Receive FIFO 14/16 full.

    enumerator `I2C_FIFO_RX15` = 0x000FU

      Receive FIFO 15/16 full.

    enumerator `I2C_FIFO_RX16` = 0x0010U

      Receive FIFO full.

    enumerator `I2C_FIFO_RXFULL` = 0x0010U

      Receive FIFO full.

  enum `I2C_BitCount`

    Values that can be passed to I2C_setBitCount() as the size parameter.

    Values:

    enumerator `I2C_BITCOUNT_1` = 1U

      1 bit per data byte

    enumerator `I2C_BITCOUNT_2` = 2U

      2 bits per data byte

    enumerator `I2C_BITCOUNT_3` = 3U

      3 bits per data byte

    enumerator `I2C_BITCOUNT_4` = 4U

      4 bits per data byte

    enumerator `I2C_BITCOUNT_5` = 5U

      5 bits per data byte

    enumerator `I2C_BITCOUNT_6` = 6U

      6 bits per data byte

    enumerator `I2C_BITCOUNT_7` = 7U

      7 bits per data byte

    enumerator `I2C_BITCOUNT_8` = 0U

      8 bits per data byte

  enum `I2C_AddressMode`

    Values that can be passed to I2C_setAddressMode() as the mode parameter.

    Values:

    enumerator `I2C_ADDR_MODE_7BITS` = 0x0000U

      7-bit address

    enumerator `I2C_ADDR_MODE_10BITS` = 0x0100U

      10-bit address

  enum `I2C_ExtendedMode`

    Values that can be passed to I2C_setExtendedMode() as the mode parameter.

    Values:

    enumerator `I2C_EADDR_MODE_BC` = 1U

      Backward compatibility.

    enumerator `I2C_EADDR_MODE_FWD` = 2U

      Forward compatibility.

  enum `I2C_EmulationMode`

    Values that can be passed to I2C_setEmulationMode() as the mode parameter.

    Values:

    enumerator `I2C_EMULATION_STOP_SCL_LOW` = 0x0000U

      If SCL is low, keep it low. If high, stop when it goes low again.

    enumerator `I2C_EMULATION_FREE_RUN` = 0x4000U

      Continue I2C operation regardless.

  enum `I2C_DutyCycle`

    Values that can be passed to I2C_initController() as the dutyCycle parameter.

    Values:

    enumerator `I2C_DUTYCYCLE_33`

      Clock duty cycle is 33%.

    enumerator `I2C_DUTYCYCLE_50`

      Clock duty cycle is 55%.

  Functions

  void `I2C_enableModule`(uint32_t base)

    Enables the I2C module.

    This function enables operation of the I2C module.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_disableModule`(uint32_t base)

    Disables the I2C module.

    This function disables operation of the I2C module.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_enableFIFO`(uint32_t base)

    Enables the transmit and receive FIFOs.

    This functions enables the transmit and receive FIFOs in the I2C.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_disableFIFO`(uint32_t base)

    Disables the transmit and receive FIFOs.

    This functions disables the transmit and receive FIFOs in the I2C.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_setFIFOInterruptLevel`(uint32_t base, I2C_TxFIFOLevel txLevel, I2C_RxFIFOLevel rxLevel)

    Sets the FIFO level at which interrupts are generated.

    This function sets the FIFO level at which transmit and receive interrupts are generated. The transmit FIFO interrupt flag will be set when the FIFO reaches a value less than or equal to

    txLevel. The receive FIFO flag will be set when the FIFO reaches a value greater than or equal to rxLevel.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `txLevel`: is the transmit FIFO interrupt level, specified as I2C_FIFO_TX0, I2C_FIFO_TX1, I2C_FIFO_TX2, … or I2C_FIFO_TX16.

      - `rxLevel`: is the receive FIFO interrupt level, specified as I2C_FIFO_RX0, I2C_FIFO_RX1, I2C_FIFO_RX2, … or I2C_FIFO_RX16.

    Return

      None.

  void `I2C_getFIFOInterruptLevel`(uint32_t base, I2C_TxFIFOLevel *txLevel, I2C_RxFIFOLevel *rxLevel)

    Gets the FIFO level at which interrupts are generated.

    This function gets the FIFO level at which transmit and receive interrupts are generated. The transmit FIFO interrupt flag will be set when the FIFO reaches a value less than or equal to

    txLevel. The receive FIFO flag will be set when the FIFO reaches a value greater than or equal to rxLevel.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `txLevel`: is a pointer to storage for the transmit FIFO level, returned as one of I2C_FIFO_TX0, I2C_FIFO_TX1, I2C_FIFO_TX2, … or I2C_FIFO_TX16.

      - `rxLevel`: is a pointer to storage for the receive FIFO level, returned as one of I2C_FIFO_RX0, I2C_FIFO_RX1, I2C_FIFO_RX2, … or I2C_FIFO_RX16.

    Return

      None.

  I2C_TxFIFOLevel `I2C_getTxFIFOStatus`(uint32_t base)

    Get the transmit FIFO status

    This function gets the current number of words in the transmit FIFO.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns the current number of words in the transmit FIFO specified as one of the following: I2C_FIFO_TX0, I2C_FIFO_TX1, I2C_FIFO_TX2, I2C_FIFO_TX3, …, or I2C_FIFO_TX16

  I2C_RxFIFOLevel `I2C_getRxFIFOStatus`(uint32_t base)

    Get the receive FIFO status

    This function gets the current number of words in the receive FIFO.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns the current number of words in the receive FIFO specified as one of the following: I2C_FIFO_RX0, I2C_FIFO_RX1, I2C_FIFO_RX2, I2C_FIFO_RX3, …, or I2C_FIFO_RX16

  uint16_t `I2C_getPreScaler`(uint32_t base)

    Reads I2C Module clock prescaler value.

    This function reads the I2C prescaler value which configures the I2C module clock by dividing down the SYSCLK. I2C_MODULE_CLK = SYSCLK / (I2CPSC + )

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns the I2C prescaler(I2CPSC) cast as an uint16_t.

  void `I2C_setTargetAddress`(uint32_t base, uint16_t targetAddr)

    Sets the address that the I2C Controller places on the bus.

    This function configures the address that the I2C Controller places on the bus when initiating a transaction.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `targetAddr`: 7-bit or 10-bit target address

    Return

      None.

  void `I2C_setOwnAddress`(uint32_t base, uint16_t Addr)

    Sets the own address for this I2C module.

    This function writes the specified address.

    Parameters

      - `base`: is the base address of the I2C Target module.

      - `Addr`: is the 7-bit or 10-bit address

    The parameter Addr is the value that is compared against the target address sent by an I2C controller.

    Return

      None.

  bool `I2C_isBusBusy`(uint32_t base)

    Indicates whether or not the I2C bus is busy.

    This function returns an indication of whether or not the I2C bus is busy. This function can be used in a multi-controller environment to determine if the bus is free for another data transfer.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns true if the I2C bus is busy; otherwise, returns false.

  uint16_t `I2C_getStatus`(uint32_t base)

    Gets the current I2C module status.

    This function returns the status for the I2C module.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      The current module status, enumerated as a bit field of

      - I2C_STS_ARB_LOST - Arbitration-lost

      - I2C_STS_NO_ACK - No-acknowledgment (NACK)

      - I2C_STS_REG_ACCESS_RDY - Register-access-ready (ARDY)

      - I2C_STS_RX_DATA_RDY - Receive-data-ready

      - I2C_STS_TX_DATA_RDY - Transmit-data-ready

      - I2C_STS_STOP_CONDITION - Stop condition detected

      - I2C_STS_BYTE_SENT - Byte transmit complete

      - I2C_STS_ADDR_ZERO - Address of all zeros detected

      - I2C_STS_ADDR_TARGET - Addressed as Target

      - I2C_STS_TX_EMPTY - Transmit shift register empty

      - I2C_STS_RX_FULL - Receive shift register full

      - I2C_STS_BUS_BUSY - Bus busy, wait for STOP or reset

      - I2C_STS_NACK_SENT - NACK was sent

      - I2C_STS_TARGET_DIR- Addressed as Target transmitter

  void `I2C_clearStatus`(uint32_t base, uint16_t stsFlags)

    Clears I2C status flags.

    This function clears the specified I2C status flags. The

    stsFlags parameter is the logical OR of the following values:

    - I2C_STS_ARB_LOST

    - I2C_STS_NO_ACK,

    - I2C_STS_REG_ACCESS_RDY

    - I2C_STS_RX_DATA_RDY

    - I2C_STS_STOP_CONDITION

    - I2C_STS_BYTE_SENT

    - I2C_STS_NACK_SENT

    - I2C_STS_TARGET_DIR

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `stsFlags`: is a bit mask of the status flags to be cleared.

    Note

      Note that some of the status flags returned by I2C_getStatus() cannot be cleared by this function. Some may only be cleared by hardware or a reset of the I2C module.

    Return

      None.

  void `I2C_setConfig`(uint32_t base, uint16_t config)

    Controls the state of the I2C module.

    This function is used to control the state of the controller and target send and receive operations. The

    config is a logical OR of the following options.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `config`: is the command to be issued to the I2C module.

    One of the following four options:

    - I2C_CONTROLLER_SEND_MODE - Controller-transmitter mode

    - I2C_CONTROLLER_RECEIVE_MODE - Controller-receiver mode

    - I2C_TARGET_SEND_MODE - Target-transmitter mode

    - I2C_TARGET_RECEIVE_MODE - Target-receiver mode

    Any of the following:

    - I2C_REPEAT_MODE - Sends data until stop bit is set, ignores data count

    - I2C_START_BYTE_MODE - Use start byte mode

    - I2C_FREE_DATA_FORMAT - Use free data format, transfers have no address

    Return

      None.

  void `I2C_setBitCount`(uint32_t base, I2C_BitCount size)

    Sets the data byte bit count the I2C module.

    The

    size parameter is a value I2C_BITCOUNT_x where x is the number of bits per data byte. The default and maximum size is 8 bits.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `size`: is the number of bits per data byte.

    Return

      None.

  void `I2C_sendStartCondition`(uint32_t base)

    Issues an I2C START condition.

    This function causes the I2C module to generate a start condition. This function is only valid when the I2C module specified by the

    base parameter is a controller.
    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_sendStopCondition`(uint32_t base)

    Issues an I2C STOP condition.

    This function causes the I2C module to generate a stop condition. This function is only valid when the I2C module specified by the

    base parameter is a controller.
    Parameters

      - `base`: is the base address of the I2C instance used.

    To check on the status of the STOP condition, I2C_getStopConditionStatus() can be used.

    Return

      None.

  void `I2C_sendNACK`(uint32_t base)

    Issues a no-acknowledge (NACK) bit.

    This function causes the I2C module to generate a NACK bit. This is only applicable when the I2C module is acting as a receiver.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  uint16_t `I2C_getData`(uint32_t base)

    Receives a byte that has been sent to the I2C.

    This function reads a byte of data from the I2C Data Receive Register.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns the byte received from by the I2C cast as an uint16_t.

  void `I2C_putData`(uint32_t base, uint16_t data)

    Transmits a byte from the I2C.

    This function places the supplied data into I2C Data Transmit Register.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `data`: is the data to be transmitted from the I2C Controller.

    Return

      None.

  bool `I2C_getStopConditionStatus`(uint32_t base)

    Get stop condition status.

    This function reads and returns the stop condition bit status.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      Returns true if the STP bit has been set by the device to generate a stop condition when the internal data counter of the I2C module has reached 0. Returns false when the STP bit is zero. This bit is automatically cleared after the stop condition has been generated.

  void `I2C_setDataCount`(uint32_t base, uint16_t count)

    Set number of bytes to be to transfer or receive when repeat mode is off.

    This function sets the number of bytes to transfer or receive when repeat mode is off.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `count`: is the value to be put in the I2C data count register.

    Return

      None.

  void `I2C_setAddressMode`(uint32_t base, I2C_AddressMode mode)

    Sets the addressing mode to either 7-bit or 10-bit.

    This function configures the I2C module for either a 7-bit address (default) or a 10-bit address. The

    mode parameter configures the address length to 10 bits when its value is I2C_ADDR_MODE_10BITS and 7 bits when I2C_ADDR_MODE_7BITS.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `mode`: is the address mode, 7-bit or 10-bit.

    Return

      None.

  void `I2C_setEmulationMode`(uint32_t base, I2C_EmulationMode mode)

    Sets I2C emulation mode.

    This function sets the behavior of the I2C operation when an emulation suspend occurs. The

    mode parameter can be one of the following:
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `mode`: is the emulation mode.

    - I2C_EMULATION_STOP_SCL_LOW - If SCL is low when the breakpoint occurs, the I2C module stops immediately. If SCL is high, the I2C module waits until SCL becomes low and then stops.

    - I2C_EMULATION_FREE_RUN - I2C operation continues regardless of a the suspend.

    Return

      None.

  void `I2C_enableLoopback`(uint32_t base)

    Enables I2C loopback mode.

    This function enables loopback mode. This mode is only valid during controller mode and is helpful during device testing as it causes data transmitted out of the data transmit register to be received in data receive register.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  void `I2C_disableLoopback`(uint32_t base)

    Disables I2C loopback mode.

    This function disables loopback mode. Loopback mode is disabled by default after reset.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      None.

  I2C_InterruptSource `I2C_getInterruptSource`(uint32_t base)

    Returns the current I2C interrupt source.

    This function returns the event that generated an I2C basic (non-FIFO) interrupt. The possible sources are the following:

    - I2C_INTSRC_NONE

    - I2C_INTSRC_ARB_LOST

    - I2C_INTSRC_NO_ACK

    - I2C_INTSRC_REG_ACCESS_RDY

    - I2C_INTSRC_RX_DATA_RDY

    - I2C_INTSRC_TX_DATA_RDY

    - I2C_INTSRC_STOP_CONDITION

    - I2C_INTSRC_ADDR_TARGET

    Parameters

      - `base`: is the base address of the I2C instance used.

    Calling this function will result in hardware automatically clearing the current interrupt code and if ready, loading the next pending enabled interrupt. It will also clear the corresponding interrupt flag if the source is I2C_INTSRC_ARB_LOST, I2C_INTSRC_NO_ACK, or I2C_INTSRC_STOP_CONDITION.

    Note

      Note that this function differs from I2C_getInterruptStatus() in that it returns a single interrupt source. I2C_getInterruptSource() will return the status of all interrupt flags possible, including the flags that aren’t necessarily enabled to generate interrupts.

    Return

      None.

  void `I2C_setExtendedMode`(uint32_t base, I2C_ExtendedMode mode)

    Sets the compatibility mode to support I2C Extended Mode.

    This function configures the I2C module for either a Forward or Backward compatibilty. The

    mode parameter configures the compatibility to Forward when its value is I2C_EADDR_MODE_FWD and Backward when I2C_EADDR_MODE_BC.
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `mode`: is the compatibility modes.

    Return

      None.

  void `I2C_initController`(uint32_t base, uint32_t sysclkHz, uint32_t bitRate, I2C_DutyCycle dutyCycle)

    Initializes the I2C Controller.

    This function initializes operation of the I2C Controller by configuring the bus speed for the controller. Note that the I2C module

    must be put into reset before calling this function. You can do this with the function I2C_disableModule().
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `sysclkHz`: is the rate of the clock supplied to the I2C module (SYSCLK) in Hz.

      - `bitRate`: is the rate of the controller clock signal, SCL.

      - `dutyCycle`: is duty cycle of the SCL signal.

    A programmable prescaler in the I2C module divides down the input clock (rate specified by sysclkHz) to produce the module clock (calculated to be around 10 MHz in this function). That clock is then divided down further to configure the SCL signal to run at the rate specified by bitRate. The dutyCycle parameter determines the percentage of time high and time low on the clock signal. The valid values are I2C_DUTYCYCLE_33 for 33% and I2C_DUTYCYCLE_50 for 50%.

    The peripheral clock is the system clock. This value is returned by SysCtl_getClock(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtl_getClock()).

    Return

      None.

  void `I2C_initControllerModuleFrequency`(uint32_t base, uint32_t sysclkHz, uint32_t bitRate, I2C_DutyCycle dutyCycle, uint32_t moduleFrequency)

    Initializes the I2C Controller.

    This function initializes operation of the I2C Controller by configuring the bus speed for the controller. Note that the I2C module

    must be put into reset before calling this function. You can do this with the function I2C_disableModule().
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `sysclkHz`: is the rate of the clock supplied to the I2C module (SYSCLK) in Hz.

      - `bitRate`: is the rate of the controller clock signal, SCL.

      - `dutyCycle`: is duty cycle of the SCL signal.

      - `moduleFrequency`: is the module clock used by I2C module

    A programmable prescaler in the I2C module divides down the input clock (rate specified by sysclkHz) to produce the module clock (calculated to be around 10 MHz in this function). That clock is then divided down further to configure the SCL signal to run at the rate specified by bitRate. The dutyCycle parameter determines the percentage of time high and time low on the clock signal. The valid values are I2C_DUTYCYCLE_33 for 33% and I2C_DUTYCYCLE_50 for 50%.

    The peripheral clock is the system clock. This value is returned by SysCtl_getClock(), or it can be explicitly hard coded if it is constant and known (to save the code/execution overhead of a call to SysCtl_getClock()).

    Return

      None.

  void `I2C_enableInterrupt`(uint32_t base, uint32_t intFlags)

    Enables I2C interrupt sources.

    This function enables the indicated I2C Controller interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `intFlags`: is the bit mask of the interrupt sources to be enabled.

    The intFlags parameter is the logical OR of any of the following:

    - I2C_INT_ARB_LOST - Arbitration-lost interrupt

    - I2C_INT_NO_ACK - No-acknowledgment (NACK) interrupt

    - I2C_INT_REG_ACCESS_RDY - Register-access-ready interrupt

    - I2C_INT_RX_DATA_RDY - Receive-data-ready interrupt

    - I2C_INT_TX_DATA_RDY - Transmit-data-ready interrupt

    - I2C_INT_STOP_CONDITION - Stop condition detected

    - I2C_INT_ADDR_TARGET - Addressed as target interrupt

    - I2C_INT_RXFF - RX FIFO level interrupt

    - I2C_INT_TXFF - TX FIFO level interrupt

    Note

      I2C_INT_RXFF and I2C_INT_TXFF are associated with the I2C FIFO interrupt vector. All others are associated with the I2C basic interrupt.

    Return

      None.

  void `I2C_disableInterrupt`(uint32_t base, uint32_t intFlags)

    Disables I2C interrupt sources.

    This function disables the indicated I2C Target interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt. Disabled sources have no effect on the processor.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `intFlags`: is the bit mask of the interrupt sources to be disabled.

    The intFlags parameter has the same definition as the intFlags parameter to I2C_enableInterrupt().

    Return

      None.

  uint32_t `I2C_getInterruptStatus`(uint32_t base)

    Gets the current I2C interrupt status.

    This function returns the interrupt status for the I2C module.

    Parameters

      - `base`: is the base address of the I2C instance used.

    Return

      The current interrupt status, enumerated as a bit field of

      - I2C_INT_ARB_LOST

      - I2C_INT_NO_ACK

      - I2C_INT_REG_ACCESS_RDY

      - I2C_INT_RX_DATA_RDY

      - I2C_INT_TX_DATA_RDY

      - I2C_INT_STOP_CONDITION

      - I2C_INT_ADDR_TARGET

      - I2C_INT_RXFF

      - I2C_INT_TXFF

    Note

      This function will only return the status flags associated with interrupts. However, a flag may be set even if its corresponding interrupt is disabled.

  void `I2C_clearInterruptStatus`(uint32_t base, uint32_t intFlags)

    Clears I2C interrupt sources.

    The specified I2C interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being triggered again immediately upon exit.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `intFlags`: is a bit mask of the interrupt sources to be cleared.

    The intFlags parameter has the same definition as the intFlags parameter to I2C_enableInterrupt().

    Note

      I2C_INT_RXFF and I2C_INT_TXFF are associated with the I2C FIFO interrupt vector. All others are associated with the I2C basic interrupt.

    Note

      Also note that some of the status flags returned by I2C_getInterruptStatus() cannot be cleared by this function. Some may only be cleared by hardware or a reset of the I2C module.

    Return

      None.

  void `I2C_configureModuleFrequency`(uint32_t base, uint32_t sysclkHz)

    Configures I2C Module Clock Frequency

    This function configures I2C module clock frequency by initializing prescale register based on SYSCLK frequency. Note that the I2C module

    must be put into reset before calling this function. You can do this with the function I2C_disableModule().
    Parameters

      - `base`: is the base address of the I2C instance used.

      - `sysclkHz`: is the rate of the clock supplied to the I2C module (SYSCLK) in Hz.

    Return

      None.

  void `I2C_configureModuleClockFrequency`(uint32_t base, uint32_t sysclkHz, uint32_t moduleFrequency)

    Configures I2C Module Clock Frequency with a given module clock

    Return

      None.

    Parameters

      - `base`: is the base address of the I2C instance used.

      - `sysclkHz`: is the rate of the clock supplied to the I2C module (SYSCLK) in Hz.

      - `moduleFrequency`: is the rate of the module clock used by I2C module This function configures I2C module clock frequency by initializing prescale register based on SYSCLK frequency. Note that the I2C module must be put into reset before calling this function. You can do this with the function I2C_disableModule().

Before initializing the I2C module, the user first must put the module into the reset state by calling I2C_disableModule(). When using the API in master mode, the user must then call I2C_initMaster() which will configure the rate and duty cycle of the master clock. For slave mode, I2C_setOwnSlaveAddress() will need to be called to set the module’s address.

For both modes, this is also the time to do any FIFO or interrupt configuration. FIFOs are configured using I2C_enableFIFO() and I2C_disableFIFO() and I2C_setFIFOInterruptLevel() if interrupts are desired. The functions I2C_enableInterrupt(), I2C_disableInterrupt(), I2C_clearInterruptStatus(), and I2C_getInterruptStatus() are for management of interrupts. Note that the I2C module uses separate interrupt lines for its basic and FIFO interrupts although the functions to configure them are the same.

When configuration is complete, I2C_enableModule() should be called to enable the operation of the module.

To do a transfer, for both master and slave modes, I2C_setConfig() should be called to configure the behavior of the module. A master will need to set I2C_setSlaveAddress() to set the address of the slave to which it will communicate. I2C_putData() will place data in the transmit buffer. A start condition can be sent by a master using I2C_sendStartCondition().

When receiving data, the status of data received can be checked using I2C_getStatus() or if in FIFO mode, I2C_getRxFIFOStatus(). I2C_getData() will read the data from the receive buffer and return it.

The code for this module is contained in driverlib/i2c.c, with driverlib/i2c.h containing the API declarations for use by applications.