STM32F4xx HAL Documentation
Hardware Abstraction Layer for STM32F4 familiy
Loading...
Searching...
No Matches
stm32f4xx_hal_i2c.h File Reference

Header file of I2C HAL module. More...

Include dependency graph for stm32f4xx_hal_i2c.h:

Go to the source code of this file.

Data Structures

struct  I2C_InitTypeDef
 
struct  I2C_HandleTypeDef
 

Macros

#define HAL_I2C_ERROR_NONE   0x00000000U
 
#define HAL_I2C_ERROR_BERR   0x00000001U
 
#define HAL_I2C_ERROR_ARLO   0x00000002U
 
#define HAL_I2C_ERROR_AF   0x00000004U
 
#define HAL_I2C_ERROR_OVR   0x00000008U
 
#define HAL_I2C_ERROR_DMA   0x00000010U
 
#define HAL_I2C_ERROR_TIMEOUT   0x00000020U
 
#define HAL_I2C_ERROR_SIZE   0x00000040U
 
#define HAL_I2C_ERROR_DMA_PARAM   0x00000080U
 
#define HAL_I2C_WRONG_START   0x00000200U
 
#define I2C_DUTYCYCLE_2   0x00000000U
 
#define I2C_DUTYCYCLE_16_9   I2C_CCR_DUTY
 
#define I2C_ADDRESSINGMODE_7BIT   0x00004000U
 
#define I2C_ADDRESSINGMODE_10BIT   (I2C_OAR1_ADDMODE | 0x00004000U)
 
#define I2C_DUALADDRESS_DISABLE   0x00000000U
 
#define I2C_DUALADDRESS_ENABLE   I2C_OAR2_ENDUAL
 
#define I2C_GENERALCALL_DISABLE   0x00000000U
 
#define I2C_GENERALCALL_ENABLE   I2C_CR1_ENGC
 
#define I2C_NOSTRETCH_DISABLE   0x00000000U
 
#define I2C_NOSTRETCH_ENABLE   I2C_CR1_NOSTRETCH
 
#define I2C_MEMADD_SIZE_8BIT   0x00000001U
 
#define I2C_MEMADD_SIZE_16BIT   0x00000010U
 
#define I2C_DIRECTION_RECEIVE   0x00000000U
 
#define I2C_DIRECTION_TRANSMIT   0x00000001U
 
#define I2C_FIRST_FRAME   0x00000001U
 
#define I2C_FIRST_AND_NEXT_FRAME   0x00000002U
 
#define I2C_NEXT_FRAME   0x00000004U
 
#define I2C_FIRST_AND_LAST_FRAME   0x00000008U
 
#define I2C_LAST_FRAME_NO_STOP   0x00000010U
 
#define I2C_LAST_FRAME   0x00000020U
 
#define I2C_OTHER_FRAME   (0x00AA0000U)
 
#define I2C_OTHER_AND_LAST_FRAME   (0xAA000000U)
 
#define I2C_IT_BUF   I2C_CR2_ITBUFEN
 
#define I2C_IT_EVT   I2C_CR2_ITEVTEN
 
#define I2C_IT_ERR   I2C_CR2_ITERREN
 
#define I2C_FLAG_OVR   0x00010800U
 
#define I2C_FLAG_AF   0x00010400U
 
#define I2C_FLAG_ARLO   0x00010200U
 
#define I2C_FLAG_BERR   0x00010100U
 
#define I2C_FLAG_TXE   0x00010080U
 
#define I2C_FLAG_RXNE   0x00010040U
 
#define I2C_FLAG_STOPF   0x00010010U
 
#define I2C_FLAG_ADD10   0x00010008U
 
#define I2C_FLAG_BTF   0x00010004U
 
#define I2C_FLAG_ADDR   0x00010002U
 
#define I2C_FLAG_SB   0x00010001U
 
#define I2C_FLAG_DUALF   0x00100080U
 
#define I2C_FLAG_GENCALL   0x00100010U
 
#define I2C_FLAG_TRA   0x00100004U
 
#define I2C_FLAG_BUSY   0x00100002U
 
#define I2C_FLAG_MSL   0x00100001U
 
#define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__)
 Reset I2C handle state.
 
#define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__)
 Enable or disable the specified I2C interrupts.
 
#define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__)
 
#define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)
 Checks if the specified I2C interrupt source is enabled or disabled.
 
