STM32F103xB HAL User Manual
Data Structures | Defines | Functions
stm32f1xx_ll_i2c.h File Reference

Header file of I2C LL module. More...

#include "stm32f1xx.h"

Go to the source code of this file.

Data Structures

struct  LL_I2C_InitTypeDef

Defines

#define LL_I2C_MAX_SPEED_STANDARD   100000U
#define LL_I2C_MAX_SPEED_FAST   400000U
#define LL_I2C_SR1_SB   I2C_SR1_SB
#define LL_I2C_SR1_ADDR   I2C_SR1_ADDR
#define LL_I2C_SR1_BTF   I2C_SR1_BTF
#define LL_I2C_SR1_ADD10   I2C_SR1_ADD10
#define LL_I2C_SR1_STOPF   I2C_SR1_STOPF
#define LL_I2C_SR1_RXNE   I2C_SR1_RXNE
#define LL_I2C_SR1_TXE   I2C_SR1_TXE
#define LL_I2C_SR1_BERR   I2C_SR1_BERR
#define LL_I2C_SR1_ARLO   I2C_SR1_ARLO
#define LL_I2C_SR1_AF   I2C_SR1_AF
#define LL_I2C_SR1_OVR   I2C_SR1_OVR
#define LL_I2C_SR1_PECERR   I2C_ISR_PECERR
#define LL_I2C_SR1_TIMEOUT   I2C_ISR_TIMEOUT
#define LL_I2C_SR1_SMALERT   I2C_ISR_SMALERT
#define LL_I2C_SR2_MSL   I2C_SR2_MSL
#define LL_I2C_SR2_BUSY   I2C_SR2_BUSY
#define LL_I2C_SR2_TRA   I2C_SR2_TRA
#define LL_I2C_SR2_GENCALL   I2C_SR2_GENCALL
#define LL_I2C_SR2_SMBDEFAULT   I2C_SR2_SMBDEFAULT
#define LL_I2C_SR2_SMBHOST   I2C_SR2_SMBHOST
#define LL_I2C_SR2_DUALF   I2C_SR2_DUALF
#define LL_I2C_CR2_ITEVTEN   I2C_CR2_ITEVTEN
#define LL_I2C_CR2_ITBUFEN   I2C_CR2_ITBUFEN
#define LL_I2C_CR2_ITERREN   I2C_CR2_ITERREN
#define LL_I2C_OWNADDRESS1_7BIT   0x00004000U
#define LL_I2C_OWNADDRESS1_10BIT   (uint32_t)(I2C_OAR1_ADDMODE | 0x00004000U)
#define LL_I2C_DUTYCYCLE_2   0x00000000U
#define LL_I2C_DUTYCYCLE_16_9   I2C_CCR_DUTY
#define LL_I2C_CLOCK_SPEED_STANDARD_MODE   0x00000000U
#define LL_I2C_CLOCK_SPEED_FAST_MODE   I2C_CCR_FS
#define LL_I2C_MODE_I2C   0x00000000U
#define LL_I2C_MODE_SMBUS_HOST   (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP)
#define LL_I2C_MODE_SMBUS_DEVICE   I2C_CR1_SMBUS
#define LL_I2C_MODE_SMBUS_DEVICE_ARP   (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_ENARP)
#define LL_I2C_ACK   I2C_CR1_ACK
#define LL_I2C_NACK   0x00000000U
#define LL_I2C_DIRECTION_WRITE   I2C_SR2_TRA
#define LL_I2C_DIRECTION_READ   0x00000000U
#define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__)   WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 Write a value in I2C register.
#define LL_I2C_ReadReg(__INSTANCE__, __REG__)   READ_REG(__INSTANCE__->__REG__)
 Read a value in I2C register.
#define __LL_I2C_FREQ_HZ_TO_MHZ(__PCLK__)   (uint32_t)((__PCLK__)/1000000U)
 Convert Peripheral Clock Frequency in Mhz.
