2 ******************************************************************************
3 * @file stm32h7xx_ll_i2c.h
4 * @author MCD Application Team
5 * @brief Header file of I2C LL module.
6 ******************************************************************************
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
12 * This software component is licensed by ST under BSD 3-Clause license,
13 * the "License"; You may not use this file except in compliance with the
14 * License. You may obtain a copy of the License at:
15 * opensource.org/licenses/BSD-3-Clause
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32H7xx_LL_I2C_H
22 #define STM32H7xx_LL_I2C_H
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32h7xx.h"
31 /** @addtogroup STM32H7xx_LL_Driver
35 #if defined (I2C1) || defined (I2C2) || defined (I2C3) || defined (I2C4) || defined (I2C5)
37 /** @defgroup I2C_LL I2C
41 /* Private types -------------------------------------------------------------*/
42 /* Private variables ---------------------------------------------------------*/
44 /* Private constants ---------------------------------------------------------*/
45 /** @defgroup I2C_LL_Private_Constants I2C Private Constants
52 /* Private macros ------------------------------------------------------------*/
53 #if defined(USE_FULL_LL_DRIVER)
54 /** @defgroup I2C_LL_Private_Macros I2C Private Macros
60 #endif /*USE_FULL_LL_DRIVER*/
62 /* Exported types ------------------------------------------------------------*/
63 #if defined(USE_FULL_LL_DRIVER)
64 /** @defgroup I2C_LL_ES_INIT I2C Exported Init structure
69 uint32_t PeripheralMode
; /*!< Specifies the peripheral mode.
70 This parameter can be a value of @ref I2C_LL_EC_PERIPHERAL_MODE.
72 This feature can be modified afterwards using unitary function @ref LL_I2C_SetMode(). */
74 uint32_t Timing
; /*!< Specifies the SDA setup, hold time and the SCL high, low period values.
75 This parameter must be set by referring to the STM32CubeMX Tool and
76 the helper macro @ref __LL_I2C_CONVERT_TIMINGS().
78 This feature can be modified afterwards using unitary function @ref LL_I2C_SetTiming(). */
80 uint32_t AnalogFilter
; /*!< Enables or disables analog noise filter.
81 This parameter can be a value of @ref I2C_LL_EC_ANALOGFILTER_SELECTION.
83 This feature can be modified afterwards using unitary functions @ref LL_I2C_EnableAnalogFilter() or LL_I2C_DisableAnalogFilter(). */
85 uint32_t DigitalFilter
; /*!< Configures the digital noise filter.
86 This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x0F.
88 This feature can be modified afterwards using unitary function @ref LL_I2C_SetDigitalFilter(). */
90 uint32_t OwnAddress1
; /*!< Specifies the device own address 1.
91 This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF.
93 This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
95 uint32_t TypeAcknowledge
; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
96 This parameter can be a value of @ref I2C_LL_EC_I2C_ACKNOWLEDGE.
98 This feature can be modified afterwards using unitary function @ref LL_I2C_AcknowledgeNextData(). */
100 uint32_t OwnAddrSize
; /*!< Specifies the device own address 1 size (7-bit or 10-bit).
101 This parameter can be a value of @ref I2C_LL_EC_OWNADDRESS1.
103 This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
104 } LL_I2C_InitTypeDef
;
108 #endif /*USE_FULL_LL_DRIVER*/
110 /* Exported constants --------------------------------------------------------*/
111 /** @defgroup I2C_LL_Exported_Constants I2C Exported Constants
115 /** @defgroup I2C_LL_EC_CLEAR_FLAG Clear Flags Defines
116 * @brief Flags defines which can be used with LL_I2C_WriteReg function
119 #define LL_I2C_ICR_ADDRCF I2C_ICR_ADDRCF /*!< Address Matched flag */
120 #define LL_I2C_ICR_NACKCF I2C_ICR_NACKCF /*!< Not Acknowledge flag */
121 #define LL_I2C_ICR_STOPCF I2C_ICR_STOPCF /*!< Stop detection flag */
122 #define LL_I2C_ICR_BERRCF I2C_ICR_BERRCF /*!< Bus error flag */
123 #define LL_I2C_ICR_ARLOCF I2C_ICR_ARLOCF /*!< Arbitration Lost flag */
124 #define LL_I2C_ICR_OVRCF I2C_ICR_OVRCF /*!< Overrun/Underrun flag */
125 #define LL_I2C_ICR_PECCF I2C_ICR_PECCF /*!< PEC error flag */
126 #define LL_I2C_ICR_TIMOUTCF I2C_ICR_TIMOUTCF /*!< Timeout detection flag */
127 #define LL_I2C_ICR_ALERTCF I2C_ICR_ALERTCF /*!< Alert flag */
132 /** @defgroup I2C_LL_EC_GET_FLAG Get Flags Defines
133 * @brief Flags defines which can be used with LL_I2C_ReadReg function
136 #define LL_I2C_ISR_TXE I2C_ISR_TXE /*!< Transmit data register empty */
137 #define LL_I2C_ISR_TXIS I2C_ISR_TXIS /*!< Transmit interrupt status */
138 #define LL_I2C_ISR_RXNE I2C_ISR_RXNE /*!< Receive data register not empty */
139 #define LL_I2C_ISR_ADDR I2C_ISR_ADDR /*!< Address matched (slave mode) */
140 #define LL_I2C_ISR_NACKF I2C_ISR_NACKF /*!< Not Acknowledge received flag */
141 #define LL_I2C_ISR_STOPF I2C_ISR_STOPF /*!< Stop detection flag */
142 #define LL_I2C_ISR_TC I2C_ISR_TC /*!< Transfer Complete (master mode) */
143 #define LL_I2C_ISR_TCR I2C_ISR_TCR /*!< Transfer Complete Reload */
144 #define LL_I2C_ISR_BERR I2C_ISR_BERR /*!< Bus error */
145 #define LL_I2C_ISR_ARLO I2C_ISR_ARLO /*!< Arbitration lost */
146 #define LL_I2C_ISR_OVR I2C_ISR_OVR /*!< Overrun/Underrun (slave mode) */
147 #define LL_I2C_ISR_PECERR I2C_ISR_PECERR /*!< PEC Error in reception (SMBus mode) */
148 #define LL_I2C_ISR_TIMEOUT I2C_ISR_TIMEOUT /*!< Timeout detection flag (SMBus mode) */
149 #define LL_I2C_ISR_ALERT I2C_ISR_ALERT /*!< SMBus alert (SMBus mode) */
150 #define LL_I2C_ISR_BUSY I2C_ISR_BUSY /*!< Bus busy */
155 /** @defgroup I2C_LL_EC_IT IT Defines
156 * @brief IT defines which can be used with LL_I2C_ReadReg and LL_I2C_WriteReg functions
159 #define LL_I2C_CR1_TXIE I2C_CR1_TXIE /*!< TX Interrupt enable */
160 #define LL_I2C_CR1_RXIE I2C_CR1_RXIE /*!< RX Interrupt enable */
161 #define LL_I2C_CR1_ADDRIE I2C_CR1_ADDRIE /*!< Address match Interrupt enable (slave only) */
162 #define LL_I2C_CR1_NACKIE I2C_CR1_NACKIE /*!< Not acknowledge received Interrupt enable */
163 #define LL_I2C_CR1_STOPIE I2C_CR1_STOPIE /*!< STOP detection Interrupt enable */
164 #define LL_I2C_CR1_TCIE I2C_CR1_TCIE /*!< Transfer Complete interrupt enable */
165 #define LL_I2C_CR1_ERRIE I2C_CR1_ERRIE /*!< Error interrupts enable */
170 /** @defgroup I2C_LL_EC_PERIPHERAL_MODE Peripheral Mode
173 #define LL_I2C_MODE_I2C 0x00000000U /*!< I2C Master or Slave mode */
174 #define LL_I2C_MODE_SMBUS_HOST I2C_CR1_SMBHEN /*!< SMBus Host address acknowledge */
175 #define LL_I2C_MODE_SMBUS_DEVICE 0x00000000U /*!< SMBus Device default mode (Default address not acknowledge) */
176 #define LL_I2C_MODE_SMBUS_DEVICE_ARP I2C_CR1_SMBDEN /*!< SMBus Device Default address acknowledge */
181 /** @defgroup I2C_LL_EC_ANALOGFILTER_SELECTION Analog Filter Selection
184 #define LL_I2C_ANALOGFILTER_ENABLE 0x00000000U /*!< Analog filter is enabled. */
185 #define LL_I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF /*!< Analog filter is disabled. */
190 /** @defgroup I2C_LL_EC_ADDRESSING_MODE Master Addressing Mode
193 #define LL_I2C_ADDRESSING_MODE_7BIT 0x00000000U /*!< Master operates in 7-bit addressing mode. */
194 #define LL_I2C_ADDRESSING_MODE_10BIT I2C_CR2_ADD10 /*!< Master operates in 10-bit addressing mode.*/
199 /** @defgroup I2C_LL_EC_OWNADDRESS1 Own Address 1 Length
202 #define LL_I2C_OWNADDRESS1_7BIT 0x00000000U /*!< Own address 1 is a 7-bit address. */
203 #define LL_I2C_OWNADDRESS1_10BIT I2C_OAR1_OA1MODE /*!< Own address 1 is a 10-bit address.*/
208 /** @defgroup I2C_LL_EC_OWNADDRESS2 Own Address 2 Masks
211 #define LL_I2C_OWNADDRESS2_NOMASK I2C_OAR2_OA2NOMASK /*!< Own Address2 No mask. */
212 #define LL_I2C_OWNADDRESS2_MASK01 I2C_OAR2_OA2MASK01 /*!< Only Address2 bits[7:2] are compared. */
213 #define LL_I2C_OWNADDRESS2_MASK02 I2C_OAR2_OA2MASK02 /*!< Only Address2 bits[7:3] are compared. */
214 #define LL_I2C_OWNADDRESS2_MASK03 I2C_OAR2_OA2MASK03 /*!< Only Address2 bits[7:4] are compared. */
215 #define LL_I2C_OWNADDRESS2_MASK04 I2C_OAR2_OA2MASK04 /*!< Only Address2 bits[7:5] are compared. */
216 #define LL_I2C_OWNADDRESS2_MASK05 I2C_OAR2_OA2MASK05 /*!< Only Address2 bits[7:6] are compared. */
217 #define LL_I2C_OWNADDRESS2_MASK06 I2C_OAR2_OA2MASK06 /*!< Only Address2 bits[7] are compared. */
218 #define LL_I2C_OWNADDRESS2_MASK07 I2C_OAR2_OA2MASK07 /*!< No comparison is done. All Address2 are acknowledged.*/
223 /** @defgroup I2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
226 #define LL_I2C_ACK 0x00000000U /*!< ACK is sent after current received byte. */
227 #define LL_I2C_NACK I2C_CR2_NACK /*!< NACK is sent after current received byte.*/
232 /** @defgroup I2C_LL_EC_ADDRSLAVE Slave Address Length
235 #define LL_I2C_ADDRSLAVE_7BIT 0x00000000U /*!< Slave Address in 7-bit. */
236 #define LL_I2C_ADDRSLAVE_10BIT I2C_CR2_ADD10 /*!< Slave Address in 10-bit.*/
241 /** @defgroup I2C_LL_EC_REQUEST Transfer Request Direction
244 #define LL_I2C_REQUEST_WRITE 0x00000000U /*!< Master request a write transfer. */
245 #define LL_I2C_REQUEST_READ I2C_CR2_RD_WRN /*!< Master request a read transfer. */
250 /** @defgroup I2C_LL_EC_MODE Transfer End Mode
253 #define LL_I2C_MODE_RELOAD I2C_CR2_RELOAD /*!< Enable I2C Reload mode. */
254 #define LL_I2C_MODE_AUTOEND I2C_CR2_AUTOEND /*!< Enable I2C Automatic end mode with no HW PEC comparison. */
255 #define LL_I2C_MODE_SOFTEND 0x00000000U /*!< Enable I2C Software end mode with no HW PEC comparison. */
256 #define LL_I2C_MODE_SMBUS_RELOAD LL_I2C_MODE_RELOAD /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
257 #define LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC LL_I2C_MODE_AUTOEND /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
258 #define LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC LL_I2C_MODE_SOFTEND /*!< Enable SMBUS Software end mode with HW PEC comparison. */
259 #define LL_I2C_MODE_SMBUS_AUTOEND_WITH_PEC (uint32_t)(LL_I2C_MODE_AUTOEND | I2C_CR2_PECBYTE) /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
260 #define LL_I2C_MODE_SMBUS_SOFTEND_WITH_PEC (uint32_t)(LL_I2C_MODE_SOFTEND | I2C_CR2_PECBYTE) /*!< Enable SMBUS Software end mode with HW PEC comparison. */
265 /** @defgroup I2C_LL_EC_GENERATE Start And Stop Generation
268 #define LL_I2C_GENERATE_NOSTARTSTOP 0x00000000U /*!< Don't Generate Stop and Start condition. */
269 #define LL_I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP) /*!< Generate Stop condition (Size should be set to 0). */
270 #define LL_I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) /*!< Generate Start for read request. */
271 #define LL_I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Start for write request. */
272 #define LL_I2C_GENERATE_RESTART_7BIT_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) /*!< Generate Restart for read request, slave 7Bit address. */
273 #define LL_I2C_GENERATE_RESTART_7BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 7Bit address. */
274 #define LL_I2C_GENERATE_RESTART_10BIT_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN | I2C_CR2_HEAD10R) /*!< Generate Restart for read request, slave 10Bit address. */
275 #define LL_I2C_GENERATE_RESTART_10BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 10Bit address.*/
280 /** @defgroup I2C_LL_EC_DIRECTION Read Write Direction
283 #define LL_I2C_DIRECTION_WRITE 0x00000000U /*!< Write transfer request by master, slave enters receiver mode. */
284 #define LL_I2C_DIRECTION_READ I2C_ISR_DIR /*!< Read transfer request by master, slave enters transmitter mode.*/
289 /** @defgroup I2C_LL_EC_DMA_REG_DATA DMA Register Data
292 #define LL_I2C_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
293 #define LL_I2C_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
298 /** @defgroup I2C_LL_EC_SMBUS_TIMEOUTA_MODE SMBus TimeoutA Mode SCL SDA Timeout
301 #define LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW 0x00000000U /*!< TimeoutA is used to detect SCL low level timeout. */
302 #define LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH I2C_TIMEOUTR_TIDLE /*!< TimeoutA is used to detect both SCL and SDA high level timeout.*/
307 /** @defgroup I2C_LL_EC_SMBUS_TIMEOUT_SELECTION SMBus Timeout Selection
310 #define LL_I2C_SMBUS_TIMEOUTA I2C_TIMEOUTR_TIMOUTEN /*!< TimeoutA enable bit */
311 #define LL_I2C_SMBUS_TIMEOUTB I2C_TIMEOUTR_TEXTEN /*!< TimeoutB (extended clock) enable bit */
312 #define LL_I2C_SMBUS_ALL_TIMEOUT (uint32_t)(I2C_TIMEOUTR_TIMOUTEN | I2C_TIMEOUTR_TEXTEN) /*!< TimeoutA and TimeoutB (extended clock) enable bits */
321 /* Exported macro ------------------------------------------------------------*/
322 /** @defgroup I2C_LL_Exported_Macros I2C Exported Macros
326 /** @defgroup I2C_LL_EM_WRITE_READ Common Write and read registers Macros
331 * @brief Write a value in I2C register
332 * @param __INSTANCE__ I2C Instance
333 * @param __REG__ Register to be written
334 * @param __VALUE__ Value to be written in the register
337 #define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
340 * @brief Read a value in I2C register
341 * @param __INSTANCE__ I2C Instance
342 * @param __REG__ Register to be read
343 * @retval Register value
345 #define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
350 /** @defgroup I2C_LL_EM_CONVERT_TIMINGS Convert SDA SCL timings
354 * @brief Configure the SDA setup, hold time and the SCL high, low period.
355 * @param __PRESCALER__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
356 * @param __DATA_SETUP_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tscldel = (SCLDEL+1)xtpresc)
357 * @param __DATA_HOLD_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tsdadel = SDADELxtpresc)
358 * @param __CLOCK_HIGH_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tsclh = (SCLH+1)xtpresc)
359 * @param __CLOCK_LOW_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tscll = (SCLL+1)xtpresc)
360 * @retval Value between Min_Data=0 and Max_Data=0xFFFFFFFF
362 #define __LL_I2C_CONVERT_TIMINGS(__PRESCALER__, __DATA_SETUP_TIME__, __DATA_HOLD_TIME__, __CLOCK_HIGH_PERIOD__, __CLOCK_LOW_PERIOD__) \
363 ((((uint32_t)(__PRESCALER__) << I2C_TIMINGR_PRESC_Pos) & I2C_TIMINGR_PRESC) | \
364 (((uint32_t)(__DATA_SETUP_TIME__) << I2C_TIMINGR_SCLDEL_Pos) & I2C_TIMINGR_SCLDEL) | \
365 (((uint32_t)(__DATA_HOLD_TIME__) << I2C_TIMINGR_SDADEL_Pos) & I2C_TIMINGR_SDADEL) | \
366 (((uint32_t)(__CLOCK_HIGH_PERIOD__) << I2C_TIMINGR_SCLH_Pos) & I2C_TIMINGR_SCLH) | \
367 (((uint32_t)(__CLOCK_LOW_PERIOD__) << I2C_TIMINGR_SCLL_Pos) & I2C_TIMINGR_SCLL))
376 /* Exported functions --------------------------------------------------------*/
377 /** @defgroup I2C_LL_Exported_Functions I2C Exported Functions
381 /** @defgroup I2C_LL_EF_Configuration Configuration
386 * @brief Enable I2C peripheral (PE = 1).
387 * @rmtoll CR1 PE LL_I2C_Enable
388 * @param I2Cx I2C Instance.
391 __STATIC_INLINE
void LL_I2C_Enable(I2C_TypeDef
*I2Cx
)
393 SET_BIT(I2Cx
->CR1
, I2C_CR1_PE
);
397 * @brief Disable I2C peripheral (PE = 0).
398 * @note When PE = 0, the I2C SCL and SDA lines are released.
399 * Internal state machines and status bits are put back to their reset value.
400 * When cleared, PE must be kept low for at least 3 APB clock cycles.
401 * @rmtoll CR1 PE LL_I2C_Disable
402 * @param I2Cx I2C Instance.
405 __STATIC_INLINE
void LL_I2C_Disable(I2C_TypeDef
*I2Cx
)
407 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_PE
);
411 * @brief Check if the I2C peripheral is enabled or disabled.
412 * @rmtoll CR1 PE LL_I2C_IsEnabled
413 * @param I2Cx I2C Instance.
414 * @retval State of bit (1 or 0).
416 __STATIC_INLINE
uint32_t LL_I2C_IsEnabled(I2C_TypeDef
*I2Cx
)
418 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_PE
) == (I2C_CR1_PE
)) ? 1UL : 0UL);
422 * @brief Configure Noise Filters (Analog and Digital).
423 * @note If the analog filter is also enabled, the digital filter is added to analog filter.
424 * The filters can only be programmed when the I2C is disabled (PE = 0).
425 * @rmtoll CR1 ANFOFF LL_I2C_ConfigFilters\n
426 * CR1 DNF LL_I2C_ConfigFilters
427 * @param I2Cx I2C Instance.
428 * @param AnalogFilter This parameter can be one of the following values:
429 * @arg @ref LL_I2C_ANALOGFILTER_ENABLE
430 * @arg @ref LL_I2C_ANALOGFILTER_DISABLE
431 * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled) and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*ti2cclk).
432 * This parameter is used to configure the digital noise filter on SDA and SCL input.
433 * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
436 __STATIC_INLINE
void LL_I2C_ConfigFilters(I2C_TypeDef
*I2Cx
, uint32_t AnalogFilter
, uint32_t DigitalFilter
)
438 MODIFY_REG(I2Cx
->CR1
, I2C_CR1_ANFOFF
| I2C_CR1_DNF
, AnalogFilter
| (DigitalFilter
<< I2C_CR1_DNF_Pos
));
442 * @brief Configure Digital Noise Filter.
443 * @note If the analog filter is also enabled, the digital filter is added to analog filter.
444 * This filter can only be programmed when the I2C is disabled (PE = 0).
445 * @rmtoll CR1 DNF LL_I2C_SetDigitalFilter
446 * @param I2Cx I2C Instance.
447 * @param DigitalFilter This parameter must be a value between Min_Data=0x00 (Digital filter disabled) and Max_Data=0x0F (Digital filter enabled and filtering capability up to 15*ti2cclk).
448 * This parameter is used to configure the digital noise filter on SDA and SCL input.
449 * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
452 __STATIC_INLINE
void LL_I2C_SetDigitalFilter(I2C_TypeDef
*I2Cx
, uint32_t DigitalFilter
)
454 MODIFY_REG(I2Cx
->CR1
, I2C_CR1_DNF
, DigitalFilter
<< I2C_CR1_DNF_Pos
);
458 * @brief Get the current Digital Noise Filter configuration.
459 * @rmtoll CR1 DNF LL_I2C_GetDigitalFilter
460 * @param I2Cx I2C Instance.
461 * @retval Value between Min_Data=0x0 and Max_Data=0xF
463 __STATIC_INLINE
uint32_t LL_I2C_GetDigitalFilter(I2C_TypeDef
*I2Cx
)
465 return (uint32_t)(READ_BIT(I2Cx
->CR1
, I2C_CR1_DNF
) >> I2C_CR1_DNF_Pos
);
469 * @brief Enable Analog Noise Filter.
470 * @note This filter can only be programmed when the I2C is disabled (PE = 0).
471 * @rmtoll CR1 ANFOFF LL_I2C_EnableAnalogFilter
472 * @param I2Cx I2C Instance.
475 __STATIC_INLINE
void LL_I2C_EnableAnalogFilter(I2C_TypeDef
*I2Cx
)
477 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_ANFOFF
);
481 * @brief Disable Analog Noise Filter.
482 * @note This filter can only be programmed when the I2C is disabled (PE = 0).
483 * @rmtoll CR1 ANFOFF LL_I2C_DisableAnalogFilter
484 * @param I2Cx I2C Instance.
487 __STATIC_INLINE
void LL_I2C_DisableAnalogFilter(I2C_TypeDef
*I2Cx
)
489 SET_BIT(I2Cx
->CR1
, I2C_CR1_ANFOFF
);
493 * @brief Check if Analog Noise Filter is enabled or disabled.
494 * @rmtoll CR1 ANFOFF LL_I2C_IsEnabledAnalogFilter
495 * @param I2Cx I2C Instance.
496 * @retval State of bit (1 or 0).
498 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledAnalogFilter(I2C_TypeDef
*I2Cx
)
500 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_ANFOFF
) != (I2C_CR1_ANFOFF
)) ? 1UL : 0UL);
504 * @brief Enable DMA transmission requests.
505 * @rmtoll CR1 TXDMAEN LL_I2C_EnableDMAReq_TX
506 * @param I2Cx I2C Instance.
509 __STATIC_INLINE
void LL_I2C_EnableDMAReq_TX(I2C_TypeDef
*I2Cx
)
511 SET_BIT(I2Cx
->CR1
, I2C_CR1_TXDMAEN
);
515 * @brief Disable DMA transmission requests.
516 * @rmtoll CR1 TXDMAEN LL_I2C_DisableDMAReq_TX
517 * @param I2Cx I2C Instance.
520 __STATIC_INLINE
void LL_I2C_DisableDMAReq_TX(I2C_TypeDef
*I2Cx
)
522 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_TXDMAEN
);
526 * @brief Check if DMA transmission requests are enabled or disabled.
527 * @rmtoll CR1 TXDMAEN LL_I2C_IsEnabledDMAReq_TX
528 * @param I2Cx I2C Instance.
529 * @retval State of bit (1 or 0).
531 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef
*I2Cx
)
533 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_TXDMAEN
) == (I2C_CR1_TXDMAEN
)) ? 1UL : 0UL);
537 * @brief Enable DMA reception requests.
538 * @rmtoll CR1 RXDMAEN LL_I2C_EnableDMAReq_RX
539 * @param I2Cx I2C Instance.
542 __STATIC_INLINE
void LL_I2C_EnableDMAReq_RX(I2C_TypeDef
*I2Cx
)
544 SET_BIT(I2Cx
->CR1
, I2C_CR1_RXDMAEN
);
548 * @brief Disable DMA reception requests.
549 * @rmtoll CR1 RXDMAEN LL_I2C_DisableDMAReq_RX
550 * @param I2Cx I2C Instance.
553 __STATIC_INLINE
void LL_I2C_DisableDMAReq_RX(I2C_TypeDef
*I2Cx
)
555 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_RXDMAEN
);
559 * @brief Check if DMA reception requests are enabled or disabled.
560 * @rmtoll CR1 RXDMAEN LL_I2C_IsEnabledDMAReq_RX
561 * @param I2Cx I2C Instance.
562 * @retval State of bit (1 or 0).
564 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef
*I2Cx
)
566 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_RXDMAEN
) == (I2C_CR1_RXDMAEN
)) ? 1UL : 0UL);
570 * @brief Get the data register address used for DMA transfer
571 * @rmtoll TXDR TXDATA LL_I2C_DMA_GetRegAddr\n
572 * RXDR RXDATA LL_I2C_DMA_GetRegAddr
573 * @param I2Cx I2C Instance
574 * @param Direction This parameter can be one of the following values:
575 * @arg @ref LL_I2C_DMA_REG_DATA_TRANSMIT
576 * @arg @ref LL_I2C_DMA_REG_DATA_RECEIVE
577 * @retval Address of data register
579 __STATIC_INLINE
uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef
*I2Cx
, uint32_t Direction
)
581 uint32_t data_reg_addr
;
583 if (Direction
== LL_I2C_DMA_REG_DATA_TRANSMIT
)
585 /* return address of TXDR register */
586 data_reg_addr
= (uint32_t) & (I2Cx
->TXDR
);
590 /* return address of RXDR register */
591 data_reg_addr
= (uint32_t) & (I2Cx
->RXDR
);
594 return data_reg_addr
;
598 * @brief Enable Clock stretching.
599 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
600 * @rmtoll CR1 NOSTRETCH LL_I2C_EnableClockStretching
601 * @param I2Cx I2C Instance.
604 __STATIC_INLINE
void LL_I2C_EnableClockStretching(I2C_TypeDef
*I2Cx
)
606 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_NOSTRETCH
);
610 * @brief Disable Clock stretching.
611 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
612 * @rmtoll CR1 NOSTRETCH LL_I2C_DisableClockStretching
613 * @param I2Cx I2C Instance.
616 __STATIC_INLINE
void LL_I2C_DisableClockStretching(I2C_TypeDef
*I2Cx
)
618 SET_BIT(I2Cx
->CR1
, I2C_CR1_NOSTRETCH
);
622 * @brief Check if Clock stretching is enabled or disabled.
623 * @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretching
624 * @param I2Cx I2C Instance.
625 * @retval State of bit (1 or 0).
627 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledClockStretching(I2C_TypeDef
*I2Cx
)
629 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_NOSTRETCH
) != (I2C_CR1_NOSTRETCH
)) ? 1UL : 0UL);
633 * @brief Enable hardware byte control in slave mode.
634 * @rmtoll CR1 SBC LL_I2C_EnableSlaveByteControl
635 * @param I2Cx I2C Instance.
638 __STATIC_INLINE
void LL_I2C_EnableSlaveByteControl(I2C_TypeDef
*I2Cx
)
640 SET_BIT(I2Cx
->CR1
, I2C_CR1_SBC
);
644 * @brief Disable hardware byte control in slave mode.
645 * @rmtoll CR1 SBC LL_I2C_DisableSlaveByteControl
646 * @param I2Cx I2C Instance.
649 __STATIC_INLINE
void LL_I2C_DisableSlaveByteControl(I2C_TypeDef
*I2Cx
)
651 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_SBC
);
655 * @brief Check if hardware byte control in slave mode is enabled or disabled.
656 * @rmtoll CR1 SBC LL_I2C_IsEnabledSlaveByteControl
657 * @param I2Cx I2C Instance.
658 * @retval State of bit (1 or 0).
660 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledSlaveByteControl(I2C_TypeDef
*I2Cx
)
662 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_SBC
) == (I2C_CR1_SBC
)) ? 1UL : 0UL);
666 * @brief Enable Wakeup from STOP.
667 * @note Macro IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
668 * WakeUpFromStop feature is supported by the I2Cx Instance.
669 * @note This bit can only be programmed when Digital Filter is disabled.
670 * @rmtoll CR1 WUPEN LL_I2C_EnableWakeUpFromStop
671 * @param I2Cx I2C Instance.
674 __STATIC_INLINE
void LL_I2C_EnableWakeUpFromStop(I2C_TypeDef
*I2Cx
)
676 SET_BIT(I2Cx
->CR1
, I2C_CR1_WUPEN
);
680 * @brief Disable Wakeup from STOP.
681 * @note Macro IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
682 * WakeUpFromStop feature is supported by the I2Cx Instance.
683 * @rmtoll CR1 WUPEN LL_I2C_DisableWakeUpFromStop
684 * @param I2Cx I2C Instance.
687 __STATIC_INLINE
void LL_I2C_DisableWakeUpFromStop(I2C_TypeDef
*I2Cx
)
689 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_WUPEN
);
693 * @brief Check if Wakeup from STOP is enabled or disabled.
694 * @note Macro IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
695 * WakeUpFromStop feature is supported by the I2Cx Instance.
696 * @rmtoll CR1 WUPEN LL_I2C_IsEnabledWakeUpFromStop
697 * @param I2Cx I2C Instance.
698 * @retval State of bit (1 or 0).
700 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledWakeUpFromStop(I2C_TypeDef
*I2Cx
)
702 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_WUPEN
) == (I2C_CR1_WUPEN
)) ? 1UL : 0UL);
706 * @brief Enable General Call.
707 * @note When enabled the Address 0x00 is ACKed.
708 * @rmtoll CR1 GCEN LL_I2C_EnableGeneralCall
709 * @param I2Cx I2C Instance.
712 __STATIC_INLINE
void LL_I2C_EnableGeneralCall(I2C_TypeDef
*I2Cx
)
714 SET_BIT(I2Cx
->CR1
, I2C_CR1_GCEN
);
718 * @brief Disable General Call.
719 * @note When disabled the Address 0x00 is NACKed.
720 * @rmtoll CR1 GCEN LL_I2C_DisableGeneralCall
721 * @param I2Cx I2C Instance.
724 __STATIC_INLINE
void LL_I2C_DisableGeneralCall(I2C_TypeDef
*I2Cx
)
726 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_GCEN
);
730 * @brief Check if General Call is enabled or disabled.
731 * @rmtoll CR1 GCEN LL_I2C_IsEnabledGeneralCall
732 * @param I2Cx I2C Instance.
733 * @retval State of bit (1 or 0).
735 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef
*I2Cx
)
737 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_GCEN
) == (I2C_CR1_GCEN
)) ? 1UL : 0UL);
741 * @brief Configure the Master to operate in 7-bit or 10-bit addressing mode.
742 * @note Changing this bit is not allowed, when the START bit is set.
743 * @rmtoll CR2 ADD10 LL_I2C_SetMasterAddressingMode
744 * @param I2Cx I2C Instance.
745 * @param AddressingMode This parameter can be one of the following values:
746 * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
747 * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
750 __STATIC_INLINE
void LL_I2C_SetMasterAddressingMode(I2C_TypeDef
*I2Cx
, uint32_t AddressingMode
)
752 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_ADD10
, AddressingMode
);
756 * @brief Get the Master addressing mode.
757 * @rmtoll CR2 ADD10 LL_I2C_GetMasterAddressingMode
758 * @param I2Cx I2C Instance.
759 * @retval Returned value can be one of the following values:
760 * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
761 * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
763 __STATIC_INLINE
uint32_t LL_I2C_GetMasterAddressingMode(I2C_TypeDef
*I2Cx
)
765 return (uint32_t)(READ_BIT(I2Cx
->CR2
, I2C_CR2_ADD10
));
769 * @brief Set the Own Address1.
770 * @rmtoll OAR1 OA1 LL_I2C_SetOwnAddress1\n
771 * OAR1 OA1MODE LL_I2C_SetOwnAddress1
772 * @param I2Cx I2C Instance.
773 * @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
774 * @param OwnAddrSize This parameter can be one of the following values:
775 * @arg @ref LL_I2C_OWNADDRESS1_7BIT
776 * @arg @ref LL_I2C_OWNADDRESS1_10BIT
779 __STATIC_INLINE
void LL_I2C_SetOwnAddress1(I2C_TypeDef
*I2Cx
, uint32_t OwnAddress1
, uint32_t OwnAddrSize
)
781 MODIFY_REG(I2Cx
->OAR1
, I2C_OAR1_OA1
| I2C_OAR1_OA1MODE
, OwnAddress1
| OwnAddrSize
);
785 * @brief Enable acknowledge on Own Address1 match address.
786 * @rmtoll OAR1 OA1EN LL_I2C_EnableOwnAddress1
787 * @param I2Cx I2C Instance.
790 __STATIC_INLINE
void LL_I2C_EnableOwnAddress1(I2C_TypeDef
*I2Cx
)
792 SET_BIT(I2Cx
->OAR1
, I2C_OAR1_OA1EN
);
796 * @brief Disable acknowledge on Own Address1 match address.
797 * @rmtoll OAR1 OA1EN LL_I2C_DisableOwnAddress1
798 * @param I2Cx I2C Instance.
801 __STATIC_INLINE
void LL_I2C_DisableOwnAddress1(I2C_TypeDef
*I2Cx
)
803 CLEAR_BIT(I2Cx
->OAR1
, I2C_OAR1_OA1EN
);
807 * @brief Check if Own Address1 acknowledge is enabled or disabled.
808 * @rmtoll OAR1 OA1EN LL_I2C_IsEnabledOwnAddress1
809 * @param I2Cx I2C Instance.
810 * @retval State of bit (1 or 0).
812 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledOwnAddress1(I2C_TypeDef
*I2Cx
)
814 return ((READ_BIT(I2Cx
->OAR1
, I2C_OAR1_OA1EN
) == (I2C_OAR1_OA1EN
)) ? 1UL : 0UL);
818 * @brief Set the 7bits Own Address2.
819 * @note This action has no effect if own address2 is enabled.
820 * @rmtoll OAR2 OA2 LL_I2C_SetOwnAddress2\n
821 * OAR2 OA2MSK LL_I2C_SetOwnAddress2
822 * @param I2Cx I2C Instance.
823 * @param OwnAddress2 Value between Min_Data=0 and Max_Data=0x7F.
824 * @param OwnAddrMask This parameter can be one of the following values:
825 * @arg @ref LL_I2C_OWNADDRESS2_NOMASK
826 * @arg @ref LL_I2C_OWNADDRESS2_MASK01
827 * @arg @ref LL_I2C_OWNADDRESS2_MASK02
828 * @arg @ref LL_I2C_OWNADDRESS2_MASK03
829 * @arg @ref LL_I2C_OWNADDRESS2_MASK04
830 * @arg @ref LL_I2C_OWNADDRESS2_MASK05
831 * @arg @ref LL_I2C_OWNADDRESS2_MASK06
832 * @arg @ref LL_I2C_OWNADDRESS2_MASK07
835 __STATIC_INLINE
void LL_I2C_SetOwnAddress2(I2C_TypeDef
*I2Cx
, uint32_t OwnAddress2
, uint32_t OwnAddrMask
)
837 MODIFY_REG(I2Cx
->OAR2
, I2C_OAR2_OA2
| I2C_OAR2_OA2MSK
, OwnAddress2
| OwnAddrMask
);
841 * @brief Enable acknowledge on Own Address2 match address.
842 * @rmtoll OAR2 OA2EN LL_I2C_EnableOwnAddress2
843 * @param I2Cx I2C Instance.
846 __STATIC_INLINE
void LL_I2C_EnableOwnAddress2(I2C_TypeDef
*I2Cx
)
848 SET_BIT(I2Cx
->OAR2
, I2C_OAR2_OA2EN
);
852 * @brief Disable acknowledge on Own Address2 match address.
853 * @rmtoll OAR2 OA2EN LL_I2C_DisableOwnAddress2
854 * @param I2Cx I2C Instance.
857 __STATIC_INLINE
void LL_I2C_DisableOwnAddress2(I2C_TypeDef
*I2Cx
)
859 CLEAR_BIT(I2Cx
->OAR2
, I2C_OAR2_OA2EN
);
863 * @brief Check if Own Address1 acknowledge is enabled or disabled.
864 * @rmtoll OAR2 OA2EN LL_I2C_IsEnabledOwnAddress2
865 * @param I2Cx I2C Instance.
866 * @retval State of bit (1 or 0).
868 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledOwnAddress2(I2C_TypeDef
*I2Cx
)
870 return ((READ_BIT(I2Cx
->OAR2
, I2C_OAR2_OA2EN
) == (I2C_OAR2_OA2EN
)) ? 1UL : 0UL);
874 * @brief Configure the SDA setup, hold time and the SCL high, low period.
875 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
876 * @rmtoll TIMINGR TIMINGR LL_I2C_SetTiming
877 * @param I2Cx I2C Instance.
878 * @param Timing This parameter must be a value between Min_Data=0 and Max_Data=0xFFFFFFFF.
879 * @note This parameter is computed with the STM32CubeMX Tool.
882 __STATIC_INLINE
void LL_I2C_SetTiming(I2C_TypeDef
*I2Cx
, uint32_t Timing
)
884 WRITE_REG(I2Cx
->TIMINGR
, Timing
);
888 * @brief Get the Timing Prescaler setting.
889 * @rmtoll TIMINGR PRESC LL_I2C_GetTimingPrescaler
890 * @param I2Cx I2C Instance.
891 * @retval Value between Min_Data=0x0 and Max_Data=0xF
893 __STATIC_INLINE
uint32_t LL_I2C_GetTimingPrescaler(I2C_TypeDef
*I2Cx
)
895 return (uint32_t)(READ_BIT(I2Cx
->TIMINGR
, I2C_TIMINGR_PRESC
) >> I2C_TIMINGR_PRESC_Pos
);
899 * @brief Get the SCL low period setting.
900 * @rmtoll TIMINGR SCLL LL_I2C_GetClockLowPeriod
901 * @param I2Cx I2C Instance.
902 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
904 __STATIC_INLINE
uint32_t LL_I2C_GetClockLowPeriod(I2C_TypeDef
*I2Cx
)
906 return (uint32_t)(READ_BIT(I2Cx
->TIMINGR
, I2C_TIMINGR_SCLL
) >> I2C_TIMINGR_SCLL_Pos
);
910 * @brief Get the SCL high period setting.
911 * @rmtoll TIMINGR SCLH LL_I2C_GetClockHighPeriod
912 * @param I2Cx I2C Instance.
913 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
915 __STATIC_INLINE
uint32_t LL_I2C_GetClockHighPeriod(I2C_TypeDef
*I2Cx
)
917 return (uint32_t)(READ_BIT(I2Cx
->TIMINGR
, I2C_TIMINGR_SCLH
) >> I2C_TIMINGR_SCLH_Pos
);
921 * @brief Get the SDA hold time.
922 * @rmtoll TIMINGR SDADEL LL_I2C_GetDataHoldTime
923 * @param I2Cx I2C Instance.
924 * @retval Value between Min_Data=0x0 and Max_Data=0xF
926 __STATIC_INLINE
uint32_t LL_I2C_GetDataHoldTime(I2C_TypeDef
*I2Cx
)
928 return (uint32_t)(READ_BIT(I2Cx
->TIMINGR
, I2C_TIMINGR_SDADEL
) >> I2C_TIMINGR_SDADEL_Pos
);
932 * @brief Get the SDA setup time.
933 * @rmtoll TIMINGR SCLDEL LL_I2C_GetDataSetupTime
934 * @param I2Cx I2C Instance.
935 * @retval Value between Min_Data=0x0 and Max_Data=0xF
937 __STATIC_INLINE
uint32_t LL_I2C_GetDataSetupTime(I2C_TypeDef
*I2Cx
)
939 return (uint32_t)(READ_BIT(I2Cx
->TIMINGR
, I2C_TIMINGR_SCLDEL
) >> I2C_TIMINGR_SCLDEL_Pos
);
943 * @brief Configure peripheral mode.
944 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
945 * SMBus feature is supported by the I2Cx Instance.
946 * @rmtoll CR1 SMBHEN LL_I2C_SetMode\n
947 * CR1 SMBDEN LL_I2C_SetMode
948 * @param I2Cx I2C Instance.
949 * @param PeripheralMode This parameter can be one of the following values:
950 * @arg @ref LL_I2C_MODE_I2C
951 * @arg @ref LL_I2C_MODE_SMBUS_HOST
952 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
953 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
956 __STATIC_INLINE
void LL_I2C_SetMode(I2C_TypeDef
*I2Cx
, uint32_t PeripheralMode
)
958 MODIFY_REG(I2Cx
->CR1
, I2C_CR1_SMBHEN
| I2C_CR1_SMBDEN
, PeripheralMode
);
962 * @brief Get peripheral mode.
963 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
964 * SMBus feature is supported by the I2Cx Instance.
965 * @rmtoll CR1 SMBHEN LL_I2C_GetMode\n
966 * CR1 SMBDEN LL_I2C_GetMode
967 * @param I2Cx I2C Instance.
968 * @retval Returned value can be one of the following values:
969 * @arg @ref LL_I2C_MODE_I2C
970 * @arg @ref LL_I2C_MODE_SMBUS_HOST
971 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
972 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
974 __STATIC_INLINE
uint32_t LL_I2C_GetMode(I2C_TypeDef
*I2Cx
)
976 return (uint32_t)(READ_BIT(I2Cx
->CR1
, I2C_CR1_SMBHEN
| I2C_CR1_SMBDEN
));
980 * @brief Enable SMBus alert (Host or Device mode)
981 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
982 * SMBus feature is supported by the I2Cx Instance.
983 * @note SMBus Device mode:
984 * - SMBus Alert pin is drived low and
985 * Alert Response Address Header acknowledge is enabled.
987 * - SMBus Alert pin management is supported.
988 * @rmtoll CR1 ALERTEN LL_I2C_EnableSMBusAlert
989 * @param I2Cx I2C Instance.
992 __STATIC_INLINE
void LL_I2C_EnableSMBusAlert(I2C_TypeDef
*I2Cx
)
994 SET_BIT(I2Cx
->CR1
, I2C_CR1_ALERTEN
);
998 * @brief Disable SMBus alert (Host or Device mode)
999 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1000 * SMBus feature is supported by the I2Cx Instance.
1001 * @note SMBus Device mode:
1002 * - SMBus Alert pin is not drived (can be used as a standard GPIO) and
1003 * Alert Response Address Header acknowledge is disabled.
1005 * - SMBus Alert pin management is not supported.
1006 * @rmtoll CR1 ALERTEN LL_I2C_DisableSMBusAlert
1007 * @param I2Cx I2C Instance.
1010 __STATIC_INLINE
void LL_I2C_DisableSMBusAlert(I2C_TypeDef
*I2Cx
)
1012 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_ALERTEN
);
1016 * @brief Check if SMBus alert (Host or Device mode) is enabled or disabled.
1017 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1018 * SMBus feature is supported by the I2Cx Instance.
1019 * @rmtoll CR1 ALERTEN LL_I2C_IsEnabledSMBusAlert
1020 * @param I2Cx I2C Instance.
1021 * @retval State of bit (1 or 0).
1023 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledSMBusAlert(I2C_TypeDef
*I2Cx
)
1025 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_ALERTEN
) == (I2C_CR1_ALERTEN
)) ? 1UL : 0UL);
1029 * @brief Enable SMBus Packet Error Calculation (PEC).
1030 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1031 * SMBus feature is supported by the I2Cx Instance.
1032 * @rmtoll CR1 PECEN LL_I2C_EnableSMBusPEC
1033 * @param I2Cx I2C Instance.
1036 __STATIC_INLINE
void LL_I2C_EnableSMBusPEC(I2C_TypeDef
*I2Cx
)
1038 SET_BIT(I2Cx
->CR1
, I2C_CR1_PECEN
);
1042 * @brief Disable SMBus Packet Error Calculation (PEC).
1043 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1044 * SMBus feature is supported by the I2Cx Instance.
1045 * @rmtoll CR1 PECEN LL_I2C_DisableSMBusPEC
1046 * @param I2Cx I2C Instance.
1049 __STATIC_INLINE
void LL_I2C_DisableSMBusPEC(I2C_TypeDef
*I2Cx
)
1051 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_PECEN
);
1055 * @brief Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
1056 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1057 * SMBus feature is supported by the I2Cx Instance.
1058 * @rmtoll CR1 PECEN LL_I2C_IsEnabledSMBusPEC
1059 * @param I2Cx I2C Instance.
1060 * @retval State of bit (1 or 0).
1062 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledSMBusPEC(I2C_TypeDef
*I2Cx
)
1064 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_PECEN
) == (I2C_CR1_PECEN
)) ? 1UL : 0UL);
1068 * @brief Configure the SMBus Clock Timeout.
1069 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1070 * SMBus feature is supported by the I2Cx Instance.
1071 * @note This configuration can only be programmed when associated Timeout is disabled (TimeoutA and/orTimeoutB).
1072 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_ConfigSMBusTimeout\n
1073 * TIMEOUTR TIDLE LL_I2C_ConfigSMBusTimeout\n
1074 * TIMEOUTR TIMEOUTB LL_I2C_ConfigSMBusTimeout
1075 * @param I2Cx I2C Instance.
1076 * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
1077 * @param TimeoutAMode This parameter can be one of the following values:
1078 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
1079 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
1083 __STATIC_INLINE
void LL_I2C_ConfigSMBusTimeout(I2C_TypeDef
*I2Cx
, uint32_t TimeoutA
, uint32_t TimeoutAMode
,
1086 MODIFY_REG(I2Cx
->TIMEOUTR
, I2C_TIMEOUTR_TIMEOUTA
| I2C_TIMEOUTR_TIDLE
| I2C_TIMEOUTR_TIMEOUTB
,
1087 TimeoutA
| TimeoutAMode
| (TimeoutB
<< I2C_TIMEOUTR_TIMEOUTB_Pos
));
1091 * @brief Configure the SMBus Clock TimeoutA (SCL low timeout or SCL and SDA high timeout depends on TimeoutA mode).
1092 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1093 * SMBus feature is supported by the I2Cx Instance.
1094 * @note These bits can only be programmed when TimeoutA is disabled.
1095 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_SetSMBusTimeoutA
1096 * @param I2Cx I2C Instance.
1097 * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
1100 __STATIC_INLINE
void LL_I2C_SetSMBusTimeoutA(I2C_TypeDef
*I2Cx
, uint32_t TimeoutA
)
1102 WRITE_REG(I2Cx
->TIMEOUTR
, TimeoutA
);
1106 * @brief Get the SMBus Clock TimeoutA setting.
1107 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1108 * SMBus feature is supported by the I2Cx Instance.
1109 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_GetSMBusTimeoutA
1110 * @param I2Cx I2C Instance.
1111 * @retval Value between Min_Data=0 and Max_Data=0xFFF
1113 __STATIC_INLINE
uint32_t LL_I2C_GetSMBusTimeoutA(I2C_TypeDef
*I2Cx
)
1115 return (uint32_t)(READ_BIT(I2Cx
->TIMEOUTR
, I2C_TIMEOUTR_TIMEOUTA
));
1119 * @brief Set the SMBus Clock TimeoutA mode.
1120 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1121 * SMBus feature is supported by the I2Cx Instance.
1122 * @note This bit can only be programmed when TimeoutA is disabled.
1123 * @rmtoll TIMEOUTR TIDLE LL_I2C_SetSMBusTimeoutAMode
1124 * @param I2Cx I2C Instance.
1125 * @param TimeoutAMode This parameter can be one of the following values:
1126 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
1127 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
1130 __STATIC_INLINE
void LL_I2C_SetSMBusTimeoutAMode(I2C_TypeDef
*I2Cx
, uint32_t TimeoutAMode
)
1132 WRITE_REG(I2Cx
->TIMEOUTR
, TimeoutAMode
);
1136 * @brief Get the SMBus Clock TimeoutA mode.
1137 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1138 * SMBus feature is supported by the I2Cx Instance.
1139 * @rmtoll TIMEOUTR TIDLE LL_I2C_GetSMBusTimeoutAMode
1140 * @param I2Cx I2C Instance.
1141 * @retval Returned value can be one of the following values:
1142 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
1143 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
1145 __STATIC_INLINE
uint32_t LL_I2C_GetSMBusTimeoutAMode(I2C_TypeDef
*I2Cx
)
1147 return (uint32_t)(READ_BIT(I2Cx
->TIMEOUTR
, I2C_TIMEOUTR_TIDLE
));
1151 * @brief Configure the SMBus Extended Cumulative Clock TimeoutB (Master or Slave mode).
1152 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1153 * SMBus feature is supported by the I2Cx Instance.
1154 * @note These bits can only be programmed when TimeoutB is disabled.
1155 * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_SetSMBusTimeoutB
1156 * @param I2Cx I2C Instance.
1157 * @param TimeoutB This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
1160 __STATIC_INLINE
void LL_I2C_SetSMBusTimeoutB(I2C_TypeDef
*I2Cx
, uint32_t TimeoutB
)
1162 WRITE_REG(I2Cx
->TIMEOUTR
, TimeoutB
<< I2C_TIMEOUTR_TIMEOUTB_Pos
);
1166 * @brief Get the SMBus Extented Cumulative Clock TimeoutB setting.
1167 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1168 * SMBus feature is supported by the I2Cx Instance.
1169 * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_GetSMBusTimeoutB
1170 * @param I2Cx I2C Instance.
1171 * @retval Value between Min_Data=0 and Max_Data=0xFFF
1173 __STATIC_INLINE
uint32_t LL_I2C_GetSMBusTimeoutB(I2C_TypeDef
*I2Cx
)
1175 return (uint32_t)(READ_BIT(I2Cx
->TIMEOUTR
, I2C_TIMEOUTR_TIMEOUTB
) >> I2C_TIMEOUTR_TIMEOUTB_Pos
);
1179 * @brief Enable the SMBus Clock Timeout.
1180 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1181 * SMBus feature is supported by the I2Cx Instance.
1182 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_EnableSMBusTimeout\n
1183 * TIMEOUTR TEXTEN LL_I2C_EnableSMBusTimeout
1184 * @param I2Cx I2C Instance.
1185 * @param ClockTimeout This parameter can be one of the following values:
1186 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
1187 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
1188 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
1191 __STATIC_INLINE
void LL_I2C_EnableSMBusTimeout(I2C_TypeDef
*I2Cx
, uint32_t ClockTimeout
)
1193 SET_BIT(I2Cx
->TIMEOUTR
, ClockTimeout
);
1197 * @brief Disable the SMBus Clock Timeout.
1198 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1199 * SMBus feature is supported by the I2Cx Instance.
1200 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_DisableSMBusTimeout\n
1201 * TIMEOUTR TEXTEN LL_I2C_DisableSMBusTimeout
1202 * @param I2Cx I2C Instance.
1203 * @param ClockTimeout This parameter can be one of the following values:
1204 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
1205 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
1206 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
1209 __STATIC_INLINE
void LL_I2C_DisableSMBusTimeout(I2C_TypeDef
*I2Cx
, uint32_t ClockTimeout
)
1211 CLEAR_BIT(I2Cx
->TIMEOUTR
, ClockTimeout
);
1215 * @brief Check if the SMBus Clock Timeout is enabled or disabled.
1216 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1217 * SMBus feature is supported by the I2Cx Instance.
1218 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_IsEnabledSMBusTimeout\n
1219 * TIMEOUTR TEXTEN LL_I2C_IsEnabledSMBusTimeout
1220 * @param I2Cx I2C Instance.
1221 * @param ClockTimeout This parameter can be one of the following values:
1222 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
1223 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
1224 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
1225 * @retval State of bit (1 or 0).
1227 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledSMBusTimeout(I2C_TypeDef
*I2Cx
, uint32_t ClockTimeout
)
1229 return ((READ_BIT(I2Cx
->TIMEOUTR
, (I2C_TIMEOUTR_TIMOUTEN
| I2C_TIMEOUTR_TEXTEN
)) == (ClockTimeout
)) ? 1UL : 0UL);
1236 /** @defgroup I2C_LL_EF_IT_Management IT_Management
1241 * @brief Enable TXIS interrupt.
1242 * @rmtoll CR1 TXIE LL_I2C_EnableIT_TX
1243 * @param I2Cx I2C Instance.
1246 __STATIC_INLINE
void LL_I2C_EnableIT_TX(I2C_TypeDef
*I2Cx
)
1248 SET_BIT(I2Cx
->CR1
, I2C_CR1_TXIE
);
1252 * @brief Disable TXIS interrupt.
1253 * @rmtoll CR1 TXIE LL_I2C_DisableIT_TX
1254 * @param I2Cx I2C Instance.
1257 __STATIC_INLINE
void LL_I2C_DisableIT_TX(I2C_TypeDef
*I2Cx
)
1259 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_TXIE
);
1263 * @brief Check if the TXIS Interrupt is enabled or disabled.
1264 * @rmtoll CR1 TXIE LL_I2C_IsEnabledIT_TX
1265 * @param I2Cx I2C Instance.
1266 * @retval State of bit (1 or 0).
1268 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef
*I2Cx
)
1270 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_TXIE
) == (I2C_CR1_TXIE
)) ? 1UL : 0UL);
1274 * @brief Enable RXNE interrupt.
1275 * @rmtoll CR1 RXIE LL_I2C_EnableIT_RX
1276 * @param I2Cx I2C Instance.
1279 __STATIC_INLINE
void LL_I2C_EnableIT_RX(I2C_TypeDef
*I2Cx
)
1281 SET_BIT(I2Cx
->CR1
, I2C_CR1_RXIE
);
1285 * @brief Disable RXNE interrupt.
1286 * @rmtoll CR1 RXIE LL_I2C_DisableIT_RX
1287 * @param I2Cx I2C Instance.
1290 __STATIC_INLINE
void LL_I2C_DisableIT_RX(I2C_TypeDef
*I2Cx
)
1292 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_RXIE
);
1296 * @brief Check if the RXNE Interrupt is enabled or disabled.
1297 * @rmtoll CR1 RXIE LL_I2C_IsEnabledIT_RX
1298 * @param I2Cx I2C Instance.
1299 * @retval State of bit (1 or 0).
1301 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_RX(I2C_TypeDef
*I2Cx
)
1303 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_RXIE
) == (I2C_CR1_RXIE
)) ? 1UL : 0UL);
1307 * @brief Enable Address match interrupt (slave mode only).
1308 * @rmtoll CR1 ADDRIE LL_I2C_EnableIT_ADDR
1309 * @param I2Cx I2C Instance.
1312 __STATIC_INLINE
void LL_I2C_EnableIT_ADDR(I2C_TypeDef
*I2Cx
)
1314 SET_BIT(I2Cx
->CR1
, I2C_CR1_ADDRIE
);
1318 * @brief Disable Address match interrupt (slave mode only).
1319 * @rmtoll CR1 ADDRIE LL_I2C_DisableIT_ADDR
1320 * @param I2Cx I2C Instance.
1323 __STATIC_INLINE
void LL_I2C_DisableIT_ADDR(I2C_TypeDef
*I2Cx
)
1325 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_ADDRIE
);
1329 * @brief Check if Address match interrupt is enabled or disabled.
1330 * @rmtoll CR1 ADDRIE LL_I2C_IsEnabledIT_ADDR
1331 * @param I2Cx I2C Instance.
1332 * @retval State of bit (1 or 0).
1334 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_ADDR(I2C_TypeDef
*I2Cx
)
1336 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_ADDRIE
) == (I2C_CR1_ADDRIE
)) ? 1UL : 0UL);
1340 * @brief Enable Not acknowledge received interrupt.
1341 * @rmtoll CR1 NACKIE LL_I2C_EnableIT_NACK
1342 * @param I2Cx I2C Instance.
1345 __STATIC_INLINE
void LL_I2C_EnableIT_NACK(I2C_TypeDef
*I2Cx
)
1347 SET_BIT(I2Cx
->CR1
, I2C_CR1_NACKIE
);
1351 * @brief Disable Not acknowledge received interrupt.
1352 * @rmtoll CR1 NACKIE LL_I2C_DisableIT_NACK
1353 * @param I2Cx I2C Instance.
1356 __STATIC_INLINE
void LL_I2C_DisableIT_NACK(I2C_TypeDef
*I2Cx
)
1358 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_NACKIE
);
1362 * @brief Check if Not acknowledge received interrupt is enabled or disabled.
1363 * @rmtoll CR1 NACKIE LL_I2C_IsEnabledIT_NACK
1364 * @param I2Cx I2C Instance.
1365 * @retval State of bit (1 or 0).
1367 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_NACK(I2C_TypeDef
*I2Cx
)
1369 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_NACKIE
) == (I2C_CR1_NACKIE
)) ? 1UL : 0UL);
1373 * @brief Enable STOP detection interrupt.
1374 * @rmtoll CR1 STOPIE LL_I2C_EnableIT_STOP
1375 * @param I2Cx I2C Instance.
1378 __STATIC_INLINE
void LL_I2C_EnableIT_STOP(I2C_TypeDef
*I2Cx
)
1380 SET_BIT(I2Cx
->CR1
, I2C_CR1_STOPIE
);
1384 * @brief Disable STOP detection interrupt.
1385 * @rmtoll CR1 STOPIE LL_I2C_DisableIT_STOP
1386 * @param I2Cx I2C Instance.
1389 __STATIC_INLINE
void LL_I2C_DisableIT_STOP(I2C_TypeDef
*I2Cx
)
1391 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_STOPIE
);
1395 * @brief Check if STOP detection interrupt is enabled or disabled.
1396 * @rmtoll CR1 STOPIE LL_I2C_IsEnabledIT_STOP
1397 * @param I2Cx I2C Instance.
1398 * @retval State of bit (1 or 0).
1400 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_STOP(I2C_TypeDef
*I2Cx
)
1402 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_STOPIE
) == (I2C_CR1_STOPIE
)) ? 1UL : 0UL);
1406 * @brief Enable Transfer Complete interrupt.
1407 * @note Any of these events will generate interrupt :
1408 * Transfer Complete (TC)
1409 * Transfer Complete Reload (TCR)
1410 * @rmtoll CR1 TCIE LL_I2C_EnableIT_TC
1411 * @param I2Cx I2C Instance.
1414 __STATIC_INLINE
void LL_I2C_EnableIT_TC(I2C_TypeDef
*I2Cx
)
1416 SET_BIT(I2Cx
->CR1
, I2C_CR1_TCIE
);
1420 * @brief Disable Transfer Complete interrupt.
1421 * @note Any of these events will generate interrupt :
1422 * Transfer Complete (TC)
1423 * Transfer Complete Reload (TCR)
1424 * @rmtoll CR1 TCIE LL_I2C_DisableIT_TC
1425 * @param I2Cx I2C Instance.
1428 __STATIC_INLINE
void LL_I2C_DisableIT_TC(I2C_TypeDef
*I2Cx
)
1430 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_TCIE
);
1434 * @brief Check if Transfer Complete interrupt is enabled or disabled.
1435 * @rmtoll CR1 TCIE LL_I2C_IsEnabledIT_TC
1436 * @param I2Cx I2C Instance.
1437 * @retval State of bit (1 or 0).
1439 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_TC(I2C_TypeDef
*I2Cx
)
1441 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_TCIE
) == (I2C_CR1_TCIE
)) ? 1UL : 0UL);
1445 * @brief Enable Error interrupts.
1446 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1447 * SMBus feature is supported by the I2Cx Instance.
1448 * @note Any of these errors will generate interrupt :
1449 * Arbitration Loss (ARLO)
1450 * Bus Error detection (BERR)
1451 * Overrun/Underrun (OVR)
1452 * SMBus Timeout detection (TIMEOUT)
1453 * SMBus PEC error detection (PECERR)
1454 * SMBus Alert pin event detection (ALERT)
1455 * @rmtoll CR1 ERRIE LL_I2C_EnableIT_ERR
1456 * @param I2Cx I2C Instance.
1459 __STATIC_INLINE
void LL_I2C_EnableIT_ERR(I2C_TypeDef
*I2Cx
)
1461 SET_BIT(I2Cx
->CR1
, I2C_CR1_ERRIE
);
1465 * @brief Disable Error interrupts.
1466 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1467 * SMBus feature is supported by the I2Cx Instance.
1468 * @note Any of these errors will generate interrupt :
1469 * Arbitration Loss (ARLO)
1470 * Bus Error detection (BERR)
1471 * Overrun/Underrun (OVR)
1472 * SMBus Timeout detection (TIMEOUT)
1473 * SMBus PEC error detection (PECERR)
1474 * SMBus Alert pin event detection (ALERT)
1475 * @rmtoll CR1 ERRIE LL_I2C_DisableIT_ERR
1476 * @param I2Cx I2C Instance.
1479 __STATIC_INLINE
void LL_I2C_DisableIT_ERR(I2C_TypeDef
*I2Cx
)
1481 CLEAR_BIT(I2Cx
->CR1
, I2C_CR1_ERRIE
);
1485 * @brief Check if Error interrupts are enabled or disabled.
1486 * @rmtoll CR1 ERRIE LL_I2C_IsEnabledIT_ERR
1487 * @param I2Cx I2C Instance.
1488 * @retval State of bit (1 or 0).
1490 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef
*I2Cx
)
1492 return ((READ_BIT(I2Cx
->CR1
, I2C_CR1_ERRIE
) == (I2C_CR1_ERRIE
)) ? 1UL : 0UL);
1499 /** @defgroup I2C_LL_EF_FLAG_management FLAG_management
1504 * @brief Indicate the status of Transmit data register empty flag.
1505 * @note RESET: When next data is written in Transmit data register.
1506 * SET: When Transmit data register is empty.
1507 * @rmtoll ISR TXE LL_I2C_IsActiveFlag_TXE
1508 * @param I2Cx I2C Instance.
1509 * @retval State of bit (1 or 0).
1511 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef
*I2Cx
)
1513 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_TXE
) == (I2C_ISR_TXE
)) ? 1UL : 0UL);
1517 * @brief Indicate the status of Transmit interrupt flag.
1518 * @note RESET: When next data is written in Transmit data register.
1519 * SET: When Transmit data register is empty.
1520 * @rmtoll ISR TXIS LL_I2C_IsActiveFlag_TXIS
1521 * @param I2Cx I2C Instance.
1522 * @retval State of bit (1 or 0).
1524 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_TXIS(I2C_TypeDef
*I2Cx
)
1526 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_TXIS
) == (I2C_ISR_TXIS
)) ? 1UL : 0UL);
1530 * @brief Indicate the status of Receive data register not empty flag.
1531 * @note RESET: When Receive data register is read.
1532 * SET: When the received data is copied in Receive data register.
1533 * @rmtoll ISR RXNE LL_I2C_IsActiveFlag_RXNE
1534 * @param I2Cx I2C Instance.
1535 * @retval State of bit (1 or 0).
1537 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef
*I2Cx
)
1539 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_RXNE
) == (I2C_ISR_RXNE
)) ? 1UL : 0UL);
1543 * @brief Indicate the status of Address matched flag (slave mode).
1544 * @note RESET: Clear default value.
1545 * SET: When the received slave address matched with one of the enabled slave address.
1546 * @rmtoll ISR ADDR LL_I2C_IsActiveFlag_ADDR
1547 * @param I2Cx I2C Instance.
1548 * @retval State of bit (1 or 0).
1550 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_ADDR(I2C_TypeDef
*I2Cx
)
1552 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_ADDR
) == (I2C_ISR_ADDR
)) ? 1UL : 0UL);
1556 * @brief Indicate the status of Not Acknowledge received flag.
1557 * @note RESET: Clear default value.
1558 * SET: When a NACK is received after a byte transmission.
1559 * @rmtoll ISR NACKF LL_I2C_IsActiveFlag_NACK
1560 * @param I2Cx I2C Instance.
1561 * @retval State of bit (1 or 0).
1563 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_NACK(I2C_TypeDef
*I2Cx
)
1565 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_NACKF
) == (I2C_ISR_NACKF
)) ? 1UL : 0UL);
1569 * @brief Indicate the status of Stop detection flag.
1570 * @note RESET: Clear default value.
1571 * SET: When a Stop condition is detected.
1572 * @rmtoll ISR STOPF LL_I2C_IsActiveFlag_STOP
1573 * @param I2Cx I2C Instance.
1574 * @retval State of bit (1 or 0).
1576 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef
*I2Cx
)
1578 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_STOPF
) == (I2C_ISR_STOPF
)) ? 1UL : 0UL);
1582 * @brief Indicate the status of Transfer complete flag (master mode).
1583 * @note RESET: Clear default value.
1584 * SET: When RELOAD=0, AUTOEND=0 and NBYTES date have been transferred.
1585 * @rmtoll ISR TC LL_I2C_IsActiveFlag_TC
1586 * @param I2Cx I2C Instance.
1587 * @retval State of bit (1 or 0).
1589 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_TC(I2C_TypeDef
*I2Cx
)
1591 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_TC
) == (I2C_ISR_TC
)) ? 1UL : 0UL);
1595 * @brief Indicate the status of Transfer complete flag (master mode).
1596 * @note RESET: Clear default value.
1597 * SET: When RELOAD=1 and NBYTES date have been transferred.
1598 * @rmtoll ISR TCR LL_I2C_IsActiveFlag_TCR
1599 * @param I2Cx I2C Instance.
1600 * @retval State of bit (1 or 0).
1602 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_TCR(I2C_TypeDef
*I2Cx
)
1604 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_TCR
) == (I2C_ISR_TCR
)) ? 1UL : 0UL);
1608 * @brief Indicate the status of Bus error flag.
1609 * @note RESET: Clear default value.
1610 * SET: When a misplaced Start or Stop condition is detected.
1611 * @rmtoll ISR BERR LL_I2C_IsActiveFlag_BERR
1612 * @param I2Cx I2C Instance.
1613 * @retval State of bit (1 or 0).
1615 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_BERR(I2C_TypeDef
*I2Cx
)
1617 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_BERR
) == (I2C_ISR_BERR
)) ? 1UL : 0UL);
1621 * @brief Indicate the status of Arbitration lost flag.
1622 * @note RESET: Clear default value.
1623 * SET: When arbitration lost.
1624 * @rmtoll ISR ARLO LL_I2C_IsActiveFlag_ARLO
1625 * @param I2Cx I2C Instance.
1626 * @retval State of bit (1 or 0).
1628 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_ARLO(I2C_TypeDef
*I2Cx
)
1630 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_ARLO
) == (I2C_ISR_ARLO
)) ? 1UL : 0UL);
1634 * @brief Indicate the status of Overrun/Underrun flag (slave mode).
1635 * @note RESET: Clear default value.
1636 * SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
1637 * @rmtoll ISR OVR LL_I2C_IsActiveFlag_OVR
1638 * @param I2Cx I2C Instance.
1639 * @retval State of bit (1 or 0).
1641 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_OVR(I2C_TypeDef
*I2Cx
)
1643 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_OVR
) == (I2C_ISR_OVR
)) ? 1UL : 0UL);
1647 * @brief Indicate the status of SMBus PEC error flag in reception.
1648 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1649 * SMBus feature is supported by the I2Cx Instance.
1650 * @note RESET: Clear default value.
1651 * SET: When the received PEC does not match with the PEC register content.
1652 * @rmtoll ISR PECERR LL_I2C_IsActiveSMBusFlag_PECERR
1653 * @param I2Cx I2C Instance.
1654 * @retval State of bit (1 or 0).
1656 __STATIC_INLINE
uint32_t LL_I2C_IsActiveSMBusFlag_PECERR(I2C_TypeDef
*I2Cx
)
1658 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_PECERR
) == (I2C_ISR_PECERR
)) ? 1UL : 0UL);
1662 * @brief Indicate the status of SMBus Timeout detection flag.
1663 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1664 * SMBus feature is supported by the I2Cx Instance.
1665 * @note RESET: Clear default value.
1666 * SET: When a timeout or extended clock timeout occurs.
1667 * @rmtoll ISR TIMEOUT LL_I2C_IsActiveSMBusFlag_TIMEOUT
1668 * @param I2Cx I2C Instance.
1669 * @retval State of bit (1 or 0).
1671 __STATIC_INLINE
uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT(I2C_TypeDef
*I2Cx
)
1673 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_TIMEOUT
) == (I2C_ISR_TIMEOUT
)) ? 1UL : 0UL);
1677 * @brief Indicate the status of SMBus alert flag.
1678 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1679 * SMBus feature is supported by the I2Cx Instance.
1680 * @note RESET: Clear default value.
1681 * SET: When SMBus host configuration, SMBus alert enabled and
1682 * a falling edge event occurs on SMBA pin.
1683 * @rmtoll ISR ALERT LL_I2C_IsActiveSMBusFlag_ALERT
1684 * @param I2Cx I2C Instance.
1685 * @retval State of bit (1 or 0).
1687 __STATIC_INLINE
uint32_t LL_I2C_IsActiveSMBusFlag_ALERT(I2C_TypeDef
*I2Cx
)
1689 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_ALERT
) == (I2C_ISR_ALERT
)) ? 1UL : 0UL);
1693 * @brief Indicate the status of Bus Busy flag.
1694 * @note RESET: Clear default value.
1695 * SET: When a Start condition is detected.
1696 * @rmtoll ISR BUSY LL_I2C_IsActiveFlag_BUSY
1697 * @param I2Cx I2C Instance.
1698 * @retval State of bit (1 or 0).
1700 __STATIC_INLINE
uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef
*I2Cx
)
1702 return ((READ_BIT(I2Cx
->ISR
, I2C_ISR_BUSY
) == (I2C_ISR_BUSY
)) ? 1UL : 0UL);
1706 * @brief Clear Address Matched flag.
1707 * @rmtoll ICR ADDRCF LL_I2C_ClearFlag_ADDR
1708 * @param I2Cx I2C Instance.
1711 __STATIC_INLINE
void LL_I2C_ClearFlag_ADDR(I2C_TypeDef
*I2Cx
)
1713 SET_BIT(I2Cx
->ICR
, I2C_ICR_ADDRCF
);
1717 * @brief Clear Not Acknowledge flag.
1718 * @rmtoll ICR NACKCF LL_I2C_ClearFlag_NACK
1719 * @param I2Cx I2C Instance.
1722 __STATIC_INLINE
void LL_I2C_ClearFlag_NACK(I2C_TypeDef
*I2Cx
)
1724 SET_BIT(I2Cx
->ICR
, I2C_ICR_NACKCF
);
1728 * @brief Clear Stop detection flag.
1729 * @rmtoll ICR STOPCF LL_I2C_ClearFlag_STOP
1730 * @param I2Cx I2C Instance.
1733 __STATIC_INLINE
void LL_I2C_ClearFlag_STOP(I2C_TypeDef
*I2Cx
)
1735 SET_BIT(I2Cx
->ICR
, I2C_ICR_STOPCF
);
1739 * @brief Clear Transmit data register empty flag (TXE).
1740 * @note This bit can be clear by software in order to flush the transmit data register (TXDR).
1741 * @rmtoll ISR TXE LL_I2C_ClearFlag_TXE
1742 * @param I2Cx I2C Instance.
1745 __STATIC_INLINE
void LL_I2C_ClearFlag_TXE(I2C_TypeDef
*I2Cx
)
1747 WRITE_REG(I2Cx
->ISR
, I2C_ISR_TXE
);
1751 * @brief Clear Bus error flag.
1752 * @rmtoll ICR BERRCF LL_I2C_ClearFlag_BERR
1753 * @param I2Cx I2C Instance.
1756 __STATIC_INLINE
void LL_I2C_ClearFlag_BERR(I2C_TypeDef
*I2Cx
)
1758 SET_BIT(I2Cx
->ICR
, I2C_ICR_BERRCF
);
1762 * @brief Clear Arbitration lost flag.
1763 * @rmtoll ICR ARLOCF LL_I2C_ClearFlag_ARLO
1764 * @param I2Cx I2C Instance.
1767 __STATIC_INLINE
void LL_I2C_ClearFlag_ARLO(I2C_TypeDef
*I2Cx
)
1769 SET_BIT(I2Cx
->ICR
, I2C_ICR_ARLOCF
);
1773 * @brief Clear Overrun/Underrun flag.
1774 * @rmtoll ICR OVRCF LL_I2C_ClearFlag_OVR
1775 * @param I2Cx I2C Instance.
1778 __STATIC_INLINE
void LL_I2C_ClearFlag_OVR(I2C_TypeDef
*I2Cx
)
1780 SET_BIT(I2Cx
->ICR
, I2C_ICR_OVRCF
);
1784 * @brief Clear SMBus PEC error flag.
1785 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1786 * SMBus feature is supported by the I2Cx Instance.
1787 * @rmtoll ICR PECCF LL_I2C_ClearSMBusFlag_PECERR
1788 * @param I2Cx I2C Instance.
1791 __STATIC_INLINE
void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef
*I2Cx
)
1793 SET_BIT(I2Cx
->ICR
, I2C_ICR_PECCF
);
1797 * @brief Clear SMBus Timeout detection flag.
1798 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1799 * SMBus feature is supported by the I2Cx Instance.
1800 * @rmtoll ICR TIMOUTCF LL_I2C_ClearSMBusFlag_TIMEOUT
1801 * @param I2Cx I2C Instance.
1804 __STATIC_INLINE
void LL_I2C_ClearSMBusFlag_TIMEOUT(I2C_TypeDef
*I2Cx
)
1806 SET_BIT(I2Cx
->ICR
, I2C_ICR_TIMOUTCF
);
1810 * @brief Clear SMBus Alert flag.
1811 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
1812 * SMBus feature is supported by the I2Cx Instance.
1813 * @rmtoll ICR ALERTCF LL_I2C_ClearSMBusFlag_ALERT
1814 * @param I2Cx I2C Instance.
1817 __STATIC_INLINE
void LL_I2C_ClearSMBusFlag_ALERT(I2C_TypeDef
*I2Cx
)
1819 SET_BIT(I2Cx
->ICR
, I2C_ICR_ALERTCF
);
1826 /** @defgroup I2C_LL_EF_Data_Management Data_Management
1831 * @brief Enable automatic STOP condition generation (master mode).
1832 * @note Automatic end mode : a STOP condition is automatically sent when NBYTES data are transferred.
1833 * This bit has no effect in slave mode or when RELOAD bit is set.
1834 * @rmtoll CR2 AUTOEND LL_I2C_EnableAutoEndMode
1835 * @param I2Cx I2C Instance.
1838 __STATIC_INLINE
void LL_I2C_EnableAutoEndMode(I2C_TypeDef
*I2Cx
)
1840 SET_BIT(I2Cx
->CR2
, I2C_CR2_AUTOEND
);
1844 * @brief Disable automatic STOP condition generation (master mode).
1845 * @note Software end mode : TC flag is set when NBYTES data are transferre, stretching SCL low.
1846 * @rmtoll CR2 AUTOEND LL_I2C_DisableAutoEndMode
1847 * @param I2Cx I2C Instance.
1850 __STATIC_INLINE
void LL_I2C_DisableAutoEndMode(I2C_TypeDef
*I2Cx
)
1852 CLEAR_BIT(I2Cx
->CR2
, I2C_CR2_AUTOEND
);
1856 * @brief Check if automatic STOP condition is enabled or disabled.
1857 * @rmtoll CR2 AUTOEND LL_I2C_IsEnabledAutoEndMode
1858 * @param I2Cx I2C Instance.
1859 * @retval State of bit (1 or 0).
1861 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledAutoEndMode(I2C_TypeDef
*I2Cx
)
1863 return ((READ_BIT(I2Cx
->CR2
, I2C_CR2_AUTOEND
) == (I2C_CR2_AUTOEND
)) ? 1UL : 0UL);
1867 * @brief Enable reload mode (master mode).
1868 * @note The transfer is not completed after the NBYTES data transfer, NBYTES will be reloaded when TCR flag is set.
1869 * @rmtoll CR2 RELOAD LL_I2C_EnableReloadMode
1870 * @param I2Cx I2C Instance.
1873 __STATIC_INLINE
void LL_I2C_EnableReloadMode(I2C_TypeDef
*I2Cx
)
1875 SET_BIT(I2Cx
->CR2
, I2C_CR2_RELOAD
);
1879 * @brief Disable reload mode (master mode).
1880 * @note The transfer is completed after the NBYTES data transfer(STOP or RESTART will follow).
1881 * @rmtoll CR2 RELOAD LL_I2C_DisableReloadMode
1882 * @param I2Cx I2C Instance.
1885 __STATIC_INLINE
void LL_I2C_DisableReloadMode(I2C_TypeDef
*I2Cx
)
1887 CLEAR_BIT(I2Cx
->CR2
, I2C_CR2_RELOAD
);
1891 * @brief Check if reload mode is enabled or disabled.
1892 * @rmtoll CR2 RELOAD LL_I2C_IsEnabledReloadMode
1893 * @param I2Cx I2C Instance.
1894 * @retval State of bit (1 or 0).
1896 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledReloadMode(I2C_TypeDef
*I2Cx
)
1898 return ((READ_BIT(I2Cx
->CR2
, I2C_CR2_RELOAD
) == (I2C_CR2_RELOAD
)) ? 1UL : 0UL);
1902 * @brief Configure the number of bytes for transfer.
1903 * @note Changing these bits when START bit is set is not allowed.
1904 * @rmtoll CR2 NBYTES LL_I2C_SetTransferSize
1905 * @param I2Cx I2C Instance.
1906 * @param TransferSize This parameter must be a value between Min_Data=0x00 and Max_Data=0xFF.
1909 __STATIC_INLINE
void LL_I2C_SetTransferSize(I2C_TypeDef
*I2Cx
, uint32_t TransferSize
)
1911 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_NBYTES
, TransferSize
<< I2C_CR2_NBYTES_Pos
);
1915 * @brief Get the number of bytes configured for transfer.
1916 * @rmtoll CR2 NBYTES LL_I2C_GetTransferSize
1917 * @param I2Cx I2C Instance.
1918 * @retval Value between Min_Data=0x0 and Max_Data=0xFF
1920 __STATIC_INLINE
uint32_t LL_I2C_GetTransferSize(I2C_TypeDef
*I2Cx
)
1922 return (uint32_t)(READ_BIT(I2Cx
->CR2
, I2C_CR2_NBYTES
) >> I2C_CR2_NBYTES_Pos
);
1926 * @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
1927 * @note Usage in Slave mode only.
1928 * @rmtoll CR2 NACK LL_I2C_AcknowledgeNextData
1929 * @param I2Cx I2C Instance.
1930 * @param TypeAcknowledge This parameter can be one of the following values:
1931 * @arg @ref LL_I2C_ACK
1932 * @arg @ref LL_I2C_NACK
1935 __STATIC_INLINE
void LL_I2C_AcknowledgeNextData(I2C_TypeDef
*I2Cx
, uint32_t TypeAcknowledge
)
1937 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_NACK
, TypeAcknowledge
);
1941 * @brief Generate a START or RESTART condition
1942 * @note The START bit can be set even if bus is BUSY or I2C is in slave mode.
1943 * This action has no effect when RELOAD is set.
1944 * @rmtoll CR2 START LL_I2C_GenerateStartCondition
1945 * @param I2Cx I2C Instance.
1948 __STATIC_INLINE
void LL_I2C_GenerateStartCondition(I2C_TypeDef
*I2Cx
)
1950 SET_BIT(I2Cx
->CR2
, I2C_CR2_START
);
1954 * @brief Generate a STOP condition after the current byte transfer (master mode).
1955 * @rmtoll CR2 STOP LL_I2C_GenerateStopCondition
1956 * @param I2Cx I2C Instance.
1959 __STATIC_INLINE
void LL_I2C_GenerateStopCondition(I2C_TypeDef
*I2Cx
)
1961 SET_BIT(I2Cx
->CR2
, I2C_CR2_STOP
);
1965 * @brief Enable automatic RESTART Read request condition for 10bit address header (master mode).
1966 * @note The master sends the complete 10bit slave address read sequence :
1967 * Start + 2 bytes 10bit address in Write direction + Restart + first 7 bits of 10bit address in Read direction.
1968 * @rmtoll CR2 HEAD10R LL_I2C_EnableAuto10BitRead
1969 * @param I2Cx I2C Instance.
1972 __STATIC_INLINE
void LL_I2C_EnableAuto10BitRead(I2C_TypeDef
*I2Cx
)
1974 CLEAR_BIT(I2Cx
->CR2
, I2C_CR2_HEAD10R
);
1978 * @brief Disable automatic RESTART Read request condition for 10bit address header (master mode).
1979 * @note The master only sends the first 7 bits of 10bit address in Read direction.
1980 * @rmtoll CR2 HEAD10R LL_I2C_DisableAuto10BitRead
1981 * @param I2Cx I2C Instance.
1984 __STATIC_INLINE
void LL_I2C_DisableAuto10BitRead(I2C_TypeDef
*I2Cx
)
1986 SET_BIT(I2Cx
->CR2
, I2C_CR2_HEAD10R
);
1990 * @brief Check if automatic RESTART Read request condition for 10bit address header is enabled or disabled.
1991 * @rmtoll CR2 HEAD10R LL_I2C_IsEnabledAuto10BitRead
1992 * @param I2Cx I2C Instance.
1993 * @retval State of bit (1 or 0).
1995 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledAuto10BitRead(I2C_TypeDef
*I2Cx
)
1997 return ((READ_BIT(I2Cx
->CR2
, I2C_CR2_HEAD10R
) != (I2C_CR2_HEAD10R
)) ? 1UL : 0UL);
2001 * @brief Configure the transfer direction (master mode).
2002 * @note Changing these bits when START bit is set is not allowed.
2003 * @rmtoll CR2 RD_WRN LL_I2C_SetTransferRequest
2004 * @param I2Cx I2C Instance.
2005 * @param TransferRequest This parameter can be one of the following values:
2006 * @arg @ref LL_I2C_REQUEST_WRITE
2007 * @arg @ref LL_I2C_REQUEST_READ
2010 __STATIC_INLINE
void LL_I2C_SetTransferRequest(I2C_TypeDef
*I2Cx
, uint32_t TransferRequest
)
2012 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_RD_WRN
, TransferRequest
);
2016 * @brief Get the transfer direction requested (master mode).
2017 * @rmtoll CR2 RD_WRN LL_I2C_GetTransferRequest
2018 * @param I2Cx I2C Instance.
2019 * @retval Returned value can be one of the following values:
2020 * @arg @ref LL_I2C_REQUEST_WRITE
2021 * @arg @ref LL_I2C_REQUEST_READ
2023 __STATIC_INLINE
uint32_t LL_I2C_GetTransferRequest(I2C_TypeDef
*I2Cx
)
2025 return (uint32_t)(READ_BIT(I2Cx
->CR2
, I2C_CR2_RD_WRN
));
2029 * @brief Configure the slave address for transfer (master mode).
2030 * @note Changing these bits when START bit is set is not allowed.
2031 * @rmtoll CR2 SADD LL_I2C_SetSlaveAddr
2032 * @param I2Cx I2C Instance.
2033 * @param SlaveAddr This parameter must be a value between Min_Data=0x00 and Max_Data=0x3F.
2036 __STATIC_INLINE
void LL_I2C_SetSlaveAddr(I2C_TypeDef
*I2Cx
, uint32_t SlaveAddr
)
2038 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_SADD
, SlaveAddr
);
2042 * @brief Get the slave address programmed for transfer.
2043 * @rmtoll CR2 SADD LL_I2C_GetSlaveAddr
2044 * @param I2Cx I2C Instance.
2045 * @retval Value between Min_Data=0x0 and Max_Data=0x3F
2047 __STATIC_INLINE
uint32_t LL_I2C_GetSlaveAddr(I2C_TypeDef
*I2Cx
)
2049 return (uint32_t)(READ_BIT(I2Cx
->CR2
, I2C_CR2_SADD
));
2053 * @brief Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).
2054 * @rmtoll CR2 SADD LL_I2C_HandleTransfer\n
2055 * CR2 ADD10 LL_I2C_HandleTransfer\n
2056 * CR2 RD_WRN LL_I2C_HandleTransfer\n
2057 * CR2 START LL_I2C_HandleTransfer\n
2058 * CR2 STOP LL_I2C_HandleTransfer\n
2059 * CR2 RELOAD LL_I2C_HandleTransfer\n
2060 * CR2 NBYTES LL_I2C_HandleTransfer\n
2061 * CR2 AUTOEND LL_I2C_HandleTransfer\n
2062 * CR2 HEAD10R LL_I2C_HandleTransfer
2063 * @param I2Cx I2C Instance.
2064 * @param SlaveAddr Specifies the slave address to be programmed.
2065 * @param SlaveAddrSize This parameter can be one of the following values:
2066 * @arg @ref LL_I2C_ADDRSLAVE_7BIT
2067 * @arg @ref LL_I2C_ADDRSLAVE_10BIT
2068 * @param TransferSize Specifies the number of bytes to be programmed.
2069 * This parameter must be a value between Min_Data=0 and Max_Data=255.
2070 * @param EndMode This parameter can be one of the following values:
2071 * @arg @ref LL_I2C_MODE_RELOAD
2072 * @arg @ref LL_I2C_MODE_AUTOEND
2073 * @arg @ref LL_I2C_MODE_SOFTEND
2074 * @arg @ref LL_I2C_MODE_SMBUS_RELOAD
2075 * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC
2076 * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC
2077 * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_WITH_PEC
2078 * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_WITH_PEC
2079 * @param Request This parameter can be one of the following values:
2080 * @arg @ref LL_I2C_GENERATE_NOSTARTSTOP
2081 * @arg @ref LL_I2C_GENERATE_STOP
2082 * @arg @ref LL_I2C_GENERATE_START_READ
2083 * @arg @ref LL_I2C_GENERATE_START_WRITE
2084 * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_READ
2085 * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_WRITE
2086 * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_READ
2087 * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_WRITE
2090 __STATIC_INLINE
void LL_I2C_HandleTransfer(I2C_TypeDef
*I2Cx
, uint32_t SlaveAddr
, uint32_t SlaveAddrSize
,
2091 uint32_t TransferSize
, uint32_t EndMode
, uint32_t Request
)
2093 MODIFY_REG(I2Cx
->CR2
, I2C_CR2_SADD
| I2C_CR2_ADD10
| (I2C_CR2_RD_WRN
& (uint32_t)(Request
>> (31U - I2C_CR2_RD_WRN_Pos
))) | I2C_CR2_START
| I2C_CR2_STOP
| I2C_CR2_RELOAD
|
2094 I2C_CR2_NBYTES
| I2C_CR2_AUTOEND
| I2C_CR2_HEAD10R
,
2095 SlaveAddr
| SlaveAddrSize
| (TransferSize
<< I2C_CR2_NBYTES_Pos
) | EndMode
| Request
);
2099 * @brief Indicate the value of transfer direction (slave mode).
2100 * @note RESET: Write transfer, Slave enters in receiver mode.
2101 * SET: Read transfer, Slave enters in transmitter mode.
2102 * @rmtoll ISR DIR LL_I2C_GetTransferDirection
2103 * @param I2Cx I2C Instance.
2104 * @retval Returned value can be one of the following values:
2105 * @arg @ref LL_I2C_DIRECTION_WRITE
2106 * @arg @ref LL_I2C_DIRECTION_READ
2108 __STATIC_INLINE
uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef
*I2Cx
)
2110 return (uint32_t)(READ_BIT(I2Cx
->ISR
, I2C_ISR_DIR
));
2114 * @brief Return the slave matched address.
2115 * @rmtoll ISR ADDCODE LL_I2C_GetAddressMatchCode
2116 * @param I2Cx I2C Instance.
2117 * @retval Value between Min_Data=0x00 and Max_Data=0x3F
2119 __STATIC_INLINE
uint32_t LL_I2C_GetAddressMatchCode(I2C_TypeDef
*I2Cx
)
2121 return (uint32_t)(READ_BIT(I2Cx
->ISR
, I2C_ISR_ADDCODE
) >> I2C_ISR_ADDCODE_Pos
<< 1);
2125 * @brief Enable internal comparison of the SMBus Packet Error byte (transmission or reception mode).
2126 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
2127 * SMBus feature is supported by the I2Cx Instance.
2128 * @note This feature is cleared by hardware when the PEC byte is transferred, or when a STOP condition or an Address Matched is received.
2129 * This bit has no effect when RELOAD bit is set.
2130 * This bit has no effect in device mode when SBC bit is not set.
2131 * @rmtoll CR2 PECBYTE LL_I2C_EnableSMBusPECCompare
2132 * @param I2Cx I2C Instance.
2135 __STATIC_INLINE
void LL_I2C_EnableSMBusPECCompare(I2C_TypeDef
*I2Cx
)
2137 SET_BIT(I2Cx
->CR2
, I2C_CR2_PECBYTE
);
2141 * @brief Check if the SMBus Packet Error byte internal comparison is requested or not.
2142 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
2143 * SMBus feature is supported by the I2Cx Instance.
2144 * @rmtoll CR2 PECBYTE LL_I2C_IsEnabledSMBusPECCompare
2145 * @param I2Cx I2C Instance.
2146 * @retval State of bit (1 or 0).
2148 __STATIC_INLINE
uint32_t LL_I2C_IsEnabledSMBusPECCompare(I2C_TypeDef
*I2Cx
)
2150 return ((READ_BIT(I2Cx
->CR2
, I2C_CR2_PECBYTE
) == (I2C_CR2_PECBYTE
)) ? 1UL : 0UL);
2154 * @brief Get the SMBus Packet Error byte calculated.
2155 * @note Macro IS_SMBUS_ALL_INSTANCE(I2Cx) can be used to check whether or not
2156 * SMBus feature is supported by the I2Cx Instance.
2157 * @rmtoll PECR PEC LL_I2C_GetSMBusPEC
2158 * @param I2Cx I2C Instance.
2159 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
2161 __STATIC_INLINE
uint32_t LL_I2C_GetSMBusPEC(I2C_TypeDef
*I2Cx
)
2163 return (uint32_t)(READ_BIT(I2Cx
->PECR
, I2C_PECR_PEC
));
2167 * @brief Read Receive Data register.
2168 * @rmtoll RXDR RXDATA LL_I2C_ReceiveData8
2169 * @param I2Cx I2C Instance.
2170 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
2172 __STATIC_INLINE
uint8_t LL_I2C_ReceiveData8(I2C_TypeDef
*I2Cx
)
2174 return (uint8_t)(READ_BIT(I2Cx
->RXDR
, I2C_RXDR_RXDATA
));
2178 * @brief Write in Transmit Data Register .
2179 * @rmtoll TXDR TXDATA LL_I2C_TransmitData8
2180 * @param I2Cx I2C Instance.
2181 * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
2184 __STATIC_INLINE
void LL_I2C_TransmitData8(I2C_TypeDef
*I2Cx
, uint8_t Data
)
2186 WRITE_REG(I2Cx
->TXDR
, Data
);
2193 #if defined(USE_FULL_LL_DRIVER)
2194 /** @defgroup I2C_LL_EF_Init Initialization and de-initialization functions
2198 ErrorStatus
LL_I2C_Init(I2C_TypeDef
*I2Cx
, LL_I2C_InitTypeDef
*I2C_InitStruct
);
2199 ErrorStatus
LL_I2C_DeInit(I2C_TypeDef
*I2Cx
);
2200 void LL_I2C_StructInit(LL_I2C_InitTypeDef
*I2C_InitStruct
);
2206 #endif /* USE_FULL_LL_DRIVER */
2216 #endif /* I2C1 || I2C2 || I2C3 || I2C4 || I2C5 */
2226 #endif /* STM32H7xx_LL_I2C_H */
2228 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/