#define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__)
 Checks whether the specified I2C flag is set or not.
 
#define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__)
 Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
 
#define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__)
 Clears the I2C ADDR pending flag.
 
#define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__)
 Clears the I2C STOPF pending flag.
 
#define __HAL_I2C_ENABLE(__HANDLE__)
 Enable the specified I2C peripheral.
 
#define __HAL_I2C_DISABLE(__HANDLE__)
 Disable the specified I2C peripheral.
 
#define I2C_FLAG_MASK   0x0000FFFFU
 
#define I2C_MIN_PCLK_FREQ_STANDARD   2000000U
 
#define I2C_MIN_PCLK_FREQ_FAST   4000000U
 
#define I2C_MIN_PCLK_FREQ(__PCLK__, __SPEED__)
 
#define I2C_CCR_CALCULATION(__PCLK__, __SPEED__, __COEFF__)
 
#define I2C_FREQRANGE(__PCLK__)
 
#define I2C_RISE_TIME(__FREQRANGE__, __SPEED__)
 
#define I2C_SPEED_STANDARD(__PCLK__, __SPEED__)
 
#define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__)
 
#define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__)
 
#define I2C_7BIT_ADD_WRITE(__ADDRESS__)
 
#define I2C_7BIT_ADD_READ(__ADDRESS__)
 
#define I2C_10BIT_ADDRESS(__ADDRESS__)
 
#define I2C_10BIT_HEADER_WRITE(__ADDRESS__)
 
#define I2C_10BIT_HEADER_READ(__ADDRESS__)
 
#define I2C_MEM_ADD_MSB(__ADDRESS__)
 
#define I2C_MEM_ADD_LSB(__ADDRESS__)
 
#define IS_I2C_DUTY_CYCLE(CYCLE)
 
#define IS_I2C_ADDRESSING_MODE(ADDRESS)
 
#define IS_I2C_DUAL_ADDRESS(ADDRESS)
 
#define IS_I2C_GENERAL_CALL(CALL)
 
#define IS_I2C_NO_STRETCH(STRETCH)
 
#define IS_I2C_MEMADD_SIZE(SIZE)
 
#define IS_I2C_CLOCK_SPEED(SPEED)
 
#define IS_I2C_OWN_ADDRESS1(ADDRESS1)
 
#define IS_I2C_OWN_ADDRESS2(ADDRESS2)
 
#define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST)
 
#define IS_I2C_TRANSFER_OTHER_OPTIONS_REQUEST(REQUEST)
 
#define I2C_CHECK_FLAG(__ISR__, __FLAG__)
 
#define I2C_CHECK_IT_SOURCE(__CR1__, __IT__)
 

Enumerations

enum  HAL_I2C_StateTypeDef {
  HAL_I2C_STATE_RESET = 0x00U , HAL_I2C_STATE_READY = 0x20U , HAL_I2C_STATE_BUSY = 0x24U , HAL_I2C_STATE_BUSY_TX = 0x21U ,
  HAL_I2C_STATE_BUSY_RX = 0x22U , HAL_I2C_STATE_LISTEN = 0x28U , HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U , HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU ,
  HAL_I2C_STATE_ABORT = 0x60U , HAL_I2C_STATE_TIMEOUT = 0xA0U , HAL_I2C_STATE_ERROR = 0xE0U
}
 
enum  HAL_I2C_ModeTypeDef { HAL_I2C_MODE_NONE = 0x00U , HAL_I2C_MODE_MASTER = 0x10U , HAL_I2C_MODE_SLAVE = 0x20U , HAL_I2C_MODE_MEM = 0x40U }
 

Functions

HAL_StatusTypeDef HAL_I2C_Init (I2C_HandleTypeDef *hi2c)
 Initializes the I2C according to the specified parameters in the I2C_InitTypeDef and initialize the associated handle.
 
HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c)
 DeInitialize the I2C peripheral.
 
void HAL_I2C_MspInit (I2C_HandleTypeDef *hi2c)
 Initialize the I2C MSP.
 
void HAL_I2C_MspDeInit (I2C_HandleTypeDef *hi2c)
 DeInitialize the I2C MSP.
 