#define __LL_I2C_FREQ_MHZ_TO_HZ(__PCLK__)   (uint32_t)((__PCLK__)*1000000U)
 Convert Peripheral Clock Frequency in Hz.
#define __LL_I2C_RISE_TIME(__FREQRANGE__, __SPEED__)   (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
 Compute I2C Clock rising time.
#define __LL_I2C_SPEED_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__)
 Compute Speed clock range to a Clock Control Register (I2C_CCR_CCR) value.
#define __LL_I2C_SPEED_STANDARD_TO_CCR(__PCLK__, __SPEED__)   (uint32_t)(((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
 Compute Speed Standard clock range to a Clock Control Register (I2C_CCR_CCR) value.
#define __LL_I2C_SPEED_FAST_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__)
 Compute Speed Fast clock range to a Clock Control Register (I2C_CCR_CCR) value.
#define __LL_I2C_10BIT_ADDRESS(__ADDRESS__)   ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
 Get the Least significant bits of a 10-Bits address.
#define __LL_I2C_10BIT_HEADER_WRITE(__ADDRESS__)   ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF0))))
 Convert a 10-Bits address to a 10-Bits header with Write direction.
#define __LL_I2C_10BIT_HEADER_READ(__ADDRESS__)   ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF1))))
 Convert a 10-Bits address to a 10-Bits header with Read direction.

Functions

__STATIC_INLINE void LL_I2C_Enable (I2C_TypeDef *I2Cx)
 Enable I2C peripheral (PE = 1).
__STATIC_INLINE void LL_I2C_Disable (I2C_TypeDef *I2Cx)
 Disable I2C peripheral (PE = 0).
__STATIC_INLINE uint32_t LL_I2C_IsEnabled (I2C_TypeDef *I2Cx)
 Check if the I2C peripheral is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableDMAReq_TX (I2C_TypeDef *I2Cx)
 Enable DMA transmission requests.
__STATIC_INLINE void LL_I2C_DisableDMAReq_TX (I2C_TypeDef *I2Cx)
 Disable DMA transmission requests.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX (I2C_TypeDef *I2Cx)
 Check if DMA transmission requests are enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableDMAReq_RX (I2C_TypeDef *I2Cx)
 Enable DMA reception requests.
__STATIC_INLINE void LL_I2C_DisableDMAReq_RX (I2C_TypeDef *I2Cx)
 Disable DMA reception requests.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX (I2C_TypeDef *I2Cx)
 Check if DMA reception requests are enabled or disabled.
__STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr (I2C_TypeDef *I2Cx)
 Get the data register address used for DMA transfer.
__STATIC_INLINE void LL_I2C_EnableClockStretching (I2C_TypeDef *I2Cx)
 Enable Clock stretching.
__STATIC_INLINE void LL_I2C_DisableClockStretching (I2C_TypeDef *I2Cx)
 Disable Clock stretching.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledClockStretching (I2C_TypeDef *I2Cx)
 Check if Clock stretching is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableGeneralCall (I2C_TypeDef *I2Cx)
 Enable General Call.
__STATIC_INLINE void LL_I2C_DisableGeneralCall (I2C_TypeDef *I2Cx)
 Disable General Call.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall (I2C_TypeDef *I2Cx)
 Check if General Call is enabled or disabled.
