17.6.3.2.3 Function i2c_master_init()

Initializes the requested I2C hardware module.

enum status_code i2c_master_init( struct i2c_master_module *const module, Sercom *const hw, const struct i2c_master_config *const config)

Initializes the SERCOM I2C master device requested and sets the provided software module struct. Run this function before any further use of the driver.

Table 17-11. Parameters
Data directionParameter nameDescription

[out]

module

Pointer to software module struct

[in]

hw

Pointer to the hardware instance

[in]

config

Pointer to the configuration struct

Returns

Status of initialization.

Table 17-12. Return Values
Return valueDescription

STATUS_OK

Module initiated correctly

STATUS_ERR_DENIED

If module is enabled

STATUS_BUSY

If module is busy resetting

STATUS_ERR_ALREADY_INITIALIZED

If setting other GCLK generator than previously set

STATUS_ERR_BAUDRATE_UNAVAILABLE

If given baudrate is not compatible with set GCLK frequency