Initialize the driver

Informative

How to bring the I2C driver up and down. Binding rules: CHI-I2C-MUST-09 and CHI-I2C-MUST-10 in I2c — Requirements; signatures in API Reference.

Prerequisites

Before I2c_Init, another module must have configured the channel’s input clock, port pins, and interrupt controller. The I2C driver assumes these are ready (see Overview).

Bring the driver up

I2c_Init(NULL_PTR);          /* driver: UNINIT -> INIT; every channel -> IDLE */

configPtr must be NULL_PTR — the configuration variant is selected at build time, not passed at runtime. After I2c_Init returns, the driver is in I2C_DRV_STATE_INIT and each channel is in I2C_CH_STATE_IDLE. A target channel begins accepting its configured address. Interrupts are enabled only for channels configured as Interrupt.

Shut down

I2c_DeInit();                /* aborts any ongoing transaction; driver -> UNINIT */

Poll the current state of a channel with I2c_GetChannelState if you need to observe it.

See also

Controller transactions and Target transactions — running transactions once a channel is initialized.