I2C API I2C Set-up

Before calling any setup functions in the I2C ROM, the application program is responsible for doing the following:

  1. Enable the clock to the I2C peripheral.
  2. Enable the two pins required for the SCL and SDA outputs of the I2C peripheral.
  3. Allocate a RAM area for dedicated use of the I2C ROM Driver.

After the I2C block is configured, the I2C ROM driver variables have to be set up:

  1. Initialize pointer to the I2C API function table.
  2. Declare the PARAM and RESULT struct.
  3. Declare Error Code struct.
  4. Declare the transmit and receive buffer.

If interrupts are used, then additional driver variables have to be set up:

  1. Declare the I2C_CALLBK_T type.
  2. Declare callback functions.
  3. Declare I2C ROM Driver ISR within the I2C ISR.
  4. Enable I2C interrupt.