20 #ifndef __STM32F4xx_LL_I2C_H
21 #define __STM32F4xx_LL_I2C_H
28 #include "stm32f4xx.h"
34 #if defined (I2C1) || defined (I2C2) || defined (I2C3)
49 #define LL_I2C_MAX_SPEED_STANDARD 100000U
50 #define LL_I2C_MAX_SPEED_FAST 400000U
56 #if defined(USE_FULL_LL_DRIVER)
66 #if defined(USE_FULL_LL_DRIVER)
88 #if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
129 #define LL_I2C_SR1_SB I2C_SR1_SB
130 #define LL_I2C_SR1_ADDR I2C_SR1_ADDR
132 #define LL_I2C_SR1_BTF I2C_SR1_BTF
133 #define LL_I2C_SR1_ADD10 I2C_SR1_ADD10
134 #define LL_I2C_SR1_STOPF I2C_SR1_STOPF
135 #define LL_I2C_SR1_RXNE I2C_SR1_RXNE
136 #define LL_I2C_SR1_TXE I2C_SR1_TXE
137 #define LL_I2C_SR1_BERR I2C_SR1_BERR
138 #define LL_I2C_SR1_ARLO I2C_SR1_ARLO
139 #define LL_I2C_SR1_AF I2C_SR1_AF
140 #define LL_I2C_SR1_OVR I2C_SR1_OVR
141 #define LL_I2C_SR1_PECERR I2C_ISR_PECERR
142 #define LL_I2C_SR1_TIMEOUT I2C_ISR_TIMEOUT
143 #define LL_I2C_SR1_SMALERT I2C_ISR_SMALERT
144 #define LL_I2C_SR2_MSL I2C_SR2_MSL
145 #define LL_I2C_SR2_BUSY I2C_SR2_BUSY
146 #define LL_I2C_SR2_TRA I2C_SR2_TRA
147 #define LL_I2C_SR2_GENCALL I2C_SR2_GENCALL
148 #define LL_I2C_SR2_SMBDEFAULT I2C_SR2_SMBDEFAULT
149 #define LL_I2C_SR2_SMBHOST I2C_SR2_SMBHOST
150 #define LL_I2C_SR2_DUALF I2C_SR2_DUALF
159 #define LL_I2C_CR2_ITEVTEN I2C_CR2_ITEVTEN
160 #define LL_I2C_CR2_ITBUFEN I2C_CR2_ITBUFEN
161 #define LL_I2C_CR2_ITERREN I2C_CR2_ITERREN
166 #if defined(I2C_FLTR_ANOFF)
170 #define LL_I2C_ANALOGFILTER_ENABLE 0x00000000U
171 #define LL_I2C_ANALOGFILTER_DISABLE I2C_FLTR_ANOFF
180 #define LL_I2C_OWNADDRESS1_7BIT 0x00004000U
181 #define LL_I2C_OWNADDRESS1_10BIT (uint32_t)(I2C_OAR1_ADDMODE | 0x00004000U)
189 #define LL_I2C_DUTYCYCLE_2 0x00000000U
190 #define LL_I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
198 #define LL_I2C_CLOCK_SPEED_STANDARD_MODE 0x00000000U
199 #define LL_I2C_CLOCK_SPEED_FAST_MODE I2C_CCR_FS
207 #define LL_I2C_MODE_I2C 0x00000000U
208 #define LL_I2C_MODE_SMBUS_HOST (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP)
209 #define LL_I2C_MODE_SMBUS_DEVICE I2C_CR1_SMBUS
210 #define LL_I2C_MODE_SMBUS_DEVICE_ARP (uint32_t)(I2C_CR1_SMBUS | I2C_CR1_ENARP)
218 #define LL_I2C_ACK I2C_CR1_ACK
219 #define LL_I2C_NACK 0x00000000U
227 #define LL_I2C_DIRECTION_WRITE I2C_SR2_TRA
228 #define LL_I2C_DIRECTION_READ 0x00000000U
253 #define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
261 #define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
275 #define __LL_I2C_FREQ_HZ_TO_MHZ(__PCLK__) (uint32_t)((__PCLK__)/1000000U)
282 #define __LL_I2C_FREQ_MHZ_TO_HZ(__PCLK__) (uint32_t)((__PCLK__)*1000000U)
290 #define __LL_I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
301 #define __LL_I2C_SPEED_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__SPEED__) <= LL_I2C_MAX_SPEED_STANDARD)? \
302 (__LL_I2C_SPEED_STANDARD_TO_CCR((__PCLK__), (__SPEED__))) : \
303 (__LL_I2C_SPEED_FAST_TO_CCR((__PCLK__), (__SPEED__), (__DUTYCYCLE__))))
311 #define __LL_I2C_SPEED_STANDARD_TO_CCR(__PCLK__, __SPEED__) (uint32_t)(((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
322 #define __LL_I2C_SPEED_FAST_TO_CCR(__PCLK__, __SPEED__, __DUTYCYCLE__) (uint32_t)(((__DUTYCYCLE__) == LL_I2C_DUTYCYCLE_2)? \
323 (((((__PCLK__) / ((__SPEED__) * 3U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 3U))) : \
324 (((((__PCLK__) / ((__SPEED__) * 25U)) & I2C_CCR_CCR) == 0U)? 1U:((__PCLK__) / ((__SPEED__) * 25U))))
331 #define __LL_I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
338 #define __LL_I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF0))))
345 #define __LL_I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF1))))
373 SET_BIT(I2Cx->CR1, I2C_CR1_PE);
384 CLEAR_BIT(I2Cx->CR1, I2C_CR1_PE);
395 return (READ_BIT(I2Cx->CR1, I2C_CR1_PE) == (I2C_CR1_PE));
398 #if defined(I2C_FLTR_ANOFF)&&defined(I2C_FLTR_DNF)
415 MODIFY_REG(I2Cx->FLTR, I2C_FLTR_ANOFF | I2C_FLTR_DNF, AnalogFilter | DigitalFilter);
418 #if defined(I2C_FLTR_DNF)
432 MODIFY_REG(I2Cx->FLTR, I2C_FLTR_DNF, DigitalFilter);
443 return (uint32_t)(READ_BIT(I2Cx->FLTR, I2C_FLTR_DNF));
446 #if defined(I2C_FLTR_ANOFF)
457 CLEAR_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF);
469 SET_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF);
480 return (READ_BIT(I2Cx->FLTR, I2C_FLTR_ANOFF) == (I2C_FLTR_ANOFF));
492 SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
503 CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
514 return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
525 SET_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
536 CLEAR_BIT(I2Cx->CR2, I2C_CR2_DMAEN);
547 return (READ_BIT(I2Cx->CR2, I2C_CR2_DMAEN) == (I2C_CR2_DMAEN));
558 return (uint32_t) & (I2Cx->DR);
570 CLEAR_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
582 SET_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
593 return (READ_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH) != (I2C_CR1_NOSTRETCH));
605 SET_BIT(I2Cx->CR1, I2C_CR1_ENGC);
617 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ENGC);
628 return (READ_BIT(I2Cx->CR1, I2C_CR1_ENGC) == (I2C_CR1_ENGC));
646 MODIFY_REG(I2Cx->OAR1, I2C_OAR1_ADD0 | I2C_OAR1_ADD1_7 | I2C_OAR1_ADD8_9 | I2C_OAR1_ADDMODE, OwnAddress1 | OwnAddrSize);
659 MODIFY_REG(I2Cx->OAR2, I2C_OAR2_ADD2, OwnAddress2);
670 SET_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL);
681 CLEAR_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL);
692 return (READ_BIT(I2Cx->OAR2, I2C_OAR2_ENDUAL) == (I2C_OAR2_ENDUAL));
704 MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock));
715 return (uint32_t)(__LL_I2C_FREQ_MHZ_TO_HZ(READ_BIT(I2Cx->CR2, I2C_CR2_FREQ)));
729 MODIFY_REG(I2Cx->CCR, I2C_CCR_DUTY, DutyCycle);
742 return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_DUTY));
756 MODIFY_REG(I2Cx->CCR, I2C_CCR_FS, ClockSpeedMode);
769 return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_FS));
782 MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, RiseTime);
793 return (uint32_t)(READ_BIT(I2Cx->TRISE, I2C_TRISE_TRISE));
806 MODIFY_REG(I2Cx->CCR, I2C_CCR_CCR, ClockPeriod);
817 return (uint32_t)(READ_BIT(I2Cx->CCR, I2C_CCR_CCR));
836 __STATIC_INLINE
void LL_I2C_ConfigSpeed(I2C_TypeDef *I2Cx, uint32_t PeriphClock, uint32_t ClockSpeed,
839 uint32_t freqrange = 0x0U;
840 uint32_t clockconfig = 0x0U;
843 freqrange = __LL_I2C_FREQ_HZ_TO_MHZ(PeriphClock);
846 MODIFY_REG(I2Cx->CR2, I2C_CR2_FREQ, freqrange);
849 MODIFY_REG(I2Cx->TRISE, I2C_TRISE_TRISE, __LL_I2C_RISE_TIME(freqrange, ClockSpeed));
852 if (ClockSpeed > LL_I2C_MAX_SPEED_STANDARD)
855 clockconfig = LL_I2C_CLOCK_SPEED_FAST_MODE | \
856 __LL_I2C_SPEED_FAST_TO_CCR(PeriphClock, ClockSpeed, DutyCycle) | \
862 clockconfig = LL_I2C_CLOCK_SPEED_STANDARD_MODE | \
863 __LL_I2C_SPEED_STANDARD_TO_CCR(PeriphClock, ClockSpeed);
867 MODIFY_REG(I2Cx->CCR, (I2C_CCR_FS | I2C_CCR_DUTY | I2C_CCR_CCR), clockconfig);
887 MODIFY_REG(I2Cx->CR1, I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP, PeripheralMode);
906 return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_SMBUS | I2C_CR1_SMBTYPE | I2C_CR1_ENARP));
924 SET_BIT(I2Cx->CR1, I2C_CR1_ALERT);
942 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ALERT);
955 return (READ_BIT(I2Cx->CR1, I2C_CR1_ALERT) == (I2C_CR1_ALERT));
968 SET_BIT(I2Cx->CR1, I2C_CR1_ENPEC);
981 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ENPEC);
994 return (READ_BIT(I2Cx->CR1, I2C_CR1_ENPEC) == (I2C_CR1_ENPEC));
1014 SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
1026 CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
1038 return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
1050 SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
1062 CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN);
1074 return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN) == (I2C_CR2_ITEVTEN | I2C_CR2_ITBUFEN));
1095 SET_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
1114 CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN);
1125 return (READ_BIT(I2Cx->CR2, I2C_CR2_ITEVTEN) == (I2C_CR2_ITEVTEN));
1139 SET_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
1153 CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN);
1164 return (READ_BIT(I2Cx->CR2, I2C_CR2_ITBUFEN) == (I2C_CR2_ITBUFEN));
1185 SET_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
1206 CLEAR_BIT(I2Cx->CR2, I2C_CR2_ITERREN);
1217 return (READ_BIT(I2Cx->CR2, I2C_CR2_ITERREN) == (I2C_CR2_ITERREN));
1238 return (READ_BIT(I2Cx->SR1, I2C_SR1_TXE) == (I2C_SR1_TXE));
1251 return (READ_BIT(I2Cx->SR1, I2C_SR1_BTF) == (I2C_SR1_BTF));
1264 return (READ_BIT(I2Cx->SR1, I2C_SR1_RXNE) == (I2C_SR1_RXNE));
1277 return (READ_BIT(I2Cx->SR1, I2C_SR1_SB) == (I2C_SR1_SB));
1290 return (READ_BIT(I2Cx->SR1, I2C_SR1_ADDR) == (I2C_SR1_ADDR));
1303 return (READ_BIT(I2Cx->SR1, I2C_SR1_ADD10) == (I2C_SR1_ADD10));
1316 return (READ_BIT(I2Cx->SR1, I2C_SR1_AF) == (I2C_SR1_AF));
1329 return (READ_BIT(I2Cx->SR1, I2C_SR1_STOPF) == (I2C_SR1_STOPF));
1342 return (READ_BIT(I2Cx->SR1, I2C_SR1_BERR) == (I2C_SR1_BERR));
1355 return (READ_BIT(I2Cx->SR1, I2C_SR1_ARLO) == (I2C_SR1_ARLO));
1368 return (READ_BIT(I2Cx->SR1, I2C_SR1_OVR) == (I2C_SR1_OVR));
1381 return (READ_BIT(I2Cx->SR1, I2C_SR1_PECERR) == (I2C_SR1_PECERR));
1394 return (READ_BIT(I2Cx->SR1, I2C_SR1_TIMEOUT) == (I2C_SR1_TIMEOUT));
1407 return (READ_BIT(I2Cx->SR1, I2C_SR1_SMBALERT) == (I2C_SR1_SMBALERT));
1420 return (READ_BIT(I2Cx->SR2, I2C_SR2_BUSY) == (I2C_SR2_BUSY));
1433 return (READ_BIT(I2Cx->SR2, I2C_SR2_DUALF) == (I2C_SR2_DUALF));
1449 return (READ_BIT(I2Cx->SR2, I2C_SR2_SMBHOST) == (I2C_SR2_SMBHOST));
1465 return (READ_BIT(I2Cx->SR2, I2C_SR2_SMBDEFAULT) == (I2C_SR2_SMBDEFAULT));
1479 return (READ_BIT(I2Cx->SR2, I2C_SR2_GENCALL) == (I2C_SR2_GENCALL));
1492 return (READ_BIT(I2Cx->SR2, I2C_SR2_MSL) == (I2C_SR2_MSL));
1505 __IO uint32_t tmpreg;
1520 CLEAR_BIT(I2Cx->SR1, I2C_SR1_AF);
1534 __IO uint32_t tmpreg;
1537 SET_BIT(I2Cx->CR1, I2C_CR1_PE);
1548 CLEAR_BIT(I2Cx->SR1, I2C_SR1_BERR);
1559 CLEAR_BIT(I2Cx->SR1, I2C_SR1_ARLO);
1570 CLEAR_BIT(I2Cx->SR1, I2C_SR1_OVR);
1581 CLEAR_BIT(I2Cx->SR1, I2C_SR1_PECERR);
1594 CLEAR_BIT(I2Cx->SR1, I2C_SR1_TIMEOUT);
1607 CLEAR_BIT(I2Cx->SR1, I2C_SR1_SMBALERT);
1626 SET_BIT(I2Cx->CR1, I2C_CR1_SWRST);
1637 CLEAR_BIT(I2Cx->CR1, I2C_CR1_SWRST);
1648 return (READ_BIT(I2Cx->CR1, I2C_CR1_SWRST) == (I2C_CR1_SWRST));
1663 MODIFY_REG(I2Cx->CR1, I2C_CR1_ACK, TypeAcknowledge);
1676 SET_BIT(I2Cx->CR1, I2C_CR1_START);
1687 SET_BIT(I2Cx->CR1, I2C_CR1_STOP);
1699 SET_BIT(I2Cx->CR1, I2C_CR1_POS);
1711 CLEAR_BIT(I2Cx->CR1, I2C_CR1_POS);
1722 return (READ_BIT(I2Cx->CR1, I2C_CR1_POS) == (I2C_CR1_POS));
1737 return (uint32_t)(READ_BIT(I2Cx->SR2, I2C_SR2_TRA));
1749 SET_BIT(I2Cx->CR2, I2C_CR2_LAST);
1761 CLEAR_BIT(I2Cx->CR2, I2C_CR2_LAST);
1772 return (READ_BIT(I2Cx->CR2, I2C_CR2_LAST) == (I2C_CR2_LAST));
1787 SET_BIT(I2Cx->CR1, I2C_CR1_PEC);
1800 CLEAR_BIT(I2Cx->CR1, I2C_CR1_PEC);
1813 return (READ_BIT(I2Cx->CR1, I2C_CR1_PEC) == (I2C_CR1_PEC));
1826 return (uint32_t)(READ_BIT(I2Cx->SR2, I2C_SR2_PEC) >> I2C_SR2_PEC_Pos);
1837 return (uint8_t)(READ_BIT(I2Cx->DR, I2C_DR_DR));
1849 MODIFY_REG(I2Cx->DR, I2C_DR_DR, Data);
1856 #if defined(USE_FULL_LL_DRIVER)
__STATIC_INLINE void LL_I2C_DisableDMAReq_TX(I2C_TypeDef *I2Cx)
Disable DMA transmission requests. @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_TX.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef *I2Cx)
Check if DMA reception requests are enabled or disabled. @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_RX.
__STATIC_INLINE void LL_I2C_EnableDMAReq_RX(I2C_TypeDef *I2Cx)
Enable DMA reception requests. @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_RX.
__STATIC_INLINE void LL_I2C_SetDigitalFilter(I2C_TypeDef *I2Cx, uint32_t DigitalFilter)
Configure Digital Noise Filter.
__STATIC_INLINE uint32_t LL_I2C_GetDutyCycle(I2C_TypeDef *I2Cx)
Get the Duty cycle (Fast mode only). @rmtoll CCR DUTY LL_I2C_GetDutyCycle.
__STATIC_INLINE uint32_t LL_I2C_GetMode(I2C_TypeDef *I2Cx)
Get peripheral mode.
__STATIC_INLINE void LL_I2C_EnableOwnAddress2(I2C_TypeDef *I2Cx)
Enable acknowledge on Own Address2 match address. @rmtoll OAR2 ENDUAL LL_I2C_EnableOwnAddress2.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef *I2Cx)
Check if General Call is enabled or disabled. @rmtoll CR1 ENGC LL_I2C_IsEnabledGeneralCall.
__STATIC_INLINE void LL_I2C_SetOwnAddress2(I2C_TypeDef *I2Cx, uint32_t OwnAddress2)
Set the 7bits Own Address2.
__STATIC_INLINE void LL_I2C_Disable(I2C_TypeDef *I2Cx)
Disable I2C peripheral (PE = 0). @rmtoll CR1 PE LL_I2C_Disable.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledAnalogFilter(I2C_TypeDef *I2Cx)
Check if Analog Noise Filter is enabled or disabled. @rmtoll FLTR ANOFF LL_I2C_IsEnabledAnalogFilter.
__STATIC_INLINE void LL_I2C_DisableOwnAddress2(I2C_TypeDef *I2Cx)
Disable acknowledge on Own Address2 match address. @rmtoll OAR2 ENDUAL LL_I2C_DisableOwnAddress2.
__STATIC_INLINE void LL_I2C_ConfigFilters(I2C_TypeDef *I2Cx, uint32_t AnalogFilter, uint32_t DigitalFilter)
Configure Noise Filters (Analog and Digital).
__STATIC_INLINE void LL_I2C_EnableGeneralCall(I2C_TypeDef *I2Cx)
Enable General Call.
__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_DisableSMBusAlert(I2C_TypeDef *I2Cx)
Disable SMBus alert (Host or Device mode)
__STATIC_INLINE void LL_I2C_DisableSMBusPEC(I2C_TypeDef *I2Cx)
Disable SMBus Packet Error Calculation (PEC).
__STATIC_INLINE void LL_I2C_EnableSMBusPEC(I2C_TypeDef *I2Cx)
Enable SMBus Packet Error Calculation (PEC).
__STATIC_INLINE void LL_I2C_DisableAnalogFilter(I2C_TypeDef *I2Cx)
Disable Analog Noise Filter.
__STATIC_INLINE void LL_I2C_DisableGeneralCall(I2C_TypeDef *I2Cx)
Disable General Call.
__STATIC_INLINE void LL_I2C_SetDutyCycle(I2C_TypeDef *I2Cx, uint32_t DutyCycle)
Configure the Duty cycle (Fast mode only). @rmtoll CCR DUTY LL_I2C_SetDutyCycle.
__STATIC_INLINE void LL_I2C_Enable(I2C_TypeDef *I2Cx)
Enable I2C peripheral (PE = 1). @rmtoll CR1 PE LL_I2C_Enable.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress2(I2C_TypeDef *I2Cx)
Check if Own Address1 acknowledge is enabled or disabled. @rmtoll OAR2 ENDUAL LL_I2C_IsEnabledOwnAddr...
__STATIC_INLINE void LL_I2C_DisableClockStretching(I2C_TypeDef *I2Cx)
Disable Clock stretching.
__STATIC_INLINE uint32_t LL_I2C_IsEnabled(I2C_TypeDef *I2Cx)
Check if the I2C peripheral is enabled or disabled. @rmtoll CR1 PE LL_I2C_IsEnabled.
__STATIC_INLINE uint32_t LL_I2C_GetDigitalFilter(I2C_TypeDef *I2Cx)
Get the current Digital Noise Filter configuration. @rmtoll FLTR DNF LL_I2C_GetDigitalFilter.
__STATIC_INLINE void LL_I2C_DisableDMAReq_RX(I2C_TypeDef *I2Cx)
Disable DMA reception requests. @rmtoll CR2 DMAEN LL_I2C_DisableDMAReq_RX.
__STATIC_INLINE uint32_t LL_I2C_GetRiseTime(I2C_TypeDef *I2Cx)
Get the SCL, SDA rising time. @rmtoll TRISE TRISE LL_I2C_GetRiseTime.
__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_EnableDMAReq_TX(I2C_TypeDef *I2Cx)
Enable DMA transmission requests. @rmtoll CR2 DMAEN LL_I2C_EnableDMAReq_TX.
__STATIC_INLINE void LL_I2C_SetMode(I2C_TypeDef *I2Cx, uint32_t PeripheralMode)
Configure peripheral mode.
__STATIC_INLINE void LL_I2C_EnableAnalogFilter(I2C_TypeDef *I2Cx)
Enable Analog Noise Filter.
__STATIC_INLINE void LL_I2C_EnableClockStretching(I2C_TypeDef *I2Cx)
Enable Clock stretching.
__STATIC_INLINE void LL_I2C_SetClockSpeedMode(I2C_TypeDef *I2Cx, uint32_t ClockSpeedMode)
Configure the I2C master clock speed mode. @rmtoll CCR FS LL_I2C_SetClockSpeedMode.
__STATIC_INLINE uint32_t LL_I2C_GetPeriphClock(I2C_TypeDef *I2Cx)
Get the Peripheral clock frequency. @rmtoll CR2 FREQ LL_I2C_GetPeriphClock.
__STATIC_INLINE uint32_t LL_I2C_GetClockPeriod(I2C_TypeDef *I2Cx)
Get the SCL high and low period. @rmtoll CCR CCR LL_I2C_GetClockPeriod.
__STATIC_INLINE void LL_I2C_SetRiseTime(I2C_TypeDef *I2Cx, uint32_t RiseTime)
Configure the SCL, SDA rising time.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef *I2Cx)
Check if DMA transmission requests are enabled or disabled. @rmtoll CR2 DMAEN LL_I2C_IsEnabledDMAReq_...
__STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef *I2Cx)
Get the data register address used for DMA transfer. @rmtoll DR DR LL_I2C_DMA_GetRegAddr.
__STATIC_INLINE void LL_I2C_SetOwnAddress1(I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
Set the Own Address1. @rmtoll OAR1 ADD0 LL_I2C_SetOwnAddress1 OAR1 ADD1_7 LL_I2C_SetOwnAddress1 OAR...
__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_EnableSMBusAlert(I2C_TypeDef *I2Cx)
Enable SMBus alert (Host or Device mode)
__STATIC_INLINE void LL_I2C_SetPeriphClock(I2C_TypeDef *I2Cx, uint32_t PeriphClock)
Configure the Peripheral clock frequency. @rmtoll CR2 FREQ LL_I2C_SetPeriphClock.
__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_IsEnabledClockStretching(I2C_TypeDef *I2Cx)
Check if Clock stretching is enabled or disabled. @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretchi...
__STATIC_INLINE uint32_t LL_I2C_GetClockSpeedMode(I2C_TypeDef *I2Cx)
Get the the I2C master speed mode. @rmtoll CCR FS LL_I2C_GetClockSpeedMode.
__STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx)
Read Receive Data register. @rmtoll DR DR LL_I2C_ReceiveData8.
__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 uint32_t LL_I2C_IsEnabledLastDMA(I2C_TypeDef *I2Cx)
Check if DMA last transfer is enabled or disabled. @rmtoll CR2 LAST LL_I2C_IsEnabledLastDMA.
__STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data)
Write in Transmit Data Register . @rmtoll DR DR LL_I2C_TransmitData8.
__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 ...
__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_IsEnabledBitPOS(I2C_TypeDef *I2Cx)
Check if bit POS is enabled or disabled. @rmtoll CR1 POS LL_I2C_IsEnabledBitPOS.
__STATIC_INLINE void LL_I2C_EnableBitPOS(I2C_TypeDef *I2Cx)
Enable bit POS (master/host mode).
__STATIC_INLINE uint32_t LL_I2C_IsResetEnabled(I2C_TypeDef *I2Cx)
Check if the I2C peripheral is under reset state or not. @rmtoll CR1 SWRST LL_I2C_IsResetEnabled.
__STATIC_INLINE void LL_I2C_DisableSMBusPECCompare(I2C_TypeDef *I2Cx)
Disable transfer or internal comparison of the SMBus Packet Error byte (transmission or reception mod...
__STATIC_INLINE void LL_I2C_GenerateStartCondition(I2C_TypeDef *I2Cx)
Generate a START or RESTART condition.
__STATIC_INLINE void LL_I2C_DisableBitPOS(I2C_TypeDef *I2Cx)
Disable bit POS (master/host mode).
__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 void LL_I2C_EnableReset(I2C_TypeDef *I2Cx)
Enable Reset of I2C peripheral. @rmtoll CR1 SWRST LL_I2C_EnableReset.
__STATIC_INLINE void LL_I2C_GenerateStopCondition(I2C_TypeDef *I2Cx)
Generate a STOP condition after the current byte transfer (master mode). @rmtoll CR1 STOP LL_I2C_Gene...
__STATIC_INLINE void LL_I2C_DisableReset(I2C_TypeDef *I2Cx)
Disable Reset of I2C peripheral. @rmtoll CR1 SWRST LL_I2C_DisableReset.
__STATIC_INLINE uint32_t LL_I2C_GetSMBusPEC(I2C_TypeDef *I2Cx)
Get the SMBus Packet Error byte calculated.
__STATIC_INLINE uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
Indicate the value of transfer direction.
__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_SB(I2C_TypeDef *I2Cx)
Indicate the status of Start Bit (master mode).
__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_TXE(I2C_TypeDef *I2Cx)
Indicate the status of Transmit data register empty 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_MSL(I2C_TypeDef *I2Cx)
Indicate the status of Master/Slave flag.
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
Clear SMBus Timeout detection flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_DUAL(I2C_TypeDef *I2Cx)
Indicate the status of Dual flag.
__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_ADDR(I2C_TypeDef *I2Cx)
Indicate the status of Address sent (master mode) or Address matched flag (slave mode).
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
Clear SMBus Alert flag.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef *I2Cx)
Indicate the status of Bus Busy flag.
__STATIC_INLINE void LL_I2C_ClearFlag_BERR(I2C_TypeDef *I2Cx)
Clear Bus error flag. @rmtoll SR1 BERR LL_I2C_ClearFlag_BERR.
__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_ADD10(I2C_TypeDef *I2Cx)
Indicate the status of 10-bit header sent (master mode).
__STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
Clear SMBus PEC error flag. @rmtoll SR1 PECERR LL_I2C_ClearSMBusFlag_PECERR.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_AF(I2C_TypeDef *I2Cx)
Indicate the status of Acknowledge failure 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_IsActiveFlag_GENCALL(I2C_TypeDef *I2Cx)
Indicate the status of General call address reception (Slave mode).
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx)
Indicate the status of Receive data register not empty flag.
__STATIC_INLINE void LL_I2C_ClearFlag_AF(I2C_TypeDef *I2Cx)
Clear Acknowledge failure flag. @rmtoll SR1 AF LL_I2C_ClearFlag_AF.
__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_SMBHOST(I2C_TypeDef *I2Cx)
Indicate the status of SMBus Host address reception (Slave mode).
__STATIC_INLINE void LL_I2C_ClearFlag_ARLO(I2C_TypeDef *I2Cx)
Clear Arbitration lost flag. @rmtoll SR1 ARLO LL_I2C_ClearFlag_ARLO.
__STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BTF(I2C_TypeDef *I2Cx)
Indicate the status of Byte Transfer Finished flag. RESET: When Data byte transfer not done....
__STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx)
Clear Stop detection flag.
__STATIC_INLINE void LL_I2C_ClearFlag_ADDR(I2C_TypeDef *I2Cx)
Clear Address Matched flag.
__STATIC_INLINE void LL_I2C_ClearFlag_OVR(I2C_TypeDef *I2Cx)
Clear Overrun/Underrun flag. @rmtoll SR1 OVR LL_I2C_ClearFlag_OVR.
__STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
Indicate the status of SMBus Timeout detection flag.
__STATIC_INLINE void LL_I2C_DisableIT_ERR(I2C_TypeDef *I2Cx)
Disable Error interrupts.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef *I2Cx)
Check if the TXE Interrupt is enabled or disabled. @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_TX CR2 ITB...
__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_RX(I2C_TypeDef *I2Cx)
Check if the RXNE Interrupt is enabled or disabled. @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_RX CR2 IT...
__STATIC_INLINE void LL_I2C_EnableIT_TX(I2C_TypeDef *I2Cx)
Enable TXE interrupt. @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_TX CR2 ITBUFEN LL_I2C_EnableIT_TX.
__STATIC_INLINE void LL_I2C_EnableIT_RX(I2C_TypeDef *I2Cx)
Enable RXNE interrupt. @rmtoll CR2 ITEVTEN LL_I2C_EnableIT_RX CR2 ITBUFEN LL_I2C_EnableIT_RX.
__STATIC_INLINE void LL_I2C_DisableIT_EVT(I2C_TypeDef *I2Cx)
Disable Events interrupts.
__STATIC_INLINE void LL_I2C_DisableIT_TX(I2C_TypeDef *I2Cx)
Disable TXE interrupt. @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_TX CR2 ITBUFEN LL_I2C_DisableIT_TX.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_BUF(I2C_TypeDef *I2Cx)
Check if Buffer interrupts are enabled or disabled. @rmtoll CR2 ITBUFEN LL_I2C_IsEnabledIT_BUF.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef *I2Cx)
Check if Error interrupts are enabled or disabled. @rmtoll CR2 ITERREN LL_I2C_IsEnabledIT_ERR.
__STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_EVT(I2C_TypeDef *I2Cx)
Check if Events interrupts are enabled or disabled. @rmtoll CR2 ITEVTEN LL_I2C_IsEnabledIT_EVT.
__STATIC_INLINE void LL_I2C_DisableIT_RX(I2C_TypeDef *I2Cx)
Disable RXNE interrupt. @rmtoll CR2 ITEVTEN LL_I2C_DisableIT_RX CR2 ITBUFEN LL_I2C_DisableIT_RX.
__STATIC_INLINE void LL_I2C_EnableIT_ERR(I2C_TypeDef *I2Cx)
Enable Error interrupts.
__STATIC_INLINE void LL_I2C_EnableIT_EVT(I2C_TypeDef *I2Cx)
Enable Events interrupts.
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.
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.