__STATIC_INLINE void LL_I2C_SetOwnAddress1 (I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
 Set the Own Address1.
__STATIC_INLINE void LL_I2C_SetOwnAddress2 (I2C_TypeDef *I2Cx, uint32_t OwnAddress2)
 Set the 7bits Own Address2.
__STATIC_INLINE void LL_I2C_EnableOwnAddress2 (I2C_TypeDef *I2Cx)
 Enable acknowledge on Own Address2 match address.
__STATIC_INLINE void LL_I2C_DisableOwnAddress2 (I2C_TypeDef *I2Cx)
 Disable acknowledge on Own Address2 match address.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress2 (I2C_TypeDef *I2Cx)
 Check if Own Address1 acknowledge is enabled or disabled.
__STATIC_INLINE void LL_I2C_SetPeriphClock (I2C_TypeDef *I2Cx, uint32_t PeriphClock)
 Configure the Peripheral clock frequency.
__STATIC_INLINE uint32_t LL_I2C_GetPeriphClock (I2C_TypeDef *I2Cx)
 Get the Peripheral clock frequency.
__STATIC_INLINE void LL_I2C_SetDutyCycle (I2C_TypeDef *I2Cx, uint32_t DutyCycle)
 Configure the Duty cycle (Fast mode only).
__STATIC_INLINE uint32_t LL_I2C_GetDutyCycle (I2C_TypeDef *I2Cx)
 Get the Duty cycle (Fast mode only).
__STATIC_INLINE void LL_I2C_SetClockSpeedMode (I2C_TypeDef *I2Cx, uint32_t ClockSpeedMode)
 Configure the I2C master clock speed mode.
__STATIC_INLINE uint32_t LL_I2C_GetClockSpeedMode (I2C_TypeDef *I2Cx)
 Get the the I2C master speed mode.
__STATIC_INLINE void LL_I2C_SetRiseTime (I2C_TypeDef *I2Cx, uint32_t RiseTime)
 Configure the SCL, SDA rising time.
__STATIC_INLINE uint32_t LL_I2C_GetRiseTime (I2C_TypeDef *I2Cx)
 Get the SCL, SDA rising time.
__STATIC_INLINE void LL_I2C_SetClockPeriod (I2C_TypeDef *I2Cx, uint32_t ClockPeriod)
 Configure the SCL high and low period.
__STATIC_INLINE uint32_t LL_I2C_GetClockPeriod (I2C_TypeDef *I2Cx)
 Get the SCL high and low period.
__STATIC_INLINE void LL_I2C_ConfigSpeed (I2C_TypeDef *I2Cx, uint32_t PeriphClock, uint32_t ClockSpeed, uint32_t DutyCycle)
 Configure the SCL speed.
__STATIC_INLINE void LL_I2C_SetMode (I2C_TypeDef *I2Cx, uint32_t PeripheralMode)
 Configure peripheral mode.
__STATIC_INLINE uint32_t LL_I2C_GetMode (I2C_TypeDef *I2Cx)
 Get peripheral mode.
__STATIC_INLINE void LL_I2C_EnableSMBusAlert (I2C_TypeDef *I2Cx)
 Enable SMBus alert (Host or Device mode)
__STATIC_INLINE void LL_I2C_DisableSMBusAlert (I2C_TypeDef *I2Cx)
 Disable SMBus alert (Host or Device mode)
__STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusAlert (I2C_TypeDef *I2Cx)
 Check if SMBus alert (Host or Device mode) is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableSMBusPEC (I2C_TypeDef *I2Cx)
 Enable SMBus Packet Error Calculation (PEC).
__STATIC_INLINE void LL_I2C_DisableSMBusPEC (I2C_TypeDef *I2Cx)
 Disable SMBus Packet Error Calculation (PEC).
__STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPEC (I2C_TypeDef *I2Cx)
 Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableIT_TX (I2C_TypeDef *I2Cx)
 Enable TXE interrupt.
__STATIC_INLINE void LL_I2C_DisableIT_TX (I2C_TypeDef *I2Cx)
 Disable TXE interrupt.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX (I2C_TypeDef *I2Cx)
 Check if the TXE Interrupt is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableIT_RX (I2C_TypeDef *I2Cx)
 Enable RXNE interrupt.
__STATIC_INLINE void LL_I2C_DisableIT_RX (I2C_TypeDef *I2Cx)
 Disable RXNE interrupt.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_RX (I2C_TypeDef *I2Cx)
 Check if the RXNE Interrupt is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableIT_EVT (I2C_TypeDef *I2Cx)
 Enable Events interrupts.
__STATIC_INLINE void LL_I2C_DisableIT_EVT (I2C_TypeDef *I2Cx)
 Disable Events interrupts.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_EVT (I2C_TypeDef *I2Cx)
 Check if Events interrupts are enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableIT_BUF (I2C_TypeDef *I2Cx)
 Enable Buffer interrupts.
__STATIC_INLINE void LL_I2C_DisableIT_BUF (I2C_TypeDef *I2Cx)
 Disable Buffer interrupts.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_BUF (I2C_TypeDef *I2Cx)
 Check if Buffer interrupts are enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableIT_ERR (I2C_TypeDef *I2Cx)
 Enable Error interrupts.
__STATIC_INLINE void LL_I2C_DisableIT_ERR (I2C_TypeDef *I2Cx)
 Disable Error interrupts.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR (I2C_TypeDef *I2Cx)
 Check if Error interrupts are enabled or disabled.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE (I2C_TypeDef *I2Cx)
 Indicate the status of Transmit data register empty flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BTF (I2C_TypeDef *I2Cx)
 Indicate the status of Byte Transfer Finished flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE (I2C_TypeDef *I2Cx)
 Indicate the status of Receive data register not empty flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_SB (I2C_TypeDef *I2Cx)
 Indicate the status of Start Bit (master mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADDR (I2C_TypeDef *I2Cx)
 Indicate the status of Address sent (master mode) or Address matched flag (slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADD10 (I2C_TypeDef *I2Cx)
 Indicate the status of 10-bit header sent (master mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_AF (I2C_TypeDef *I2Cx)
 Indicate the status of Acknowledge failure flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP (I2C_TypeDef *I2Cx)
 Indicate the status of Stop detection flag (slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BERR (I2C_TypeDef *I2Cx)
 Indicate the status of Bus error flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ARLO (I2C_TypeDef *I2Cx)
 Indicate the status of Arbitration lost flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_OVR (I2C_TypeDef *I2Cx)
 Indicate the status of Overrun/Underrun flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_PECERR (I2C_TypeDef *I2Cx)
 Indicate the status of SMBus PEC error flag in reception.
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT (I2C_TypeDef *I2Cx)
 Indicate the status of SMBus Timeout detection flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_ALERT (I2C_TypeDef *I2Cx)
 Indicate the status of SMBus alert flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY (I2C_TypeDef *I2Cx)
 Indicate the status of Bus Busy flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_DUAL (I2C_TypeDef *I2Cx)
 Indicate the status of Dual flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_SMBHOST (I2C_TypeDef *I2Cx)
 Indicate the status of SMBus Host address reception (Slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_SMBDEFAULT (I2C_TypeDef *I2Cx)
 Indicate the status of SMBus Device default address reception (Slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_GENCALL (I2C_TypeDef *I2Cx)
 Indicate the status of General call address reception (Slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_MSL (I2C_TypeDef *I2Cx)
 Indicate the status of Master/Slave flag.
__STATIC_INLINE void LL_I2C_ClearFlag_ADDR (I2C_TypeDef *I2Cx)
 Clear Address Matched flag.
__STATIC_INLINE void LL_I2C_ClearFlag_AF (I2C_TypeDef *I2Cx)
 Clear Acknowledge failure flag.
__STATIC_INLINE void LL_I2C_ClearFlag_STOP (I2C_TypeDef *I2Cx)
 Clear Stop detection flag.
__STATIC_INLINE void LL_I2C_ClearFlag_BERR (I2C_TypeDef *I2Cx)
 Clear Bus error flag.
__STATIC_INLINE void LL_I2C_ClearFlag_ARLO (I2C_TypeDef *I2Cx)
 Clear Arbitration lost flag.
__STATIC_INLINE void LL_I2C_ClearFlag_OVR (I2C_TypeDef *I2Cx)
 Clear Overrun/Underrun flag.
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR (I2C_TypeDef *I2Cx)
 Clear SMBus PEC error flag.
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_TIMEOUT (I2C_TypeDef *I2Cx)
 Clear SMBus Timeout detection flag.
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_ALERT (I2C_TypeDef *I2Cx)
 Clear SMBus Alert flag.
__STATIC_INLINE void LL_I2C_EnableReset (I2C_TypeDef *I2Cx)
 Enable Reset of I2C peripheral.
__STATIC_INLINE void LL_I2C_DisableReset (I2C_TypeDef *I2Cx)
 Disable Reset of I2C peripheral.
__STATIC_INLINE uint32_t LL_I2C_IsResetEnabled (I2C_TypeDef *I2Cx)
 Check if the I2C peripheral is under reset state or not.
__STATIC_INLINE void LL_I2C_AcknowledgeNextData (I2C_TypeDef *I2Cx, uint32_t TypeAcknowledge)
 Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
__STATIC_INLINE void LL_I2C_GenerateStartCondition (I2C_TypeDef *I2Cx)
 Generate a START or RESTART condition.
__STATIC_INLINE void LL_I2C_GenerateStopCondition (I2C_TypeDef *I2Cx)
 Generate a STOP condition after the current byte transfer (master mode).
__STATIC_INLINE void LL_I2C_EnableBitPOS (I2C_TypeDef *I2Cx)
 Enable bit POS (master/host mode).
__STATIC_INLINE void LL_I2C_DisableBitPOS (I2C_TypeDef *I2Cx)
 Disable bit POS (master/host mode).
__STATIC_INLINE uint32_t LL_I2C_IsEnabledBitPOS (I2C_TypeDef *I2Cx)
 Check if bit POS is enabled or disabled.
__STATIC_INLINE uint32_t LL_I2C_GetTransferDirection (I2C_TypeDef *I2Cx)
 Indicate the value of transfer direction.
__STATIC_INLINE void LL_I2C_EnableLastDMA (I2C_TypeDef *I2Cx)
 Enable DMA last transfer.
__STATIC_INLINE void LL_I2C_DisableLastDMA (I2C_TypeDef *I2Cx)
 Disable DMA last transfer.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledLastDMA (I2C_TypeDef *I2Cx)
 Check if DMA last transfer is enabled or disabled.
__STATIC_INLINE void LL_I2C_EnableSMBusPECCompare (I2C_TypeDef *I2Cx)
 Enable transfer or internal comparison of the SMBus Packet Error byte (transmission or reception mode).
__STATIC_INLINE void LL_I2C_DisableSMBusPECCompare (I2C_TypeDef *I2Cx)
 Disable transfer or internal comparison of the SMBus Packet Error byte (transmission or reception mode).
__STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPECCompare (I2C_TypeDef *I2Cx)
 Check if the SMBus Packet Error byte transfer or internal comparison is requested or not.
__STATIC_INLINE uint32_t LL_I2C_GetSMBusPEC (I2C_TypeDef *I2Cx)
 Get the SMBus Packet Error byte calculated.
__STATIC_INLINE uint8_t LL_I2C_ReceiveData8 (I2C_TypeDef *I2Cx)
 Read Receive Data register.
__STATIC_INLINE void LL_I2C_TransmitData8 (I2C_TypeDef *I2Cx, uint8_t Data)
 Write in Transmit Data Register .
uint32_t LL_I2C_Init (I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
 Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
uint32_t LL_I2C_DeInit (I2C_TypeDef *I2Cx)
 De-initialize the I2C registers to their default reset values.
void LL_I2C_StructInit (LL_I2C_InitTypeDef *I2C_InitStruct)
 Set each LL_I2C_InitTypeDef field to default value.

Detailed Description

Header file of I2C LL module.

Author:
MCD Application Team
Attention:

© Copyright (c) 2016 STMicroelectronics. All rights reserved.

This software component is licensed by ST under BSD 3-Clause license, the "License"; You may not use this file except in compliance with the License. You may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause

Definition in file stm32f1xx_ll_i2c.h.