STM32F439xx HAL User Manual
|
I2C HAL module driver. This file provides firmware functions to manage the following functionalities of the Inter Integrated Circuit (I2C) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral State, Mode and Error functions. More...
#include "stm32f4xx_hal.h"
Go to the source code of this file.
Defines | |
#define | I2C_TIMEOUT_FLAG 35U |
#define | I2C_TIMEOUT_BUSY_FLAG 25U |
#define | I2C_NO_OPTION_FRAME 0xFFFF0000U |
#define | I2C_STATE_MSK ((uint32_t)((HAL_I2C_STATE_BUSY_TX | HAL_I2C_STATE_BUSY_RX) & (~(uint32_t)HAL_I2C_STATE_READY))) |
#define | I2C_STATE_NONE ((uint32_t)(HAL_I2C_MODE_NONE)) |
#define | I2C_STATE_MASTER_BUSY_TX ((uint32_t)((HAL_I2C_STATE_BUSY_TX & I2C_STATE_MSK) | HAL_I2C_MODE_MASTER)) |
#define | I2C_STATE_MASTER_BUSY_RX ((uint32_t)((HAL_I2C_STATE_BUSY_RX & I2C_STATE_MSK) | HAL_I2C_MODE_MASTER)) |
#define | I2C_STATE_SLAVE_BUSY_TX ((uint32_t)((HAL_I2C_STATE_BUSY_TX & I2C_STATE_MSK) | HAL_I2C_MODE_SLAVE)) |
#define | I2C_STATE_SLAVE_BUSY_RX ((uint32_t)((HAL_I2C_STATE_BUSY_RX & I2C_STATE_MSK) | HAL_I2C_MODE_SLAVE)) |
Functions | |
static void | I2C_DMAXferCplt (DMA_HandleTypeDef *hdma) |
DMA I2C process complete callback. | |
static void | I2C_DMAError (DMA_HandleTypeDef *hdma) |
DMA I2C communication error callback. | |
static void | I2C_DMAAbort (DMA_HandleTypeDef *hdma) |
DMA I2C communication abort callback (To be called at end of DMA Abort procedure). | |
static void | I2C_ITError (I2C_HandleTypeDef *hi2c) |
I2C interrupts error process. | |
static HAL_StatusTypeDef | I2C_MasterRequestWrite (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Timeout, uint32_t Tickstart) |
static HAL_StatusTypeDef | I2C_MasterRequestRead (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Timeout, uint32_t Tickstart) |
Master sends target device address for read request. | |
static HAL_StatusTypeDef | I2C_RequestMemoryWrite (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout, uint32_t Tickstart) |
Master sends target device address followed by internal memory address for write request. | |
static HAL_StatusTypeDef | I2C_RequestMemoryRead (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint32_t Timeout, uint32_t Tickstart) |
Master sends target device address followed by internal memory address for read request. | |
static HAL_StatusTypeDef | I2C_WaitOnFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Flag, FlagStatus Status, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout. | |
static HAL_StatusTypeDef | I2C_WaitOnMasterAddressFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Flag, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout for Master addressing phase. | |
static HAL_StatusTypeDef | I2C_WaitOnTXEFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout for specific usage of TXE flag. | |
static HAL_StatusTypeDef | I2C_WaitOnBTFFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout for specific usage of BTF flag. | |
static HAL_StatusTypeDef | I2C_WaitOnRXNEFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout for specific usage of RXNE flag. | |
static HAL_StatusTypeDef | I2C_WaitOnSTOPFlagUntilTimeout (I2C_HandleTypeDef *hi2c, uint32_t Timeout, uint32_t Tickstart) |
This function handles I2C Communication Timeout for specific usage of STOP flag. | |
static HAL_StatusTypeDef | I2C_IsAcknowledgeFailed (I2C_HandleTypeDef *hi2c) |
This function handles Acknowledge failed detection during an I2C Communication. | |
static HAL_StatusTypeDef | I2C_MasterTransmit_TXE (I2C_HandleTypeDef *hi2c) |
Handle TXE flag for Master. | |
static HAL_StatusTypeDef | I2C_MasterTransmit_BTF (I2C_HandleTypeDef *hi2c) |
Handle BTF flag for Master transmitter. | |
static HAL_StatusTypeDef | I2C_MasterReceive_RXNE (I2C_HandleTypeDef *hi2c) |
Handle RXNE flag for Master. | |
static HAL_StatusTypeDef | I2C_MasterReceive_BTF (I2C_HandleTypeDef *hi2c) |
Handle BTF flag for Master receiver. | |
static HAL_StatusTypeDef | I2C_Master_SB (I2C_HandleTypeDef *hi2c) |
Handle SB flag for Master. | |
static HAL_StatusTypeDef | I2C_Master_ADD10 (I2C_HandleTypeDef *hi2c) |
Handle ADD10 flag for Master. | |
static HAL_StatusTypeDef | I2C_Master_ADDR (I2C_HandleTypeDef *hi2c) |
Handle ADDR flag for Master. | |
static HAL_StatusTypeDef | I2C_SlaveTransmit_TXE (I2C_HandleTypeDef *hi2c) |
Handle TXE flag for Slave. | |
static HAL_StatusTypeDef | I2C_SlaveTransmit_BTF (I2C_HandleTypeDef *hi2c) |
Handle BTF flag for Slave transmitter. | |
static HAL_StatusTypeDef | I2C_SlaveReceive_RXNE (I2C_HandleTypeDef *hi2c) |
Handle RXNE flag for Slave. | |
static HAL_StatusTypeDef | I2C_SlaveReceive_BTF (I2C_HandleTypeDef *hi2c) |
Handle BTF flag for Slave receiver. | |
static HAL_StatusTypeDef | I2C_Slave_ADDR (I2C_HandleTypeDef *hi2c) |
Handle ADD flag for Slave. | |
static HAL_StatusTypeDef | I2C_Slave_STOPF (I2C_HandleTypeDef *hi2c) |
Handle STOPF flag for Slave. | |
static HAL_StatusTypeDef | I2C_Slave_AF (I2C_HandleTypeDef *hi2c) |
HAL_StatusTypeDef | HAL_I2C_Init (I2C_HandleTypeDef *hi2c) |
Initializes the I2C according to the specified parameters in the I2C_InitTypeDef and create the associated handle. | |
HAL_StatusTypeDef | HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c) |
DeInitializes the I2C peripheral. | |
__weak void | HAL_I2C_MspInit (I2C_HandleTypeDef *hi2c) |
I2C MSP Init. | |
__weak void | HAL_I2C_MspDeInit (I2C_HandleTypeDef *hi2c) |
I2C MSP DeInit. | |
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_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_Master_Sequential_Transmit_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions) |
Sequential transmit in master mode an amount of data in non-blocking mode with Interrupt. | |
HAL_StatusTypeDef | HAL_I2C_Master_Sequential_Receive_IT (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 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_Slave_Sequential_Transmit_IT (I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions) |
Sequential transmit in slave mode an amount of data in no-blocking mode with Interrupt. | |
HAL_StatusTypeDef | HAL_I2C_Slave_Sequential_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_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_Master_Abort_IT (I2C_HandleTypeDef *hi2c, uint16_t DevAddress) |
Abort a master I2C process communication with Interrupt. | |
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 (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_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_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_IsDeviceReady (I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout) |
Checks if target device is ready for communication. | |
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. | |
__weak void | HAL_I2C_MasterTxCpltCallback (I2C_HandleTypeDef *hi2c) |
Master Tx Transfer completed callback. | |
__weak void | HAL_I2C_MasterRxCpltCallback (I2C_HandleTypeDef *hi2c) |
Master Rx Transfer completed callback. | |
__weak void | HAL_I2C_SlaveTxCpltCallback (I2C_HandleTypeDef *hi2c) |
Slave Tx Transfer completed callback. | |
__weak void | HAL_I2C_SlaveRxCpltCallback (I2C_HandleTypeDef *hi2c) |
Slave Rx Transfer completed callback. | |
__weak void | HAL_I2C_AddrCallback (I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode) |
Slave Address Match callback. | |
__weak void | HAL_I2C_ListenCpltCallback (I2C_HandleTypeDef *hi2c) |
Listen Complete callback. | |
__weak void | HAL_I2C_MemTxCpltCallback (I2C_HandleTypeDef *hi2c) |
Memory Tx Transfer completed callback. | |
__weak void | HAL_I2C_MemRxCpltCallback (I2C_HandleTypeDef *hi2c) |
Memory Rx Transfer completed callback. | |
__weak void | HAL_I2C_ErrorCallback (I2C_HandleTypeDef *hi2c) |
I2C error callback. | |
__weak 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) |
Return the I2C Master, Slave, Memory or no mode. | |
uint32_t | HAL_I2C_GetError (I2C_HandleTypeDef *hi2c) |
Return the I2C error code. |
I2C HAL module driver. This file provides firmware functions to manage the following functionalities of the Inter Integrated Circuit (I2C) peripheral: + Initialization and de-initialization functions + IO operation functions + Peripheral State, Mode and Error functions.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file stm32f4xx_hal_i2c.c.