![]() |
MCUXpresso SDK API Reference Manual
Rev 2.12.1
NXP Semiconductors
|
Data Structures | |
| struct | i2c_master_config_t |
| Structure with settings to initialize the I2C master module. More... | |
Enumerations | |
| enum | _i2c_master_flags { kI2C_MasterPendingFlag = I2C_STAT_MSTPENDING_MASK, kI2C_MasterArbitrationLostFlag, kI2C_MasterStartStopErrorFlag } |
| I2C master peripheral flags. More... | |
| enum | i2c_direction_t { kI2C_Write = 0U, kI2C_Read = 1U } |
| Direction of master and slave transfers. More... | |
Initialization and deinitialization | |
| void | I2C_MasterGetDefaultConfig (i2c_master_config_t *masterConfig) |
| Provides a default configuration for the I2C master peripheral. More... | |
| void | I2C_MasterInit (I2C_Type *base, const i2c_master_config_t *masterConfig, uint32_t srcClock_Hz) |
| Initializes the I2C master peripheral. More... | |
| void | I2C_MasterDeinit (I2C_Type *base) |
| Deinitializes the I2C master peripheral. More... | |
| uint32_t | I2C_GetInstance (I2C_Type *base) |
| Returns an instance number given a base address. More... | |
| static void | I2C_MasterReset (I2C_Type *base) |
| Performs a software reset. More... | |
| static void | I2C_MasterEnable (I2C_Type *base, bool enable) |
| Enables or disables the I2C module as master. More... | |
Status | |
| static uint32_t | I2C_GetStatusFlags (I2C_Type *base) |
| Gets the I2C status flags. More... | |
| static void | I2C_MasterClearStatusFlags (I2C_Type *base, uint32_t statusMask) |
| Clears the I2C master status flag state. More... | |
Interrupts | |
| static void | I2C_EnableInterrupts (I2C_Type *base, uint32_t interruptMask) |
| Enables the I2C master interrupt requests. More... | |
| static void | I2C_DisableInterrupts (I2C_Type *base, uint32_t interruptMask) |
| Disables the I2C master interrupt requests. More... | |
| static uint32_t | I2C_GetEnabledInterrupts (I2C_Type *base) |
| Returns the set of currently enabled I2C master interrupt requests. More... | |
Bus operations | |
| void | I2C_MasterSetBaudRate (I2C_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) |
| Sets the I2C bus frequency for master transactions. More... | |
| static bool | I2C_MasterGetBusIdleState (I2C_Type *base) |
| Returns whether the bus is idle. More... | |
| status_t | I2C_MasterStart (I2C_Type *base, uint8_t address, i2c_direction_t direction) |
| Sends a START on the I2C bus. More... | |
| status_t | I2C_MasterStop (I2C_Type *base) |
| Sends a STOP signal on the I2C bus. More... | |
| static status_t | I2C_MasterRepeatedStart (I2C_Type *base, uint8_t address, i2c_direction_t direction) |
| Sends a REPEATED START on the I2C bus. More... | |
| struct i2c_master_config_t |
This structure holds configuration settings for the I2C peripheral. To initialize this structure to reasonable defaults, call the I2C_MasterGetDefaultConfig() function and pass a pointer to your configuration structure instance.
The configuration structure can be made constant so it resides in flash.
Data Fields | |
| bool | enableMaster |
| Whether to enable master mode. More... | |
| uint32_t | baudRate_Bps |
| Desired baud rate in bits per second. More... | |
| bool | enableTimeout |
| Enable internal timeout function. More... | |
| bool i2c_master_config_t::enableMaster |
| uint32_t i2c_master_config_t::baudRate_Bps |
| bool i2c_master_config_t::enableTimeout |
| enum _i2c_master_flags |
| enum i2c_direction_t |
| void I2C_MasterGetDefaultConfig | ( | i2c_master_config_t * | masterConfig | ) |
This function provides the following default configuration for the I2C master peripheral:
After calling this function, you can override any settings in order to customize the configuration, prior to initializing the master driver with I2C_MasterInit().
| [out] | masterConfig | User provided configuration structure for default values. Refer to i2c_master_config_t. |
| void I2C_MasterInit | ( | I2C_Type * | base, |
| const i2c_master_config_t * | masterConfig, | ||
| uint32_t | srcClock_Hz | ||
| ) |
This function enables the peripheral clock and initializes the I2C master peripheral as described by the user provided configuration. A software reset is performed prior to configuration.
| base | The I2C peripheral base address. |
| masterConfig | User provided peripheral configuration. Use I2C_MasterGetDefaultConfig() to get a set of defaults that you can override. |
| srcClock_Hz | Frequency in Hertz of the I2C functional clock. Used to calculate the baud rate divisors, filter widths, and timeout periods. |
| void I2C_MasterDeinit | ( | I2C_Type * | base | ) |
This function disables the I2C master peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.
| base | The I2C peripheral base address. |
| uint32_t I2C_GetInstance | ( | I2C_Type * | base | ) |
If an invalid base address is passed, debug builds will assert. Release builds will just return instance number 0.
| base | The I2C peripheral base address. |
|
inlinestatic |
Restores the I2C master peripheral to reset conditions.
| base | The I2C peripheral base address. |
|
inlinestatic |
| base | The I2C peripheral base address. |
| enable | Pass true to enable or false to disable the specified I2C as master. |
|
inlinestatic |
A bit mask with the state of all I2C status flags is returned. For each flag, the corresponding bit in the return value is set if the flag is asserted.
| base | The I2C peripheral base address. |
|
inlinestatic |
The following status register flags can be cleared:
Attempts to clear other flags has no effect.
| base | The I2C peripheral base address. |
| statusMask | A bitmask of status flags that are to be cleared. The mask is composed of _i2c_master_flags enumerators OR'd together. You may pass the result of a previous call to I2C_GetStatusFlags(). |
|
inlinestatic |
| base | The I2C peripheral base address. |
| interruptMask | Bit mask of interrupts to enable. See _i2c_master_flags for the set of constants that should be OR'd together to form the bit mask. |
|
inlinestatic |
| base | The I2C peripheral base address. |
| interruptMask | Bit mask of interrupts to disable. See _i2c_master_flags for the set of constants that should be OR'd together to form the bit mask. |
|
inlinestatic |
| base | The I2C peripheral base address. |
| void I2C_MasterSetBaudRate | ( | I2C_Type * | base, |
| uint32_t | baudRate_Bps, | ||
| uint32_t | srcClock_Hz | ||
| ) |
The I2C master is automatically disabled and re-enabled as necessary to configure the baud rate. Do not call this function during a transfer, or the transfer is aborted.
| base | The I2C peripheral base address. |
| srcClock_Hz | I2C functional clock frequency in Hertz. |
| baudRate_Bps | Requested bus frequency in bits per second. |
|
inlinestatic |
Requires the master mode to be enabled.
| base | The I2C peripheral base address. |
| true | Bus is busy. |
| false | Bus is idle. |
| status_t I2C_MasterStart | ( | I2C_Type * | base, |
| uint8_t | address, | ||
| i2c_direction_t | direction | ||
| ) |
This function is used to initiate a new master mode transfer by sending the START signal. The slave address is sent following the I2C START signal.
| base | I2C peripheral base pointer |
| address | 7-bit slave device address. |
| direction | Master transfer directions(transmit/receive). |
| kStatus_Success | Successfully send the start signal. |
| kStatus_I2C_Busy | Current bus is busy. |
| status_t I2C_MasterStop | ( | I2C_Type * | base | ) |
| kStatus_Success | Successfully send the stop signal. |
| kStatus_I2C_Timeout | Send stop signal failed, timeout. |
|
inlinestatic |
| base | I2C peripheral base pointer |
| address | 7-bit slave device address. |
| direction | Master transfer directions(transmit/receive). |
| kStatus_Success | Successfully send the start signal. |
| kStatus_I2C_Busy | Current bus is busy but not occupied by current I2C master. |