HAL_StatusTypeDef HAL_I2C_Master_Transmit (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Transmits in master mode an amount of data in blocking mode.
 
HAL_StatusTypeDef HAL_I2C_Master_Receive (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Receives in master mode an amount of data in blocking mode.
 
HAL_StatusTypeDef HAL_I2C_Slave_Transmit (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Transmits in slave mode an amount of data in blocking mode.
 
HAL_StatusTypeDef HAL_I2C_Slave_Receive (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Receive in slave mode an amount of data in blocking mode.
 
HAL_StatusTypeDef HAL_I2C_Mem_Write (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Write an amount of data in blocking mode to a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_Mem_Read (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
 Read an amount of data in blocking mode from a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_IsDeviceReady (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout)
 Checks if target device is ready for communication.
 
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
 Transmit in master mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
 Receive in master mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
 Transmit in slave mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
 Receive in slave mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
 Write an amount of data in non-blocking mode with Interrupt to a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
 Read an amount of data in non-blocking mode with Interrupt from a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential transmit in master I2C mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential receive in master I2C mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_IT (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential transmit in slave mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_IT (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential receive in slave mode an amount of data in non-blocking mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_EnableListen_IT (I2C_HandleTypeDef *hi2c)
 Enable the Address listen mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_DisableListen_IT (I2C_HandleTypeDef *hi2c)
 Disable the Address listen mode with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress)
 Abort a master or memory I2C IT or DMA process communication with Interrupt.
 
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
 Transmit in master mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
 Receive in master mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
 Transmit in slave mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
 Receive in slave mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
 Write an amount of data in non-blocking mode with DMA to a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
 Reads an amount of data in non-blocking mode with DMA from a specific memory address.
 
HAL_StatusTypeDef HAL_I2C_Master_Seq_Transmit_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential transmit in master I2C mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Master_Seq_Receive_DMA (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential receive in master mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Transmit_DMA (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential transmit in slave mode an amount of data in non-blocking mode with DMA.
 
HAL_StatusTypeDef HAL_I2C_Slave_Seq_Receive_DMA (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
 Sequential receive in slave mode an amount of data in non-blocking mode with DMA.
 
void HAL_I2C_EV_IRQHandler (I2C_HandleTypeDef *hi2c)
 This function handles I2C event interrupt request.
 
void HAL_I2C_ER_IRQHandler (I2C_HandleTypeDef *hi2c)
 This function handles I2C error interrupt request.
 
void HAL_I2C_MasterTxCpltCallback (I2C_HandleTypeDef *hi2c)
 Master Tx Transfer completed callback.
 
void HAL_I2C_MasterRxCpltCallback (I2C_HandleTypeDef *hi2c)
 Master Rx Transfer completed callback.
 
void HAL_I2C_SlaveTxCpltCallback (I2C_HandleTypeDef *hi2c)
 Slave Tx Transfer completed callback.
 
void HAL_I2C_SlaveRxCpltCallback (I2C_HandleTypeDef *hi2c)
 Slave Rx Transfer completed callback.
 
void HAL_I2C_AddrCallback (I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
 Slave Address Match callback.
 
void HAL_I2C_ListenCpltCallback (I2C_HandleTypeDef *hi2c)
 Listen Complete callback.
 
void HAL_I2C_MemTxCpltCallback (I2C_HandleTypeDef *hi2c)
 Memory Tx Transfer completed callback.
 
void HAL_I2C_MemRxCpltCallback (I2C_HandleTypeDef *hi2c)
 Memory Rx Transfer completed callback.
 
void HAL_I2C_ErrorCallback (I2C_HandleTypeDef *hi2c)
 I2C error callback.
 
void HAL_I2C_AbortCpltCallback (I2C_HandleTypeDef *hi2c)
 I2C abort callback.
 
HAL_I2C_StateTypeDef HAL_I2C_GetState (I2C_HandleTypeDef *hi2c)
 Return the I2C handle state.
 
HAL_I2C_ModeTypeDef HAL_I2C_GetMode (I2C_HandleTypeDef *hi2c)
 Returns the I2C Master, Slave, Memory or no mode.
 
uint32_t HAL_I2C_GetError (I2C_HandleTypeDef *hi2c)
 Return the I2C error code.
 

Detailed Description

Header file of I2C HAL module.

Author
MCD Application Team
Attention

Copyright (c) 2016 STMicroelectronics. All rights reserved.

This software is licensed under terms that can be found in the LICENSE file in the root directory of this software component. If no LICENSE file comes with this software, it is provided AS-IS.

Definition in file stm32f4xx_hal_i2c.h.