mbed library sources. Supersedes mbed-src.

Dependents:   Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more

Committer:
AnnaBridge
Date:
Wed Feb 20 22:31:08 2019 +0000
Revision:
189:f392fc9709a3
Parent:
186:707f6e361f3e
mbed library release version 165

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 158:b23ee177fd68 1 /**
Kojto 158:b23ee177fd68 2 ******************************************************************************
Kojto 158:b23ee177fd68 3 * @file stm32l0xx_ll_i2c.h
Kojto 158:b23ee177fd68 4 * @author MCD Application Team
Kojto 158:b23ee177fd68 5 * @brief Header file of I2C LL module.
Kojto 158:b23ee177fd68 6 ******************************************************************************
Kojto 158:b23ee177fd68 7 * @attention
Kojto 158:b23ee177fd68 8 *
Kojto 158:b23ee177fd68 9 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 158:b23ee177fd68 10 *
Kojto 158:b23ee177fd68 11 * Redistribution and use in source and binary forms, with or without modification,
Kojto 158:b23ee177fd68 12 * are permitted provided that the following conditions are met:
Kojto 158:b23ee177fd68 13 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 158:b23ee177fd68 14 * this list of conditions and the following disclaimer.
Kojto 158:b23ee177fd68 15 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 158:b23ee177fd68 16 * this list of conditions and the following disclaimer in the documentation
Kojto 158:b23ee177fd68 17 * and/or other materials provided with the distribution.
Kojto 158:b23ee177fd68 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 158:b23ee177fd68 19 * may be used to endorse or promote products derived from this software
Kojto 158:b23ee177fd68 20 * without specific prior written permission.
Kojto 158:b23ee177fd68 21 *
Kojto 158:b23ee177fd68 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 158:b23ee177fd68 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 158:b23ee177fd68 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 158:b23ee177fd68 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 158:b23ee177fd68 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 158:b23ee177fd68 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 158:b23ee177fd68 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 158:b23ee177fd68 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 158:b23ee177fd68 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 158:b23ee177fd68 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 158:b23ee177fd68 32 *
Kojto 158:b23ee177fd68 33 ******************************************************************************
Kojto 158:b23ee177fd68 34 */
Kojto 158:b23ee177fd68 35
Kojto 158:b23ee177fd68 36 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 158:b23ee177fd68 37 #ifndef __STM32L0xx_LL_I2C_H
Kojto 158:b23ee177fd68 38 #define __STM32L0xx_LL_I2C_H
Kojto 158:b23ee177fd68 39
Kojto 158:b23ee177fd68 40 #ifdef __cplusplus
Kojto 158:b23ee177fd68 41 extern "C" {
Kojto 158:b23ee177fd68 42 #endif
Kojto 158:b23ee177fd68 43
Kojto 158:b23ee177fd68 44 /* Includes ------------------------------------------------------------------*/
Kojto 158:b23ee177fd68 45 #include "stm32l0xx.h"
Kojto 158:b23ee177fd68 46
Kojto 158:b23ee177fd68 47 /** @addtogroup STM32L0xx_LL_Driver
Kojto 158:b23ee177fd68 48 * @{
Kojto 158:b23ee177fd68 49 */
Kojto 158:b23ee177fd68 50
Kojto 158:b23ee177fd68 51 #if defined (I2C1) || defined (I2C2) || defined (I2C3)
Kojto 158:b23ee177fd68 52
Kojto 158:b23ee177fd68 53 /** @defgroup I2C_LL I2C
Kojto 158:b23ee177fd68 54 * @{
Kojto 158:b23ee177fd68 55 */
Kojto 158:b23ee177fd68 56
Kojto 158:b23ee177fd68 57 /* Private types -------------------------------------------------------------*/
Kojto 158:b23ee177fd68 58 /* Private variables ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 59
Kojto 158:b23ee177fd68 60 /* Private constants ---------------------------------------------------------*/
Kojto 158:b23ee177fd68 61 /** @defgroup I2C_LL_Private_Constants I2C Private Constants
Kojto 158:b23ee177fd68 62 * @{
Kojto 158:b23ee177fd68 63 */
Kojto 158:b23ee177fd68 64 /**
Kojto 158:b23ee177fd68 65 * @}
Kojto 158:b23ee177fd68 66 */
Kojto 158:b23ee177fd68 67
Kojto 158:b23ee177fd68 68 /* Private macros ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 69 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 70 /** @defgroup I2C_LL_Private_Macros I2C Private Macros
Kojto 158:b23ee177fd68 71 * @{
Kojto 158:b23ee177fd68 72 */
Kojto 158:b23ee177fd68 73 /**
Kojto 158:b23ee177fd68 74 * @}
Kojto 158:b23ee177fd68 75 */
Kojto 158:b23ee177fd68 76 #endif /*USE_FULL_LL_DRIVER*/
Kojto 158:b23ee177fd68 77
Kojto 158:b23ee177fd68 78 /* Exported types ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 79 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 80 /** @defgroup I2C_LL_ES_INIT I2C Exported Init structure
Kojto 158:b23ee177fd68 81 * @{
Kojto 158:b23ee177fd68 82 */
Kojto 158:b23ee177fd68 83 typedef struct
Kojto 158:b23ee177fd68 84 {
Kojto 158:b23ee177fd68 85 uint32_t PeripheralMode; /*!< Specifies the peripheral mode.
Kojto 158:b23ee177fd68 86 This parameter can be a value of @ref I2C_LL_EC_PERIPHERAL_MODE
Kojto 158:b23ee177fd68 87
Kojto 158:b23ee177fd68 88 This feature can be modified afterwards using unitary function @ref LL_I2C_SetMode(). */
Kojto 158:b23ee177fd68 89
Kojto 158:b23ee177fd68 90 uint32_t Timing; /*!< Specifies the SDA setup, hold time and the SCL high, low period values.
Kojto 158:b23ee177fd68 91 This parameter must be set by referring to the STM32CubeMX Tool and
Kojto 158:b23ee177fd68 92 the helper macro @ref __LL_I2C_CONVERT_TIMINGS()
Kojto 158:b23ee177fd68 93
Kojto 158:b23ee177fd68 94 This feature can be modified afterwards using unitary function @ref LL_I2C_SetTiming(). */
Kojto 158:b23ee177fd68 95
Kojto 158:b23ee177fd68 96 uint32_t AnalogFilter; /*!< Enables or disables analog noise filter.
Kojto 158:b23ee177fd68 97 This parameter can be a value of @ref I2C_LL_EC_ANALOGFILTER_SELECTION
Kojto 158:b23ee177fd68 98
Kojto 158:b23ee177fd68 99 This feature can be modified afterwards using unitary functions @ref LL_I2C_EnableAnalogFilter() or LL_I2C_DisableAnalogFilter(). */
Kojto 158:b23ee177fd68 100
Kojto 158:b23ee177fd68 101 uint32_t DigitalFilter; /*!< Configures the digital noise filter.
Kojto 158:b23ee177fd68 102 This parameter can be a number between Min_Data = 0x00 and Max_Data = 0x0F
Kojto 158:b23ee177fd68 103
Kojto 158:b23ee177fd68 104 This feature can be modified afterwards using unitary function @ref LL_I2C_SetDigitalFilter(). */
Kojto 158:b23ee177fd68 105
Kojto 158:b23ee177fd68 106 uint32_t OwnAddress1; /*!< Specifies the device own address 1.
Kojto 158:b23ee177fd68 107 This parameter must be a value between Min_Data = 0x00 and Max_Data = 0x3FF
Kojto 158:b23ee177fd68 108
Kojto 158:b23ee177fd68 109 This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
Kojto 158:b23ee177fd68 110
Kojto 158:b23ee177fd68 111 uint32_t TypeAcknowledge; /*!< Specifies the ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
Kojto 158:b23ee177fd68 112 This parameter can be a value of @ref I2C_LL_EC_I2C_ACKNOWLEDGE
Kojto 158:b23ee177fd68 113
Kojto 158:b23ee177fd68 114 This feature can be modified afterwards using unitary function @ref LL_I2C_AcknowledgeNextData(). */
Kojto 158:b23ee177fd68 115
Kojto 158:b23ee177fd68 116 uint32_t OwnAddrSize; /*!< Specifies the device own address 1 size (7-bit or 10-bit).
Kojto 158:b23ee177fd68 117 This parameter can be a value of @ref I2C_LL_EC_OWNADDRESS1
Kojto 158:b23ee177fd68 118
Kojto 158:b23ee177fd68 119 This feature can be modified afterwards using unitary function @ref LL_I2C_SetOwnAddress1(). */
Kojto 158:b23ee177fd68 120 } LL_I2C_InitTypeDef;
Kojto 158:b23ee177fd68 121 /**
Kojto 158:b23ee177fd68 122 * @}
Kojto 158:b23ee177fd68 123 */
Kojto 158:b23ee177fd68 124 #endif /*USE_FULL_LL_DRIVER*/
Kojto 158:b23ee177fd68 125
Kojto 158:b23ee177fd68 126 /* Exported constants --------------------------------------------------------*/
Kojto 158:b23ee177fd68 127 /** @defgroup I2C_LL_Exported_Constants I2C Exported Constants
Kojto 158:b23ee177fd68 128 * @{
Kojto 158:b23ee177fd68 129 */
Kojto 158:b23ee177fd68 130
Kojto 158:b23ee177fd68 131 /** @defgroup I2C_LL_EC_CLEAR_FLAG Clear Flags Defines
Kojto 158:b23ee177fd68 132 * @brief Flags defines which can be used with LL_I2C_WriteReg function
Kojto 158:b23ee177fd68 133 * @{
Kojto 158:b23ee177fd68 134 */
Kojto 158:b23ee177fd68 135 #define LL_I2C_ICR_ADDRCF I2C_ICR_ADDRCF /*!< Address Matched flag */
Kojto 158:b23ee177fd68 136 #define LL_I2C_ICR_NACKCF I2C_ICR_NACKCF /*!< Not Acknowledge flag */
Kojto 158:b23ee177fd68 137 #define LL_I2C_ICR_STOPCF I2C_ICR_STOPCF /*!< Stop detection flag */
Kojto 158:b23ee177fd68 138 #define LL_I2C_ICR_BERRCF I2C_ICR_BERRCF /*!< Bus error flag */
Kojto 158:b23ee177fd68 139 #define LL_I2C_ICR_ARLOCF I2C_ICR_ARLOCF /*!< Arbitration Lost flag */
Kojto 158:b23ee177fd68 140 #define LL_I2C_ICR_OVRCF I2C_ICR_OVRCF /*!< Overrun/Underrun flag */
Kojto 158:b23ee177fd68 141 #define LL_I2C_ICR_PECCF I2C_ICR_PECCF /*!< PEC error flag */
Kojto 158:b23ee177fd68 142 #define LL_I2C_ICR_TIMOUTCF I2C_ICR_TIMOUTCF /*!< Timeout detection flag */
Kojto 158:b23ee177fd68 143 #define LL_I2C_ICR_ALERTCF I2C_ICR_ALERTCF /*!< Alert flag */
Kojto 158:b23ee177fd68 144 /**
Kojto 158:b23ee177fd68 145 * @}
Kojto 158:b23ee177fd68 146 */
Kojto 158:b23ee177fd68 147
Kojto 158:b23ee177fd68 148 /** @defgroup I2C_LL_EC_GET_FLAG Get Flags Defines
Kojto 158:b23ee177fd68 149 * @brief Flags defines which can be used with LL_I2C_ReadReg function
Kojto 158:b23ee177fd68 150 * @{
Kojto 158:b23ee177fd68 151 */
Kojto 158:b23ee177fd68 152 #define LL_I2C_ISR_TXE I2C_ISR_TXE /*!< Transmit data register empty */
Kojto 158:b23ee177fd68 153 #define LL_I2C_ISR_TXIS I2C_ISR_TXIS /*!< Transmit interrupt status */
Kojto 158:b23ee177fd68 154 #define LL_I2C_ISR_RXNE I2C_ISR_RXNE /*!< Receive data register not empty */
Kojto 158:b23ee177fd68 155 #define LL_I2C_ISR_ADDR I2C_ISR_ADDR /*!< Address matched (slave mode) */
Kojto 158:b23ee177fd68 156 #define LL_I2C_ISR_NACKF I2C_ISR_NACKF /*!< Not Acknowledge received flag */
Kojto 158:b23ee177fd68 157 #define LL_I2C_ISR_STOPF I2C_ISR_STOPF /*!< Stop detection flag */
Kojto 158:b23ee177fd68 158 #define LL_I2C_ISR_TC I2C_ISR_TC /*!< Transfer Complete (master mode) */
Kojto 158:b23ee177fd68 159 #define LL_I2C_ISR_TCR I2C_ISR_TCR /*!< Transfer Complete Reload */
Kojto 158:b23ee177fd68 160 #define LL_I2C_ISR_BERR I2C_ISR_BERR /*!< Bus error */
Kojto 158:b23ee177fd68 161 #define LL_I2C_ISR_ARLO I2C_ISR_ARLO /*!< Arbitration lost */
Kojto 158:b23ee177fd68 162 #define LL_I2C_ISR_OVR I2C_ISR_OVR /*!< Overrun/Underrun (slave mode) */
Kojto 158:b23ee177fd68 163 #define LL_I2C_ISR_PECERR I2C_ISR_PECERR /*!< PEC Error in reception (SMBus mode) */
Kojto 158:b23ee177fd68 164 #define LL_I2C_ISR_TIMEOUT I2C_ISR_TIMEOUT /*!< Timeout detection flag (SMBus mode) */
Kojto 158:b23ee177fd68 165 #define LL_I2C_ISR_ALERT I2C_ISR_ALERT /*!< SMBus alert (SMBus mode) */
Kojto 158:b23ee177fd68 166 #define LL_I2C_ISR_BUSY I2C_ISR_BUSY /*!< Bus busy */
Kojto 158:b23ee177fd68 167 /**
Kojto 158:b23ee177fd68 168 * @}
Kojto 158:b23ee177fd68 169 */
Kojto 158:b23ee177fd68 170
Kojto 158:b23ee177fd68 171 /** @defgroup I2C_LL_EC_IT IT Defines
Kojto 158:b23ee177fd68 172 * @brief IT defines which can be used with LL_I2C_ReadReg and LL_I2C_WriteReg functions
Kojto 158:b23ee177fd68 173 * @{
Kojto 158:b23ee177fd68 174 */
Kojto 158:b23ee177fd68 175 #define LL_I2C_CR1_TXIE I2C_CR1_TXIE /*!< TX Interrupt enable */
Kojto 158:b23ee177fd68 176 #define LL_I2C_CR1_RXIE I2C_CR1_RXIE /*!< RX Interrupt enable */
Kojto 158:b23ee177fd68 177 #define LL_I2C_CR1_ADDRIE I2C_CR1_ADDRIE /*!< Address match Interrupt enable (slave only) */
Kojto 158:b23ee177fd68 178 #define LL_I2C_CR1_NACKIE I2C_CR1_NACKIE /*!< Not acknowledge received Interrupt enable */
Kojto 158:b23ee177fd68 179 #define LL_I2C_CR1_STOPIE I2C_CR1_STOPIE /*!< STOP detection Interrupt enable */
Kojto 158:b23ee177fd68 180 #define LL_I2C_CR1_TCIE I2C_CR1_TCIE /*!< Transfer Complete interrupt enable */
Kojto 158:b23ee177fd68 181 #define LL_I2C_CR1_ERRIE I2C_CR1_ERRIE /*!< Error interrupts enable */
Kojto 158:b23ee177fd68 182 /**
Kojto 158:b23ee177fd68 183 * @}
Kojto 158:b23ee177fd68 184 */
Kojto 158:b23ee177fd68 185
Kojto 158:b23ee177fd68 186 /** @defgroup I2C_LL_EC_PERIPHERAL_MODE Peripheral Mode
Kojto 158:b23ee177fd68 187 * @{
Kojto 158:b23ee177fd68 188 */
Anna Bridge 186:707f6e361f3e 189 #define LL_I2C_MODE_I2C 0x00000000U /*!< I2C Master or Slave mode */
Kojto 158:b23ee177fd68 190 #define LL_I2C_MODE_SMBUS_HOST I2C_CR1_SMBHEN /*!< SMBus Host address acknowledge */
Anna Bridge 186:707f6e361f3e 191 #define LL_I2C_MODE_SMBUS_DEVICE 0x00000000U /*!< SMBus Device default mode (Default address not acknowledge) */
Kojto 158:b23ee177fd68 192 #define LL_I2C_MODE_SMBUS_DEVICE_ARP I2C_CR1_SMBDEN /*!< SMBus Device Default address acknowledge */
Kojto 158:b23ee177fd68 193 /**
Kojto 158:b23ee177fd68 194 * @}
Kojto 158:b23ee177fd68 195 */
Kojto 158:b23ee177fd68 196
Kojto 158:b23ee177fd68 197 /** @defgroup I2C_LL_EC_ANALOGFILTER_SELECTION Analog Filter Selection
Kojto 158:b23ee177fd68 198 * @{
Kojto 158:b23ee177fd68 199 */
Anna Bridge 186:707f6e361f3e 200 #define LL_I2C_ANALOGFILTER_ENABLE 0x00000000U /*!< Analog filter is enabled. */
Kojto 158:b23ee177fd68 201 #define LL_I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF /*!< Analog filter is disabled. */
Kojto 158:b23ee177fd68 202 /**
Kojto 158:b23ee177fd68 203 * @}
Kojto 158:b23ee177fd68 204 */
Kojto 158:b23ee177fd68 205
Kojto 158:b23ee177fd68 206 /** @defgroup I2C_LL_EC_ADDRESSING_MODE Master Addressing Mode
Kojto 158:b23ee177fd68 207 * @{
Kojto 158:b23ee177fd68 208 */
Anna Bridge 186:707f6e361f3e 209 #define LL_I2C_ADDRESSING_MODE_7BIT 0x00000000U /*!< Master operates in 7-bit addressing mode. */
Kojto 158:b23ee177fd68 210 #define LL_I2C_ADDRESSING_MODE_10BIT I2C_CR2_ADD10 /*!< Master operates in 10-bit addressing mode.*/
Kojto 158:b23ee177fd68 211 /**
Kojto 158:b23ee177fd68 212 * @}
Kojto 158:b23ee177fd68 213 */
Kojto 158:b23ee177fd68 214
Kojto 158:b23ee177fd68 215 /** @defgroup I2C_LL_EC_OWNADDRESS1 Own Address 1 Length
Kojto 158:b23ee177fd68 216 * @{
Kojto 158:b23ee177fd68 217 */
Anna Bridge 186:707f6e361f3e 218 #define LL_I2C_OWNADDRESS1_7BIT 0x00000000U /*!< Own address 1 is a 7-bit address. */
Kojto 158:b23ee177fd68 219 #define LL_I2C_OWNADDRESS1_10BIT I2C_OAR1_OA1MODE /*!< Own address 1 is a 10-bit address.*/
Kojto 158:b23ee177fd68 220 /**
Kojto 158:b23ee177fd68 221 * @}
Kojto 158:b23ee177fd68 222 */
Kojto 158:b23ee177fd68 223
Kojto 158:b23ee177fd68 224 /** @defgroup I2C_LL_EC_OWNADDRESS2 Own Address 2 Masks
Kojto 158:b23ee177fd68 225 * @{
Kojto 158:b23ee177fd68 226 */
Kojto 158:b23ee177fd68 227 #define LL_I2C_OWNADDRESS2_NOMASK I2C_OAR2_OA2NOMASK /*!< Own Address2 No mask. */
Kojto 158:b23ee177fd68 228 #define LL_I2C_OWNADDRESS2_MASK01 I2C_OAR2_OA2MASK01 /*!< Only Address2 bits[7:2] are compared. */
Kojto 158:b23ee177fd68 229 #define LL_I2C_OWNADDRESS2_MASK02 I2C_OAR2_OA2MASK02 /*!< Only Address2 bits[7:3] are compared. */
Kojto 158:b23ee177fd68 230 #define LL_I2C_OWNADDRESS2_MASK03 I2C_OAR2_OA2MASK03 /*!< Only Address2 bits[7:4] are compared. */
Kojto 158:b23ee177fd68 231 #define LL_I2C_OWNADDRESS2_MASK04 I2C_OAR2_OA2MASK04 /*!< Only Address2 bits[7:5] are compared. */
Kojto 158:b23ee177fd68 232 #define LL_I2C_OWNADDRESS2_MASK05 I2C_OAR2_OA2MASK05 /*!< Only Address2 bits[7:6] are compared. */
Kojto 158:b23ee177fd68 233 #define LL_I2C_OWNADDRESS2_MASK06 I2C_OAR2_OA2MASK06 /*!< Only Address2 bits[7] are compared. */
Kojto 158:b23ee177fd68 234 #define LL_I2C_OWNADDRESS2_MASK07 I2C_OAR2_OA2MASK07 /*!< No comparison is done. All Address2 are acknowledged.*/
Kojto 158:b23ee177fd68 235 /**
Kojto 158:b23ee177fd68 236 * @}
Kojto 158:b23ee177fd68 237 */
Kojto 158:b23ee177fd68 238
Kojto 158:b23ee177fd68 239 /** @defgroup I2C_LL_EC_I2C_ACKNOWLEDGE Acknowledge Generation
Kojto 158:b23ee177fd68 240 * @{
Kojto 158:b23ee177fd68 241 */
Anna Bridge 186:707f6e361f3e 242 #define LL_I2C_ACK 0x00000000U /*!< ACK is sent after current received byte. */
Kojto 158:b23ee177fd68 243 #define LL_I2C_NACK I2C_CR2_NACK /*!< NACK is sent after current received byte.*/
Kojto 158:b23ee177fd68 244 /**
Kojto 158:b23ee177fd68 245 * @}
Kojto 158:b23ee177fd68 246 */
Kojto 158:b23ee177fd68 247
Kojto 158:b23ee177fd68 248 /** @defgroup I2C_LL_EC_ADDRSLAVE Slave Address Length
Kojto 158:b23ee177fd68 249 * @{
Kojto 158:b23ee177fd68 250 */
Anna Bridge 186:707f6e361f3e 251 #define LL_I2C_ADDRSLAVE_7BIT 0x00000000U /*!< Slave Address in 7-bit. */
Kojto 158:b23ee177fd68 252 #define LL_I2C_ADDRSLAVE_10BIT I2C_CR2_ADD10 /*!< Slave Address in 10-bit.*/
Kojto 158:b23ee177fd68 253 /**
Kojto 158:b23ee177fd68 254 * @}
Kojto 158:b23ee177fd68 255 */
Kojto 158:b23ee177fd68 256
Kojto 158:b23ee177fd68 257 /** @defgroup I2C_LL_EC_REQUEST Transfer Request Direction
Kojto 158:b23ee177fd68 258 * @{
Kojto 158:b23ee177fd68 259 */
Anna Bridge 186:707f6e361f3e 260 #define LL_I2C_REQUEST_WRITE 0x00000000U /*!< Master request a write transfer. */
Kojto 158:b23ee177fd68 261 #define LL_I2C_REQUEST_READ I2C_CR2_RD_WRN /*!< Master request a read transfer. */
Kojto 158:b23ee177fd68 262 /**
Kojto 158:b23ee177fd68 263 * @}
Kojto 158:b23ee177fd68 264 */
Kojto 158:b23ee177fd68 265
Kojto 158:b23ee177fd68 266 /** @defgroup I2C_LL_EC_MODE Transfer End Mode
Kojto 158:b23ee177fd68 267 * @{
Kojto 158:b23ee177fd68 268 */
Kojto 158:b23ee177fd68 269 #define LL_I2C_MODE_RELOAD I2C_CR2_RELOAD /*!< Enable I2C Reload mode. */
Kojto 158:b23ee177fd68 270 #define LL_I2C_MODE_AUTOEND I2C_CR2_AUTOEND /*!< Enable I2C Automatic end mode with no HW PEC comparison. */
Anna Bridge 186:707f6e361f3e 271 #define LL_I2C_MODE_SOFTEND 0x00000000U /*!< Enable I2C Software end mode with no HW PEC comparison. */
Kojto 158:b23ee177fd68 272 #define LL_I2C_MODE_SMBUS_RELOAD LL_I2C_MODE_RELOAD /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
Kojto 158:b23ee177fd68 273 #define LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC LL_I2C_MODE_AUTOEND /*!< Enable SMBUS Automatic end mode with HW PEC comparison. */
Kojto 158:b23ee177fd68 274 #define LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC LL_I2C_MODE_SOFTEND /*!< Enable SMBUS Software end mode with HW PEC comparison. */
Kojto 158:b23ee177fd68 275 #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. */
Kojto 158:b23ee177fd68 276 #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. */
Kojto 158:b23ee177fd68 277 /**
Kojto 158:b23ee177fd68 278 * @}
Kojto 158:b23ee177fd68 279 */
Kojto 158:b23ee177fd68 280
Kojto 158:b23ee177fd68 281 /** @defgroup I2C_LL_EC_GENERATE Start And Stop Generation
Kojto 158:b23ee177fd68 282 * @{
Kojto 158:b23ee177fd68 283 */
Anna Bridge 186:707f6e361f3e 284 #define LL_I2C_GENERATE_NOSTARTSTOP 0x00000000U /*!< Don't Generate Stop and Start condition. */
Anna Bridge 186:707f6e361f3e 285 #define LL_I2C_GENERATE_STOP (uint32_t)(0x80000000U | I2C_CR2_STOP) /*!< Generate Stop condition (Size should be set to 0). */
Anna Bridge 186:707f6e361f3e 286 #define LL_I2C_GENERATE_START_READ (uint32_t)(0x80000000U | I2C_CR2_START | I2C_CR2_RD_WRN) /*!< Generate Start for read request. */
Anna Bridge 186:707f6e361f3e 287 #define LL_I2C_GENERATE_START_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Start for write request. */
Anna Bridge 186:707f6e361f3e 288 #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. */
Anna Bridge 186:707f6e361f3e 289 #define LL_I2C_GENERATE_RESTART_7BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 7Bit address. */
Anna Bridge 186:707f6e361f3e 290 #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. */
Anna Bridge 186:707f6e361f3e 291 #define LL_I2C_GENERATE_RESTART_10BIT_WRITE (uint32_t)(0x80000000U | I2C_CR2_START) /*!< Generate Restart for write request, slave 10Bit address.*/
Kojto 158:b23ee177fd68 292 /**
Kojto 158:b23ee177fd68 293 * @}
Kojto 158:b23ee177fd68 294 */
Kojto 158:b23ee177fd68 295
Kojto 158:b23ee177fd68 296 /** @defgroup I2C_LL_EC_DIRECTION Read Write Direction
Kojto 158:b23ee177fd68 297 * @{
Kojto 158:b23ee177fd68 298 */
Anna Bridge 186:707f6e361f3e 299 #define LL_I2C_DIRECTION_WRITE 0x00000000U /*!< Write transfer request by master, slave enters receiver mode. */
Kojto 158:b23ee177fd68 300 #define LL_I2C_DIRECTION_READ I2C_ISR_DIR /*!< Read transfer request by master, slave enters transmitter mode.*/
Kojto 158:b23ee177fd68 301 /**
Kojto 158:b23ee177fd68 302 * @}
Kojto 158:b23ee177fd68 303 */
Kojto 158:b23ee177fd68 304
Kojto 158:b23ee177fd68 305 /** @defgroup I2C_LL_EC_DMA_REG_DATA DMA Register Data
Kojto 158:b23ee177fd68 306 * @{
Kojto 158:b23ee177fd68 307 */
Anna Bridge 186:707f6e361f3e 308 #define LL_I2C_DMA_REG_DATA_TRANSMIT 0x00000000U /*!< Get address of data register used for transmission */
Anna Bridge 186:707f6e361f3e 309 #define LL_I2C_DMA_REG_DATA_RECEIVE 0x00000001U /*!< Get address of data register used for reception */
Kojto 158:b23ee177fd68 310 /**
Kojto 158:b23ee177fd68 311 * @}
Kojto 158:b23ee177fd68 312 */
Kojto 158:b23ee177fd68 313
Kojto 158:b23ee177fd68 314 /** @defgroup I2C_LL_EC_SMBUS_TIMEOUTA_MODE SMBus TimeoutA Mode SCL SDA Timeout
Kojto 158:b23ee177fd68 315 * @{
Kojto 158:b23ee177fd68 316 */
Anna Bridge 186:707f6e361f3e 317 #define LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW 0x00000000U /*!< TimeoutA is used to detect SCL low level timeout. */
Kojto 158:b23ee177fd68 318 #define LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH I2C_TIMEOUTR_TIDLE /*!< TimeoutA is used to detect both SCL and SDA high level timeout.*/
Kojto 158:b23ee177fd68 319 /**
Kojto 158:b23ee177fd68 320 * @}
Kojto 158:b23ee177fd68 321 */
Kojto 158:b23ee177fd68 322
Kojto 158:b23ee177fd68 323 /** @defgroup I2C_LL_EC_SMBUS_TIMEOUT_SELECTION SMBus Timeout Selection
Kojto 158:b23ee177fd68 324 * @{
Kojto 158:b23ee177fd68 325 */
Kojto 158:b23ee177fd68 326 #define LL_I2C_SMBUS_TIMEOUTA I2C_TIMEOUTR_TIMOUTEN /*!< TimeoutA enable bit */
Kojto 158:b23ee177fd68 327 #define LL_I2C_SMBUS_TIMEOUTB I2C_TIMEOUTR_TEXTEN /*!< TimeoutB (extended clock) enable bit */
Kojto 158:b23ee177fd68 328 #define LL_I2C_SMBUS_ALL_TIMEOUT (uint32_t)(I2C_TIMEOUTR_TIMOUTEN | I2C_TIMEOUTR_TEXTEN) /*!< TimeoutA and TimeoutB (extended clock) enable bits */
Kojto 158:b23ee177fd68 329 /**
Kojto 158:b23ee177fd68 330 * @}
Kojto 158:b23ee177fd68 331 */
Kojto 158:b23ee177fd68 332
Kojto 158:b23ee177fd68 333 /**
Kojto 158:b23ee177fd68 334 * @}
Kojto 158:b23ee177fd68 335 */
Kojto 158:b23ee177fd68 336
Kojto 158:b23ee177fd68 337 /* Exported macro ------------------------------------------------------------*/
Kojto 158:b23ee177fd68 338 /** @defgroup I2C_LL_Exported_Macros I2C Exported Macros
Kojto 158:b23ee177fd68 339 * @{
Kojto 158:b23ee177fd68 340 */
Kojto 158:b23ee177fd68 341
Kojto 158:b23ee177fd68 342 /** @defgroup I2C_LL_EM_WRITE_READ Common Write and read registers Macros
Kojto 158:b23ee177fd68 343 * @{
Kojto 158:b23ee177fd68 344 */
Kojto 158:b23ee177fd68 345
Kojto 158:b23ee177fd68 346 /**
Kojto 158:b23ee177fd68 347 * @brief Write a value in I2C register
Kojto 158:b23ee177fd68 348 * @param __INSTANCE__ I2C Instance
Kojto 158:b23ee177fd68 349 * @param __REG__ Register to be written
Kojto 158:b23ee177fd68 350 * @param __VALUE__ Value to be written in the register
Kojto 158:b23ee177fd68 351 * @retval None
Kojto 158:b23ee177fd68 352 */
Kojto 158:b23ee177fd68 353 #define LL_I2C_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
Kojto 158:b23ee177fd68 354
Kojto 158:b23ee177fd68 355 /**
Kojto 158:b23ee177fd68 356 * @brief Read a value in I2C register
Kojto 158:b23ee177fd68 357 * @param __INSTANCE__ I2C Instance
Kojto 158:b23ee177fd68 358 * @param __REG__ Register to be read
Kojto 158:b23ee177fd68 359 * @retval Register value
Kojto 158:b23ee177fd68 360 */
Kojto 158:b23ee177fd68 361 #define LL_I2C_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
Kojto 158:b23ee177fd68 362 /**
Kojto 158:b23ee177fd68 363 * @}
Kojto 158:b23ee177fd68 364 */
Kojto 158:b23ee177fd68 365
Kojto 158:b23ee177fd68 366 /** @defgroup I2C_LL_EM_CONVERT_TIMINGS Convert SDA SCL timings
Kojto 158:b23ee177fd68 367 * @{
Kojto 158:b23ee177fd68 368 */
Kojto 158:b23ee177fd68 369 /**
Kojto 158:b23ee177fd68 370 * @brief Configure the SDA setup, hold time and the SCL high, low period.
Anna Bridge 186:707f6e361f3e 371 * @param __PRESCALER__ This parameter must be a value between Min_Data=0 and Max_Data=0xF.
Anna Bridge 186:707f6e361f3e 372 * @param __DATA_SETUP_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tscldel = (SCLDEL+1)xtpresc)
Anna Bridge 186:707f6e361f3e 373 * @param __DATA_HOLD_TIME__ This parameter must be a value between Min_Data=0 and Max_Data=0xF. (tsdadel = SDADELxtpresc)
Anna Bridge 186:707f6e361f3e 374 * @param __CLOCK_HIGH_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tsclh = (SCLH+1)xtpresc)
Anna Bridge 186:707f6e361f3e 375 * @param __CLOCK_LOW_PERIOD__ This parameter must be a value between Min_Data=0 and Max_Data=0xFF. (tscll = (SCLL+1)xtpresc)
Anna Bridge 186:707f6e361f3e 376 * @retval Value between Min_Data=0 and Max_Data=0xFFFFFFFF
Kojto 158:b23ee177fd68 377 */
Kojto 158:b23ee177fd68 378 #define __LL_I2C_CONVERT_TIMINGS(__PRESCALER__, __DATA_SETUP_TIME__, __DATA_HOLD_TIME__, __CLOCK_HIGH_PERIOD__, __CLOCK_LOW_PERIOD__) \
Anna Bridge 186:707f6e361f3e 379 ((((uint32_t)(__PRESCALER__) << I2C_TIMINGR_PRESC_Pos) & I2C_TIMINGR_PRESC) | \
Anna Bridge 186:707f6e361f3e 380 (((uint32_t)(__DATA_SETUP_TIME__) << I2C_TIMINGR_SCLDEL_Pos) & I2C_TIMINGR_SCLDEL) | \
Anna Bridge 186:707f6e361f3e 381 (((uint32_t)(__DATA_HOLD_TIME__) << I2C_TIMINGR_SDADEL_Pos) & I2C_TIMINGR_SDADEL) | \
Anna Bridge 186:707f6e361f3e 382 (((uint32_t)(__CLOCK_HIGH_PERIOD__) << I2C_TIMINGR_SCLH_Pos) & I2C_TIMINGR_SCLH) | \
Anna Bridge 186:707f6e361f3e 383 (((uint32_t)(__CLOCK_LOW_PERIOD__) << I2C_TIMINGR_SCLL_Pos) & I2C_TIMINGR_SCLL))
Kojto 158:b23ee177fd68 384 /**
Kojto 158:b23ee177fd68 385 * @}
Kojto 158:b23ee177fd68 386 */
Kojto 158:b23ee177fd68 387
Kojto 158:b23ee177fd68 388 /**
Kojto 158:b23ee177fd68 389 * @}
Kojto 158:b23ee177fd68 390 */
Kojto 158:b23ee177fd68 391
Kojto 158:b23ee177fd68 392 /* Exported functions --------------------------------------------------------*/
Kojto 158:b23ee177fd68 393 /** @defgroup I2C_LL_Exported_Functions I2C Exported Functions
Kojto 158:b23ee177fd68 394 * @{
Kojto 158:b23ee177fd68 395 */
Kojto 158:b23ee177fd68 396
Kojto 158:b23ee177fd68 397 /** @defgroup I2C_LL_EF_Configuration Configuration
Kojto 158:b23ee177fd68 398 * @{
Kojto 158:b23ee177fd68 399 */
Kojto 158:b23ee177fd68 400
Kojto 158:b23ee177fd68 401 /**
Kojto 158:b23ee177fd68 402 * @brief Enable I2C peripheral (PE = 1).
Kojto 158:b23ee177fd68 403 * @rmtoll CR1 PE LL_I2C_Enable
Kojto 158:b23ee177fd68 404 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 405 * @retval None
Kojto 158:b23ee177fd68 406 */
Kojto 158:b23ee177fd68 407 __STATIC_INLINE void LL_I2C_Enable(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 408 {
Kojto 158:b23ee177fd68 409 SET_BIT(I2Cx->CR1, I2C_CR1_PE);
Kojto 158:b23ee177fd68 410 }
Kojto 158:b23ee177fd68 411
Kojto 158:b23ee177fd68 412 /**
Kojto 158:b23ee177fd68 413 * @brief Disable I2C peripheral (PE = 0).
Kojto 158:b23ee177fd68 414 * @note When PE = 0, the I2C SCL and SDA lines are released.
Kojto 158:b23ee177fd68 415 * Internal state machines and status bits are put back to their reset value.
Kojto 158:b23ee177fd68 416 * When cleared, PE must be kept low for at least 3 APB clock cycles.
Kojto 158:b23ee177fd68 417 * @rmtoll CR1 PE LL_I2C_Disable
Kojto 158:b23ee177fd68 418 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 419 * @retval None
Kojto 158:b23ee177fd68 420 */
Kojto 158:b23ee177fd68 421 __STATIC_INLINE void LL_I2C_Disable(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 422 {
Kojto 158:b23ee177fd68 423 CLEAR_BIT(I2Cx->CR1, I2C_CR1_PE);
Kojto 158:b23ee177fd68 424 }
Kojto 158:b23ee177fd68 425
Kojto 158:b23ee177fd68 426 /**
Kojto 158:b23ee177fd68 427 * @brief Check if the I2C peripheral is enabled or disabled.
Kojto 158:b23ee177fd68 428 * @rmtoll CR1 PE LL_I2C_IsEnabled
Kojto 158:b23ee177fd68 429 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 430 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 431 */
Kojto 158:b23ee177fd68 432 __STATIC_INLINE uint32_t LL_I2C_IsEnabled(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 433 {
Kojto 158:b23ee177fd68 434 return (READ_BIT(I2Cx->CR1, I2C_CR1_PE) == (I2C_CR1_PE));
Kojto 158:b23ee177fd68 435 }
Kojto 158:b23ee177fd68 436
Kojto 158:b23ee177fd68 437 /**
Kojto 158:b23ee177fd68 438 * @brief Configure Noise Filters (Analog and Digital).
Kojto 158:b23ee177fd68 439 * @note If the analog filter is also enabled, the digital filter is added to analog filter.
Kojto 158:b23ee177fd68 440 * The filters can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 441 * @rmtoll CR1 ANFOFF LL_I2C_ConfigFilters\n
Kojto 158:b23ee177fd68 442 * CR1 DNF LL_I2C_ConfigFilters
Kojto 158:b23ee177fd68 443 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 444 * @param AnalogFilter This parameter can be one of the following values:
Kojto 158:b23ee177fd68 445 * @arg @ref LL_I2C_ANALOGFILTER_ENABLE
Kojto 158:b23ee177fd68 446 * @arg @ref LL_I2C_ANALOGFILTER_DISABLE
Anna Bridge 186:707f6e361f3e 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).
Kojto 158:b23ee177fd68 448 * This parameter is used to configure the digital noise filter on SDA and SCL input.
Kojto 158:b23ee177fd68 449 * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
Kojto 158:b23ee177fd68 450 * @retval None
Kojto 158:b23ee177fd68 451 */
Kojto 158:b23ee177fd68 452 __STATIC_INLINE void LL_I2C_ConfigFilters(I2C_TypeDef *I2Cx, uint32_t AnalogFilter, uint32_t DigitalFilter)
Kojto 158:b23ee177fd68 453 {
Anna Bridge 186:707f6e361f3e 454 MODIFY_REG(I2Cx->CR1, I2C_CR1_ANFOFF | I2C_CR1_DNF, AnalogFilter | (DigitalFilter << I2C_CR1_DNF_Pos));
Kojto 158:b23ee177fd68 455 }
Kojto 158:b23ee177fd68 456
Kojto 158:b23ee177fd68 457 /**
Kojto 158:b23ee177fd68 458 * @brief Configure Digital Noise Filter.
Kojto 158:b23ee177fd68 459 * @note If the analog filter is also enabled, the digital filter is added to analog filter.
Kojto 158:b23ee177fd68 460 * This filter can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 461 * @rmtoll CR1 DNF LL_I2C_SetDigitalFilter
Kojto 158:b23ee177fd68 462 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 463 * @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).
Kojto 158:b23ee177fd68 464 * This parameter is used to configure the digital noise filter on SDA and SCL input.
Kojto 158:b23ee177fd68 465 * The digital filter will filter spikes with a length of up to DNF[3:0]*ti2cclk.
Kojto 158:b23ee177fd68 466 * @retval None
Kojto 158:b23ee177fd68 467 */
Kojto 158:b23ee177fd68 468 __STATIC_INLINE void LL_I2C_SetDigitalFilter(I2C_TypeDef *I2Cx, uint32_t DigitalFilter)
Kojto 158:b23ee177fd68 469 {
Anna Bridge 186:707f6e361f3e 470 MODIFY_REG(I2Cx->CR1, I2C_CR1_DNF, DigitalFilter << I2C_CR1_DNF_Pos);
Kojto 158:b23ee177fd68 471 }
Kojto 158:b23ee177fd68 472
Kojto 158:b23ee177fd68 473 /**
Kojto 158:b23ee177fd68 474 * @brief Get the current Digital Noise Filter configuration.
Kojto 158:b23ee177fd68 475 * @rmtoll CR1 DNF LL_I2C_GetDigitalFilter
Kojto 158:b23ee177fd68 476 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 477 * @retval Value between Min_Data=0x0 and Max_Data=0xF
Kojto 158:b23ee177fd68 478 */
Kojto 158:b23ee177fd68 479 __STATIC_INLINE uint32_t LL_I2C_GetDigitalFilter(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 480 {
Anna Bridge 186:707f6e361f3e 481 return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_DNF) >> I2C_CR1_DNF_Pos);
Kojto 158:b23ee177fd68 482 }
Kojto 158:b23ee177fd68 483
Kojto 158:b23ee177fd68 484 /**
Kojto 158:b23ee177fd68 485 * @brief Enable Analog Noise Filter.
Kojto 158:b23ee177fd68 486 * @note This filter can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 487 * @rmtoll CR1 ANFOFF LL_I2C_EnableAnalogFilter
Kojto 158:b23ee177fd68 488 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 489 * @retval None
Kojto 158:b23ee177fd68 490 */
Kojto 158:b23ee177fd68 491 __STATIC_INLINE void LL_I2C_EnableAnalogFilter(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 492 {
Kojto 158:b23ee177fd68 493 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ANFOFF);
Kojto 158:b23ee177fd68 494 }
Kojto 158:b23ee177fd68 495
Kojto 158:b23ee177fd68 496 /**
Kojto 158:b23ee177fd68 497 * @brief Disable Analog Noise Filter.
Kojto 158:b23ee177fd68 498 * @note This filter can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 499 * @rmtoll CR1 ANFOFF LL_I2C_DisableAnalogFilter
Kojto 158:b23ee177fd68 500 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 501 * @retval None
Kojto 158:b23ee177fd68 502 */
Kojto 158:b23ee177fd68 503 __STATIC_INLINE void LL_I2C_DisableAnalogFilter(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 504 {
Kojto 158:b23ee177fd68 505 SET_BIT(I2Cx->CR1, I2C_CR1_ANFOFF);
Kojto 158:b23ee177fd68 506 }
Kojto 158:b23ee177fd68 507
Kojto 158:b23ee177fd68 508 /**
Kojto 158:b23ee177fd68 509 * @brief Check if Analog Noise Filter is enabled or disabled.
Kojto 158:b23ee177fd68 510 * @rmtoll CR1 ANFOFF LL_I2C_IsEnabledAnalogFilter
Kojto 158:b23ee177fd68 511 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 512 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 513 */
Kojto 158:b23ee177fd68 514 __STATIC_INLINE uint32_t LL_I2C_IsEnabledAnalogFilter(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 515 {
Kojto 158:b23ee177fd68 516 return (READ_BIT(I2Cx->CR1, I2C_CR1_ANFOFF) != (I2C_CR1_ANFOFF));
Kojto 158:b23ee177fd68 517 }
Kojto 158:b23ee177fd68 518
Kojto 158:b23ee177fd68 519 /**
Kojto 158:b23ee177fd68 520 * @brief Enable DMA transmission requests.
Kojto 158:b23ee177fd68 521 * @rmtoll CR1 TXDMAEN LL_I2C_EnableDMAReq_TX
Kojto 158:b23ee177fd68 522 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 523 * @retval None
Kojto 158:b23ee177fd68 524 */
Kojto 158:b23ee177fd68 525 __STATIC_INLINE void LL_I2C_EnableDMAReq_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 526 {
Kojto 158:b23ee177fd68 527 SET_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN);
Kojto 158:b23ee177fd68 528 }
Kojto 158:b23ee177fd68 529
Kojto 158:b23ee177fd68 530 /**
Kojto 158:b23ee177fd68 531 * @brief Disable DMA transmission requests.
Kojto 158:b23ee177fd68 532 * @rmtoll CR1 TXDMAEN LL_I2C_DisableDMAReq_TX
Kojto 158:b23ee177fd68 533 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 534 * @retval None
Kojto 158:b23ee177fd68 535 */
Kojto 158:b23ee177fd68 536 __STATIC_INLINE void LL_I2C_DisableDMAReq_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 537 {
Kojto 158:b23ee177fd68 538 CLEAR_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN);
Kojto 158:b23ee177fd68 539 }
Kojto 158:b23ee177fd68 540
Kojto 158:b23ee177fd68 541 /**
Kojto 158:b23ee177fd68 542 * @brief Check if DMA transmission requests are enabled or disabled.
Kojto 158:b23ee177fd68 543 * @rmtoll CR1 TXDMAEN LL_I2C_IsEnabledDMAReq_TX
Kojto 158:b23ee177fd68 544 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 545 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 546 */
Kojto 158:b23ee177fd68 547 __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 548 {
Kojto 158:b23ee177fd68 549 return (READ_BIT(I2Cx->CR1, I2C_CR1_TXDMAEN) == (I2C_CR1_TXDMAEN));
Kojto 158:b23ee177fd68 550 }
Kojto 158:b23ee177fd68 551
Kojto 158:b23ee177fd68 552 /**
Kojto 158:b23ee177fd68 553 * @brief Enable DMA reception requests.
Kojto 158:b23ee177fd68 554 * @rmtoll CR1 RXDMAEN LL_I2C_EnableDMAReq_RX
Kojto 158:b23ee177fd68 555 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 556 * @retval None
Kojto 158:b23ee177fd68 557 */
Kojto 158:b23ee177fd68 558 __STATIC_INLINE void LL_I2C_EnableDMAReq_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 559 {
Kojto 158:b23ee177fd68 560 SET_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN);
Kojto 158:b23ee177fd68 561 }
Kojto 158:b23ee177fd68 562
Kojto 158:b23ee177fd68 563 /**
Kojto 158:b23ee177fd68 564 * @brief Disable DMA reception requests.
Kojto 158:b23ee177fd68 565 * @rmtoll CR1 RXDMAEN LL_I2C_DisableDMAReq_RX
Kojto 158:b23ee177fd68 566 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 567 * @retval None
Kojto 158:b23ee177fd68 568 */
Kojto 158:b23ee177fd68 569 __STATIC_INLINE void LL_I2C_DisableDMAReq_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 570 {
Kojto 158:b23ee177fd68 571 CLEAR_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN);
Kojto 158:b23ee177fd68 572 }
Kojto 158:b23ee177fd68 573
Kojto 158:b23ee177fd68 574 /**
Kojto 158:b23ee177fd68 575 * @brief Check if DMA reception requests are enabled or disabled.
Kojto 158:b23ee177fd68 576 * @rmtoll CR1 RXDMAEN LL_I2C_IsEnabledDMAReq_RX
Kojto 158:b23ee177fd68 577 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 578 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 579 */
Kojto 158:b23ee177fd68 580 __STATIC_INLINE uint32_t LL_I2C_IsEnabledDMAReq_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 581 {
Kojto 158:b23ee177fd68 582 return (READ_BIT(I2Cx->CR1, I2C_CR1_RXDMAEN) == (I2C_CR1_RXDMAEN));
Kojto 158:b23ee177fd68 583 }
Kojto 158:b23ee177fd68 584
Kojto 158:b23ee177fd68 585 /**
Kojto 158:b23ee177fd68 586 * @brief Get the data register address used for DMA transfer
Kojto 158:b23ee177fd68 587 * @rmtoll TXDR TXDATA LL_I2C_DMA_GetRegAddr\n
Kojto 158:b23ee177fd68 588 * RXDR RXDATA LL_I2C_DMA_GetRegAddr
Kojto 158:b23ee177fd68 589 * @param I2Cx I2C Instance
Kojto 158:b23ee177fd68 590 * @param Direction This parameter can be one of the following values:
Kojto 158:b23ee177fd68 591 * @arg @ref LL_I2C_DMA_REG_DATA_TRANSMIT
Kojto 158:b23ee177fd68 592 * @arg @ref LL_I2C_DMA_REG_DATA_RECEIVE
Kojto 158:b23ee177fd68 593 * @retval Address of data register
Kojto 158:b23ee177fd68 594 */
Kojto 158:b23ee177fd68 595 __STATIC_INLINE uint32_t LL_I2C_DMA_GetRegAddr(I2C_TypeDef *I2Cx, uint32_t Direction)
Kojto 158:b23ee177fd68 596 {
Kojto 158:b23ee177fd68 597 register uint32_t data_reg_addr = 0U;
Kojto 158:b23ee177fd68 598
Kojto 158:b23ee177fd68 599 if (Direction == LL_I2C_DMA_REG_DATA_TRANSMIT)
Kojto 158:b23ee177fd68 600 {
Kojto 158:b23ee177fd68 601 /* return address of TXDR register */
Kojto 158:b23ee177fd68 602 data_reg_addr = (uint32_t) & (I2Cx->TXDR);
Kojto 158:b23ee177fd68 603 }
Kojto 158:b23ee177fd68 604 else
Kojto 158:b23ee177fd68 605 {
Kojto 158:b23ee177fd68 606 /* return address of RXDR register */
Kojto 158:b23ee177fd68 607 data_reg_addr = (uint32_t) & (I2Cx->RXDR);
Kojto 158:b23ee177fd68 608 }
Kojto 158:b23ee177fd68 609
Kojto 158:b23ee177fd68 610 return data_reg_addr;
Kojto 158:b23ee177fd68 611 }
Kojto 158:b23ee177fd68 612
Kojto 158:b23ee177fd68 613 /**
Kojto 158:b23ee177fd68 614 * @brief Enable Clock stretching.
Kojto 158:b23ee177fd68 615 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 616 * @rmtoll CR1 NOSTRETCH LL_I2C_EnableClockStretching
Kojto 158:b23ee177fd68 617 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 618 * @retval None
Kojto 158:b23ee177fd68 619 */
Kojto 158:b23ee177fd68 620 __STATIC_INLINE void LL_I2C_EnableClockStretching(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 621 {
Kojto 158:b23ee177fd68 622 CLEAR_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
Kojto 158:b23ee177fd68 623 }
Kojto 158:b23ee177fd68 624
Kojto 158:b23ee177fd68 625 /**
Kojto 158:b23ee177fd68 626 * @brief Disable Clock stretching.
Kojto 158:b23ee177fd68 627 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 628 * @rmtoll CR1 NOSTRETCH LL_I2C_DisableClockStretching
Kojto 158:b23ee177fd68 629 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 630 * @retval None
Kojto 158:b23ee177fd68 631 */
Kojto 158:b23ee177fd68 632 __STATIC_INLINE void LL_I2C_DisableClockStretching(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 633 {
Kojto 158:b23ee177fd68 634 SET_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH);
Kojto 158:b23ee177fd68 635 }
Kojto 158:b23ee177fd68 636
Kojto 158:b23ee177fd68 637 /**
Kojto 158:b23ee177fd68 638 * @brief Check if Clock stretching is enabled or disabled.
Kojto 158:b23ee177fd68 639 * @rmtoll CR1 NOSTRETCH LL_I2C_IsEnabledClockStretching
Kojto 158:b23ee177fd68 640 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 641 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 642 */
Kojto 158:b23ee177fd68 643 __STATIC_INLINE uint32_t LL_I2C_IsEnabledClockStretching(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 644 {
Kojto 158:b23ee177fd68 645 return (READ_BIT(I2Cx->CR1, I2C_CR1_NOSTRETCH) != (I2C_CR1_NOSTRETCH));
Kojto 158:b23ee177fd68 646 }
Kojto 158:b23ee177fd68 647
Kojto 158:b23ee177fd68 648 /**
Kojto 158:b23ee177fd68 649 * @brief Enable hardware byte control in slave mode.
Kojto 158:b23ee177fd68 650 * @rmtoll CR1 SBC LL_I2C_EnableSlaveByteControl
Kojto 158:b23ee177fd68 651 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 652 * @retval None
Kojto 158:b23ee177fd68 653 */
Kojto 158:b23ee177fd68 654 __STATIC_INLINE void LL_I2C_EnableSlaveByteControl(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 655 {
Kojto 158:b23ee177fd68 656 SET_BIT(I2Cx->CR1, I2C_CR1_SBC);
Kojto 158:b23ee177fd68 657 }
Kojto 158:b23ee177fd68 658
Kojto 158:b23ee177fd68 659 /**
Kojto 158:b23ee177fd68 660 * @brief Disable hardware byte control in slave mode.
Kojto 158:b23ee177fd68 661 * @rmtoll CR1 SBC LL_I2C_DisableSlaveByteControl
Kojto 158:b23ee177fd68 662 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 663 * @retval None
Kojto 158:b23ee177fd68 664 */
Kojto 158:b23ee177fd68 665 __STATIC_INLINE void LL_I2C_DisableSlaveByteControl(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 666 {
Kojto 158:b23ee177fd68 667 CLEAR_BIT(I2Cx->CR1, I2C_CR1_SBC);
Kojto 158:b23ee177fd68 668 }
Kojto 158:b23ee177fd68 669
Kojto 158:b23ee177fd68 670 /**
Kojto 158:b23ee177fd68 671 * @brief Check if hardware byte control in slave mode is enabled or disabled.
Kojto 158:b23ee177fd68 672 * @rmtoll CR1 SBC LL_I2C_IsEnabledSlaveByteControl
Kojto 158:b23ee177fd68 673 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 674 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 675 */
Kojto 158:b23ee177fd68 676 __STATIC_INLINE uint32_t LL_I2C_IsEnabledSlaveByteControl(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 677 {
Kojto 158:b23ee177fd68 678 return (READ_BIT(I2Cx->CR1, I2C_CR1_SBC) == (I2C_CR1_SBC));
Kojto 158:b23ee177fd68 679 }
Kojto 158:b23ee177fd68 680
Kojto 158:b23ee177fd68 681 /**
Kojto 158:b23ee177fd68 682 * @brief Enable Wakeup from STOP.
Kojto 158:b23ee177fd68 683 * @note Macro @ref IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 684 * WakeUpFromStop feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 685 * @note This bit can only be programmed when Digital Filter is disabled.
Kojto 158:b23ee177fd68 686 * @rmtoll CR1 WUPEN LL_I2C_EnableWakeUpFromStop
Kojto 158:b23ee177fd68 687 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 688 * @retval None
Kojto 158:b23ee177fd68 689 */
Kojto 158:b23ee177fd68 690 __STATIC_INLINE void LL_I2C_EnableWakeUpFromStop(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 691 {
Kojto 158:b23ee177fd68 692 SET_BIT(I2Cx->CR1, I2C_CR1_WUPEN);
Kojto 158:b23ee177fd68 693 }
Kojto 158:b23ee177fd68 694
Kojto 158:b23ee177fd68 695 /**
Kojto 158:b23ee177fd68 696 * @brief Disable Wakeup from STOP.
Kojto 158:b23ee177fd68 697 * @note Macro @ref IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 698 * WakeUpFromStop feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 699 * @rmtoll CR1 WUPEN LL_I2C_DisableWakeUpFromStop
Kojto 158:b23ee177fd68 700 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 701 * @retval None
Kojto 158:b23ee177fd68 702 */
Kojto 158:b23ee177fd68 703 __STATIC_INLINE void LL_I2C_DisableWakeUpFromStop(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 704 {
Kojto 158:b23ee177fd68 705 CLEAR_BIT(I2Cx->CR1, I2C_CR1_WUPEN);
Kojto 158:b23ee177fd68 706 }
Kojto 158:b23ee177fd68 707
Kojto 158:b23ee177fd68 708 /**
Kojto 158:b23ee177fd68 709 * @brief Check if Wakeup from STOP is enabled or disabled.
Kojto 158:b23ee177fd68 710 * @note Macro @ref IS_I2C_WAKEUP_FROMSTOP_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 711 * WakeUpFromStop feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 712 * @rmtoll CR1 WUPEN LL_I2C_IsEnabledWakeUpFromStop
Kojto 158:b23ee177fd68 713 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 714 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 715 */
Kojto 158:b23ee177fd68 716 __STATIC_INLINE uint32_t LL_I2C_IsEnabledWakeUpFromStop(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 717 {
Kojto 158:b23ee177fd68 718 return (READ_BIT(I2Cx->CR1, I2C_CR1_WUPEN) == (I2C_CR1_WUPEN));
Kojto 158:b23ee177fd68 719 }
Kojto 158:b23ee177fd68 720
Kojto 158:b23ee177fd68 721 /**
Kojto 158:b23ee177fd68 722 * @brief Enable General Call.
Kojto 158:b23ee177fd68 723 * @note When enabled the Address 0x00 is ACKed.
Kojto 158:b23ee177fd68 724 * @rmtoll CR1 GCEN LL_I2C_EnableGeneralCall
Kojto 158:b23ee177fd68 725 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 726 * @retval None
Kojto 158:b23ee177fd68 727 */
Kojto 158:b23ee177fd68 728 __STATIC_INLINE void LL_I2C_EnableGeneralCall(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 729 {
Kojto 158:b23ee177fd68 730 SET_BIT(I2Cx->CR1, I2C_CR1_GCEN);
Kojto 158:b23ee177fd68 731 }
Kojto 158:b23ee177fd68 732
Kojto 158:b23ee177fd68 733 /**
Kojto 158:b23ee177fd68 734 * @brief Disable General Call.
Kojto 158:b23ee177fd68 735 * @note When disabled the Address 0x00 is NACKed.
Kojto 158:b23ee177fd68 736 * @rmtoll CR1 GCEN LL_I2C_DisableGeneralCall
Kojto 158:b23ee177fd68 737 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 738 * @retval None
Kojto 158:b23ee177fd68 739 */
Kojto 158:b23ee177fd68 740 __STATIC_INLINE void LL_I2C_DisableGeneralCall(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 741 {
Kojto 158:b23ee177fd68 742 CLEAR_BIT(I2Cx->CR1, I2C_CR1_GCEN);
Kojto 158:b23ee177fd68 743 }
Kojto 158:b23ee177fd68 744
Kojto 158:b23ee177fd68 745 /**
Kojto 158:b23ee177fd68 746 * @brief Check if General Call is enabled or disabled.
Kojto 158:b23ee177fd68 747 * @rmtoll CR1 GCEN LL_I2C_IsEnabledGeneralCall
Kojto 158:b23ee177fd68 748 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 749 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 750 */
Kojto 158:b23ee177fd68 751 __STATIC_INLINE uint32_t LL_I2C_IsEnabledGeneralCall(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 752 {
Kojto 158:b23ee177fd68 753 return (READ_BIT(I2Cx->CR1, I2C_CR1_GCEN) == (I2C_CR1_GCEN));
Kojto 158:b23ee177fd68 754 }
Kojto 158:b23ee177fd68 755
Kojto 158:b23ee177fd68 756 /**
Kojto 158:b23ee177fd68 757 * @brief Configure the Master to operate in 7-bit or 10-bit addressing mode.
Kojto 158:b23ee177fd68 758 * @note Changing this bit is not allowed, when the START bit is set.
Kojto 158:b23ee177fd68 759 * @rmtoll CR2 ADD10 LL_I2C_SetMasterAddressingMode
Kojto 158:b23ee177fd68 760 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 761 * @param AddressingMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 762 * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
Kojto 158:b23ee177fd68 763 * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
Kojto 158:b23ee177fd68 764 * @retval None
Kojto 158:b23ee177fd68 765 */
Kojto 158:b23ee177fd68 766 __STATIC_INLINE void LL_I2C_SetMasterAddressingMode(I2C_TypeDef *I2Cx, uint32_t AddressingMode)
Kojto 158:b23ee177fd68 767 {
Kojto 158:b23ee177fd68 768 MODIFY_REG(I2Cx->CR2, I2C_CR2_ADD10, AddressingMode);
Kojto 158:b23ee177fd68 769 }
Kojto 158:b23ee177fd68 770
Kojto 158:b23ee177fd68 771 /**
Kojto 158:b23ee177fd68 772 * @brief Get the Master addressing mode.
Kojto 158:b23ee177fd68 773 * @rmtoll CR2 ADD10 LL_I2C_GetMasterAddressingMode
Kojto 158:b23ee177fd68 774 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 775 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 776 * @arg @ref LL_I2C_ADDRESSING_MODE_7BIT
Kojto 158:b23ee177fd68 777 * @arg @ref LL_I2C_ADDRESSING_MODE_10BIT
Kojto 158:b23ee177fd68 778 */
Kojto 158:b23ee177fd68 779 __STATIC_INLINE uint32_t LL_I2C_GetMasterAddressingMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 780 {
Kojto 158:b23ee177fd68 781 return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_ADD10));
Kojto 158:b23ee177fd68 782 }
Kojto 158:b23ee177fd68 783
Kojto 158:b23ee177fd68 784 /**
Kojto 158:b23ee177fd68 785 * @brief Set the Own Address1.
Kojto 158:b23ee177fd68 786 * @rmtoll OAR1 OA1 LL_I2C_SetOwnAddress1\n
Kojto 158:b23ee177fd68 787 * OAR1 OA1MODE LL_I2C_SetOwnAddress1
Kojto 158:b23ee177fd68 788 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 789 * @param OwnAddress1 This parameter must be a value between Min_Data=0 and Max_Data=0x3FF.
Kojto 158:b23ee177fd68 790 * @param OwnAddrSize This parameter can be one of the following values:
Kojto 158:b23ee177fd68 791 * @arg @ref LL_I2C_OWNADDRESS1_7BIT
Kojto 158:b23ee177fd68 792 * @arg @ref LL_I2C_OWNADDRESS1_10BIT
Kojto 158:b23ee177fd68 793 * @retval None
Kojto 158:b23ee177fd68 794 */
Kojto 158:b23ee177fd68 795 __STATIC_INLINE void LL_I2C_SetOwnAddress1(I2C_TypeDef *I2Cx, uint32_t OwnAddress1, uint32_t OwnAddrSize)
Kojto 158:b23ee177fd68 796 {
Kojto 158:b23ee177fd68 797 MODIFY_REG(I2Cx->OAR1, I2C_OAR1_OA1 | I2C_OAR1_OA1MODE, OwnAddress1 | OwnAddrSize);
Kojto 158:b23ee177fd68 798 }
Kojto 158:b23ee177fd68 799
Kojto 158:b23ee177fd68 800 /**
Kojto 158:b23ee177fd68 801 * @brief Enable acknowledge on Own Address1 match address.
Kojto 158:b23ee177fd68 802 * @rmtoll OAR1 OA1EN LL_I2C_EnableOwnAddress1
Kojto 158:b23ee177fd68 803 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 804 * @retval None
Kojto 158:b23ee177fd68 805 */
Kojto 158:b23ee177fd68 806 __STATIC_INLINE void LL_I2C_EnableOwnAddress1(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 807 {
Kojto 158:b23ee177fd68 808 SET_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN);
Kojto 158:b23ee177fd68 809 }
Kojto 158:b23ee177fd68 810
Kojto 158:b23ee177fd68 811 /**
Kojto 158:b23ee177fd68 812 * @brief Disable acknowledge on Own Address1 match address.
Kojto 158:b23ee177fd68 813 * @rmtoll OAR1 OA1EN LL_I2C_DisableOwnAddress1
Kojto 158:b23ee177fd68 814 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 815 * @retval None
Kojto 158:b23ee177fd68 816 */
Kojto 158:b23ee177fd68 817 __STATIC_INLINE void LL_I2C_DisableOwnAddress1(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 818 {
Kojto 158:b23ee177fd68 819 CLEAR_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN);
Kojto 158:b23ee177fd68 820 }
Kojto 158:b23ee177fd68 821
Kojto 158:b23ee177fd68 822 /**
Kojto 158:b23ee177fd68 823 * @brief Check if Own Address1 acknowledge is enabled or disabled.
Kojto 158:b23ee177fd68 824 * @rmtoll OAR1 OA1EN LL_I2C_IsEnabledOwnAddress1
Kojto 158:b23ee177fd68 825 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 826 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 827 */
Kojto 158:b23ee177fd68 828 __STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress1(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 829 {
Kojto 158:b23ee177fd68 830 return (READ_BIT(I2Cx->OAR1, I2C_OAR1_OA1EN) == (I2C_OAR1_OA1EN));
Kojto 158:b23ee177fd68 831 }
Kojto 158:b23ee177fd68 832
Kojto 158:b23ee177fd68 833 /**
Kojto 158:b23ee177fd68 834 * @brief Set the 7bits Own Address2.
Kojto 158:b23ee177fd68 835 * @note This action has no effect if own address2 is enabled.
Kojto 158:b23ee177fd68 836 * @rmtoll OAR2 OA2 LL_I2C_SetOwnAddress2\n
Kojto 158:b23ee177fd68 837 * OAR2 OA2MSK LL_I2C_SetOwnAddress2
Kojto 158:b23ee177fd68 838 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 839 * @param OwnAddress2 Value between Min_Data=0 and Max_Data=0x7F.
Kojto 158:b23ee177fd68 840 * @param OwnAddrMask This parameter can be one of the following values:
Kojto 158:b23ee177fd68 841 * @arg @ref LL_I2C_OWNADDRESS2_NOMASK
Kojto 158:b23ee177fd68 842 * @arg @ref LL_I2C_OWNADDRESS2_MASK01
Kojto 158:b23ee177fd68 843 * @arg @ref LL_I2C_OWNADDRESS2_MASK02
Kojto 158:b23ee177fd68 844 * @arg @ref LL_I2C_OWNADDRESS2_MASK03
Kojto 158:b23ee177fd68 845 * @arg @ref LL_I2C_OWNADDRESS2_MASK04
Kojto 158:b23ee177fd68 846 * @arg @ref LL_I2C_OWNADDRESS2_MASK05
Kojto 158:b23ee177fd68 847 * @arg @ref LL_I2C_OWNADDRESS2_MASK06
Kojto 158:b23ee177fd68 848 * @arg @ref LL_I2C_OWNADDRESS2_MASK07
Kojto 158:b23ee177fd68 849 * @retval None
Kojto 158:b23ee177fd68 850 */
Kojto 158:b23ee177fd68 851 __STATIC_INLINE void LL_I2C_SetOwnAddress2(I2C_TypeDef *I2Cx, uint32_t OwnAddress2, uint32_t OwnAddrMask)
Kojto 158:b23ee177fd68 852 {
Kojto 158:b23ee177fd68 853 MODIFY_REG(I2Cx->OAR2, I2C_OAR2_OA2 | I2C_OAR2_OA2MSK, OwnAddress2 | OwnAddrMask);
Kojto 158:b23ee177fd68 854 }
Kojto 158:b23ee177fd68 855
Kojto 158:b23ee177fd68 856 /**
Kojto 158:b23ee177fd68 857 * @brief Enable acknowledge on Own Address2 match address.
Kojto 158:b23ee177fd68 858 * @rmtoll OAR2 OA2EN LL_I2C_EnableOwnAddress2
Kojto 158:b23ee177fd68 859 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 860 * @retval None
Kojto 158:b23ee177fd68 861 */
Kojto 158:b23ee177fd68 862 __STATIC_INLINE void LL_I2C_EnableOwnAddress2(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 863 {
Kojto 158:b23ee177fd68 864 SET_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN);
Kojto 158:b23ee177fd68 865 }
Kojto 158:b23ee177fd68 866
Kojto 158:b23ee177fd68 867 /**
Kojto 158:b23ee177fd68 868 * @brief Disable acknowledge on Own Address2 match address.
Kojto 158:b23ee177fd68 869 * @rmtoll OAR2 OA2EN LL_I2C_DisableOwnAddress2
Kojto 158:b23ee177fd68 870 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 871 * @retval None
Kojto 158:b23ee177fd68 872 */
Kojto 158:b23ee177fd68 873 __STATIC_INLINE void LL_I2C_DisableOwnAddress2(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 874 {
Kojto 158:b23ee177fd68 875 CLEAR_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN);
Kojto 158:b23ee177fd68 876 }
Kojto 158:b23ee177fd68 877
Kojto 158:b23ee177fd68 878 /**
Kojto 158:b23ee177fd68 879 * @brief Check if Own Address1 acknowledge is enabled or disabled.
Kojto 158:b23ee177fd68 880 * @rmtoll OAR2 OA2EN LL_I2C_IsEnabledOwnAddress2
Kojto 158:b23ee177fd68 881 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 882 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 883 */
Kojto 158:b23ee177fd68 884 __STATIC_INLINE uint32_t LL_I2C_IsEnabledOwnAddress2(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 885 {
Kojto 158:b23ee177fd68 886 return (READ_BIT(I2Cx->OAR2, I2C_OAR2_OA2EN) == (I2C_OAR2_OA2EN));
Kojto 158:b23ee177fd68 887 }
Kojto 158:b23ee177fd68 888
Kojto 158:b23ee177fd68 889 /**
Kojto 158:b23ee177fd68 890 * @brief Configure the SDA setup, hold time and the SCL high, low period.
Kojto 158:b23ee177fd68 891 * @note This bit can only be programmed when the I2C is disabled (PE = 0).
Kojto 158:b23ee177fd68 892 * @rmtoll TIMINGR TIMINGR LL_I2C_SetTiming
Kojto 158:b23ee177fd68 893 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 894 * @param Timing This parameter must be a value between Min_Data=0 and Max_Data=0xFFFFFFFF.
Kojto 158:b23ee177fd68 895 * @note This parameter is computed with the STM32CubeMX Tool.
Kojto 158:b23ee177fd68 896 * @retval None
Kojto 158:b23ee177fd68 897 */
Kojto 158:b23ee177fd68 898 __STATIC_INLINE void LL_I2C_SetTiming(I2C_TypeDef *I2Cx, uint32_t Timing)
Kojto 158:b23ee177fd68 899 {
Kojto 158:b23ee177fd68 900 WRITE_REG(I2Cx->TIMINGR, Timing);
Kojto 158:b23ee177fd68 901 }
Kojto 158:b23ee177fd68 902
Kojto 158:b23ee177fd68 903 /**
Kojto 158:b23ee177fd68 904 * @brief Get the Timing Prescaler setting.
Kojto 158:b23ee177fd68 905 * @rmtoll TIMINGR PRESC LL_I2C_GetTimingPrescaler
Kojto 158:b23ee177fd68 906 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 907 * @retval Value between Min_Data=0x0 and Max_Data=0xF
Kojto 158:b23ee177fd68 908 */
Kojto 158:b23ee177fd68 909 __STATIC_INLINE uint32_t LL_I2C_GetTimingPrescaler(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 910 {
Anna Bridge 186:707f6e361f3e 911 return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_PRESC) >> I2C_TIMINGR_PRESC_Pos);
Kojto 158:b23ee177fd68 912 }
Kojto 158:b23ee177fd68 913
Kojto 158:b23ee177fd68 914 /**
Kojto 158:b23ee177fd68 915 * @brief Get the SCL low period setting.
Kojto 158:b23ee177fd68 916 * @rmtoll TIMINGR SCLL LL_I2C_GetClockLowPeriod
Kojto 158:b23ee177fd68 917 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 918 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 919 */
Kojto 158:b23ee177fd68 920 __STATIC_INLINE uint32_t LL_I2C_GetClockLowPeriod(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 921 {
Anna Bridge 186:707f6e361f3e 922 return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLL) >> I2C_TIMINGR_SCLL_Pos);
Kojto 158:b23ee177fd68 923 }
Kojto 158:b23ee177fd68 924
Kojto 158:b23ee177fd68 925 /**
Kojto 158:b23ee177fd68 926 * @brief Get the SCL high period setting.
Kojto 158:b23ee177fd68 927 * @rmtoll TIMINGR SCLH LL_I2C_GetClockHighPeriod
Kojto 158:b23ee177fd68 928 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 929 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 930 */
Kojto 158:b23ee177fd68 931 __STATIC_INLINE uint32_t LL_I2C_GetClockHighPeriod(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 932 {
Anna Bridge 186:707f6e361f3e 933 return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLH) >> I2C_TIMINGR_SCLH_Pos);
Kojto 158:b23ee177fd68 934 }
Kojto 158:b23ee177fd68 935
Kojto 158:b23ee177fd68 936 /**
Kojto 158:b23ee177fd68 937 * @brief Get the SDA hold time.
Kojto 158:b23ee177fd68 938 * @rmtoll TIMINGR SDADEL LL_I2C_GetDataHoldTime
Kojto 158:b23ee177fd68 939 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 940 * @retval Value between Min_Data=0x0 and Max_Data=0xF
Kojto 158:b23ee177fd68 941 */
Kojto 158:b23ee177fd68 942 __STATIC_INLINE uint32_t LL_I2C_GetDataHoldTime(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 943 {
Anna Bridge 186:707f6e361f3e 944 return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SDADEL) >> I2C_TIMINGR_SDADEL_Pos);
Kojto 158:b23ee177fd68 945 }
Kojto 158:b23ee177fd68 946
Kojto 158:b23ee177fd68 947 /**
Kojto 158:b23ee177fd68 948 * @brief Get the SDA setup time.
Kojto 158:b23ee177fd68 949 * @rmtoll TIMINGR SCLDEL LL_I2C_GetDataSetupTime
Kojto 158:b23ee177fd68 950 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 951 * @retval Value between Min_Data=0x0 and Max_Data=0xF
Kojto 158:b23ee177fd68 952 */
Kojto 158:b23ee177fd68 953 __STATIC_INLINE uint32_t LL_I2C_GetDataSetupTime(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 954 {
Anna Bridge 186:707f6e361f3e 955 return (uint32_t)(READ_BIT(I2Cx->TIMINGR, I2C_TIMINGR_SCLDEL) >> I2C_TIMINGR_SCLDEL_Pos);
Kojto 158:b23ee177fd68 956 }
Kojto 158:b23ee177fd68 957
Kojto 158:b23ee177fd68 958 /**
Kojto 158:b23ee177fd68 959 * @brief Configure peripheral mode.
Kojto 158:b23ee177fd68 960 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 961 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 962 * @rmtoll CR1 SMBHEN LL_I2C_SetMode\n
Kojto 158:b23ee177fd68 963 * CR1 SMBDEN LL_I2C_SetMode
Kojto 158:b23ee177fd68 964 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 965 * @param PeripheralMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 966 * @arg @ref LL_I2C_MODE_I2C
Kojto 158:b23ee177fd68 967 * @arg @ref LL_I2C_MODE_SMBUS_HOST
Kojto 158:b23ee177fd68 968 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
Kojto 158:b23ee177fd68 969 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
Kojto 158:b23ee177fd68 970 * @retval None
Kojto 158:b23ee177fd68 971 */
Kojto 158:b23ee177fd68 972 __STATIC_INLINE void LL_I2C_SetMode(I2C_TypeDef *I2Cx, uint32_t PeripheralMode)
Kojto 158:b23ee177fd68 973 {
Kojto 158:b23ee177fd68 974 MODIFY_REG(I2Cx->CR1, I2C_CR1_SMBHEN | I2C_CR1_SMBDEN, PeripheralMode);
Kojto 158:b23ee177fd68 975 }
Kojto 158:b23ee177fd68 976
Kojto 158:b23ee177fd68 977 /**
Kojto 158:b23ee177fd68 978 * @brief Get peripheral mode.
Kojto 158:b23ee177fd68 979 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 980 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 981 * @rmtoll CR1 SMBHEN LL_I2C_GetMode\n
Kojto 158:b23ee177fd68 982 * CR1 SMBDEN LL_I2C_GetMode
Kojto 158:b23ee177fd68 983 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 984 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 985 * @arg @ref LL_I2C_MODE_I2C
Kojto 158:b23ee177fd68 986 * @arg @ref LL_I2C_MODE_SMBUS_HOST
Kojto 158:b23ee177fd68 987 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE
Kojto 158:b23ee177fd68 988 * @arg @ref LL_I2C_MODE_SMBUS_DEVICE_ARP
Kojto 158:b23ee177fd68 989 */
Kojto 158:b23ee177fd68 990 __STATIC_INLINE uint32_t LL_I2C_GetMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 991 {
Kojto 158:b23ee177fd68 992 return (uint32_t)(READ_BIT(I2Cx->CR1, I2C_CR1_SMBHEN | I2C_CR1_SMBDEN));
Kojto 158:b23ee177fd68 993 }
Kojto 158:b23ee177fd68 994
Kojto 158:b23ee177fd68 995 /**
Kojto 158:b23ee177fd68 996 * @brief Enable SMBus alert (Host or Device mode)
Kojto 158:b23ee177fd68 997 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 998 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 999 * @note SMBus Device mode:
Kojto 158:b23ee177fd68 1000 * - SMBus Alert pin is drived low and
Kojto 158:b23ee177fd68 1001 * Alert Response Address Header acknowledge is enabled.
Kojto 158:b23ee177fd68 1002 * SMBus Host mode:
Kojto 158:b23ee177fd68 1003 * - SMBus Alert pin management is supported.
Kojto 158:b23ee177fd68 1004 * @rmtoll CR1 ALERTEN LL_I2C_EnableSMBusAlert
Kojto 158:b23ee177fd68 1005 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1006 * @retval None
Kojto 158:b23ee177fd68 1007 */
Kojto 158:b23ee177fd68 1008 __STATIC_INLINE void LL_I2C_EnableSMBusAlert(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1009 {
Kojto 158:b23ee177fd68 1010 SET_BIT(I2Cx->CR1, I2C_CR1_ALERTEN);
Kojto 158:b23ee177fd68 1011 }
Kojto 158:b23ee177fd68 1012
Kojto 158:b23ee177fd68 1013 /**
Kojto 158:b23ee177fd68 1014 * @brief Disable SMBus alert (Host or Device mode)
Kojto 158:b23ee177fd68 1015 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1016 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1017 * @note SMBus Device mode:
Kojto 158:b23ee177fd68 1018 * - SMBus Alert pin is not drived (can be used as a standard GPIO) and
Kojto 158:b23ee177fd68 1019 * Alert Response Address Header acknowledge is disabled.
Kojto 158:b23ee177fd68 1020 * SMBus Host mode:
Kojto 158:b23ee177fd68 1021 * - SMBus Alert pin management is not supported.
Kojto 158:b23ee177fd68 1022 * @rmtoll CR1 ALERTEN LL_I2C_DisableSMBusAlert
Kojto 158:b23ee177fd68 1023 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1024 * @retval None
Kojto 158:b23ee177fd68 1025 */
Kojto 158:b23ee177fd68 1026 __STATIC_INLINE void LL_I2C_DisableSMBusAlert(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1027 {
Kojto 158:b23ee177fd68 1028 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ALERTEN);
Kojto 158:b23ee177fd68 1029 }
Kojto 158:b23ee177fd68 1030
Kojto 158:b23ee177fd68 1031 /**
Kojto 158:b23ee177fd68 1032 * @brief Check if SMBus alert (Host or Device mode) is enabled or disabled.
Kojto 158:b23ee177fd68 1033 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1034 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1035 * @rmtoll CR1 ALERTEN LL_I2C_IsEnabledSMBusAlert
Kojto 158:b23ee177fd68 1036 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1037 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1038 */
Kojto 158:b23ee177fd68 1039 __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusAlert(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1040 {
Kojto 158:b23ee177fd68 1041 return (READ_BIT(I2Cx->CR1, I2C_CR1_ALERTEN) == (I2C_CR1_ALERTEN));
Kojto 158:b23ee177fd68 1042 }
Kojto 158:b23ee177fd68 1043
Kojto 158:b23ee177fd68 1044 /**
Kojto 158:b23ee177fd68 1045 * @brief Enable SMBus Packet Error Calculation (PEC).
Kojto 158:b23ee177fd68 1046 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1047 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1048 * @rmtoll CR1 PECEN LL_I2C_EnableSMBusPEC
Kojto 158:b23ee177fd68 1049 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1050 * @retval None
Kojto 158:b23ee177fd68 1051 */
Kojto 158:b23ee177fd68 1052 __STATIC_INLINE void LL_I2C_EnableSMBusPEC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1053 {
Kojto 158:b23ee177fd68 1054 SET_BIT(I2Cx->CR1, I2C_CR1_PECEN);
Kojto 158:b23ee177fd68 1055 }
Kojto 158:b23ee177fd68 1056
Kojto 158:b23ee177fd68 1057 /**
Kojto 158:b23ee177fd68 1058 * @brief Disable SMBus Packet Error Calculation (PEC).
Kojto 158:b23ee177fd68 1059 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1060 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1061 * @rmtoll CR1 PECEN LL_I2C_DisableSMBusPEC
Kojto 158:b23ee177fd68 1062 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1063 * @retval None
Kojto 158:b23ee177fd68 1064 */
Kojto 158:b23ee177fd68 1065 __STATIC_INLINE void LL_I2C_DisableSMBusPEC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1066 {
Kojto 158:b23ee177fd68 1067 CLEAR_BIT(I2Cx->CR1, I2C_CR1_PECEN);
Kojto 158:b23ee177fd68 1068 }
Kojto 158:b23ee177fd68 1069
Kojto 158:b23ee177fd68 1070 /**
Kojto 158:b23ee177fd68 1071 * @brief Check if SMBus Packet Error Calculation (PEC) is enabled or disabled.
Kojto 158:b23ee177fd68 1072 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1073 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1074 * @rmtoll CR1 PECEN LL_I2C_IsEnabledSMBusPEC
Kojto 158:b23ee177fd68 1075 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1076 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1077 */
Kojto 158:b23ee177fd68 1078 __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPEC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1079 {
Kojto 158:b23ee177fd68 1080 return (READ_BIT(I2Cx->CR1, I2C_CR1_PECEN) == (I2C_CR1_PECEN));
Kojto 158:b23ee177fd68 1081 }
Kojto 158:b23ee177fd68 1082
Kojto 158:b23ee177fd68 1083 /**
Kojto 158:b23ee177fd68 1084 * @brief Configure the SMBus Clock Timeout.
Kojto 158:b23ee177fd68 1085 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1086 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1087 * @note This configuration can only be programmed when associated Timeout is disabled (TimeoutA and/orTimeoutB).
Kojto 158:b23ee177fd68 1088 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_ConfigSMBusTimeout\n
Kojto 158:b23ee177fd68 1089 * TIMEOUTR TIDLE LL_I2C_ConfigSMBusTimeout\n
Kojto 158:b23ee177fd68 1090 * TIMEOUTR TIMEOUTB LL_I2C_ConfigSMBusTimeout
Kojto 158:b23ee177fd68 1091 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1092 * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
Kojto 158:b23ee177fd68 1093 * @param TimeoutAMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1094 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
Kojto 158:b23ee177fd68 1095 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
Kojto 158:b23ee177fd68 1096 * @param TimeoutB
Kojto 158:b23ee177fd68 1097 * @retval None
Kojto 158:b23ee177fd68 1098 */
Kojto 158:b23ee177fd68 1099 __STATIC_INLINE void LL_I2C_ConfigSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t TimeoutA, uint32_t TimeoutAMode,
Anna Bridge 186:707f6e361f3e 1100 uint32_t TimeoutB)
Kojto 158:b23ee177fd68 1101 {
Kojto 158:b23ee177fd68 1102 MODIFY_REG(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTA | I2C_TIMEOUTR_TIDLE | I2C_TIMEOUTR_TIMEOUTB,
Anna Bridge 186:707f6e361f3e 1103 TimeoutA | TimeoutAMode | (TimeoutB << I2C_TIMEOUTR_TIMEOUTB_Pos));
Kojto 158:b23ee177fd68 1104 }
Kojto 158:b23ee177fd68 1105
Kojto 158:b23ee177fd68 1106 /**
Kojto 158:b23ee177fd68 1107 * @brief Configure the SMBus Clock TimeoutA (SCL low timeout or SCL and SDA high timeout depends on TimeoutA mode).
Kojto 158:b23ee177fd68 1108 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1109 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1110 * @note These bits can only be programmed when TimeoutA is disabled.
Kojto 158:b23ee177fd68 1111 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_SetSMBusTimeoutA
Kojto 158:b23ee177fd68 1112 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1113 * @param TimeoutA This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
Kojto 158:b23ee177fd68 1114 * @retval None
Kojto 158:b23ee177fd68 1115 */
Kojto 158:b23ee177fd68 1116 __STATIC_INLINE void LL_I2C_SetSMBusTimeoutA(I2C_TypeDef *I2Cx, uint32_t TimeoutA)
Kojto 158:b23ee177fd68 1117 {
Kojto 158:b23ee177fd68 1118 WRITE_REG(I2Cx->TIMEOUTR, TimeoutA);
Kojto 158:b23ee177fd68 1119 }
Kojto 158:b23ee177fd68 1120
Kojto 158:b23ee177fd68 1121 /**
Kojto 158:b23ee177fd68 1122 * @brief Get the SMBus Clock TimeoutA setting.
Kojto 158:b23ee177fd68 1123 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1124 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1125 * @rmtoll TIMEOUTR TIMEOUTA LL_I2C_GetSMBusTimeoutA
Kojto 158:b23ee177fd68 1126 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1127 * @retval Value between Min_Data=0 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1128 */
Kojto 158:b23ee177fd68 1129 __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutA(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1130 {
Kojto 158:b23ee177fd68 1131 return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTA));
Kojto 158:b23ee177fd68 1132 }
Kojto 158:b23ee177fd68 1133
Kojto 158:b23ee177fd68 1134 /**
Kojto 158:b23ee177fd68 1135 * @brief Set the SMBus Clock TimeoutA mode.
Kojto 158:b23ee177fd68 1136 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1137 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1138 * @note This bit can only be programmed when TimeoutA is disabled.
Kojto 158:b23ee177fd68 1139 * @rmtoll TIMEOUTR TIDLE LL_I2C_SetSMBusTimeoutAMode
Kojto 158:b23ee177fd68 1140 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1141 * @param TimeoutAMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1142 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
Kojto 158:b23ee177fd68 1143 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
Kojto 158:b23ee177fd68 1144 * @retval None
Kojto 158:b23ee177fd68 1145 */
Kojto 158:b23ee177fd68 1146 __STATIC_INLINE void LL_I2C_SetSMBusTimeoutAMode(I2C_TypeDef *I2Cx, uint32_t TimeoutAMode)
Kojto 158:b23ee177fd68 1147 {
Kojto 158:b23ee177fd68 1148 WRITE_REG(I2Cx->TIMEOUTR, TimeoutAMode);
Kojto 158:b23ee177fd68 1149 }
Kojto 158:b23ee177fd68 1150
Kojto 158:b23ee177fd68 1151 /**
Kojto 158:b23ee177fd68 1152 * @brief Get the SMBus Clock TimeoutA mode.
Kojto 158:b23ee177fd68 1153 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1154 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1155 * @rmtoll TIMEOUTR TIDLE LL_I2C_GetSMBusTimeoutAMode
Kojto 158:b23ee177fd68 1156 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1157 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 1158 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SCL_LOW
Kojto 158:b23ee177fd68 1159 * @arg @ref LL_I2C_SMBUS_TIMEOUTA_MODE_SDA_SCL_HIGH
Kojto 158:b23ee177fd68 1160 */
Kojto 158:b23ee177fd68 1161 __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutAMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1162 {
Kojto 158:b23ee177fd68 1163 return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIDLE));
Kojto 158:b23ee177fd68 1164 }
Kojto 158:b23ee177fd68 1165
Kojto 158:b23ee177fd68 1166 /**
Kojto 158:b23ee177fd68 1167 * @brief Configure the SMBus Extended Cumulative Clock TimeoutB (Master or Slave mode).
Kojto 158:b23ee177fd68 1168 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1169 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1170 * @note These bits can only be programmed when TimeoutB is disabled.
Kojto 158:b23ee177fd68 1171 * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_SetSMBusTimeoutB
Kojto 158:b23ee177fd68 1172 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1173 * @param TimeoutB This parameter must be a value between Min_Data=0 and Max_Data=0xFFF.
Kojto 158:b23ee177fd68 1174 * @retval None
Kojto 158:b23ee177fd68 1175 */
Kojto 158:b23ee177fd68 1176 __STATIC_INLINE void LL_I2C_SetSMBusTimeoutB(I2C_TypeDef *I2Cx, uint32_t TimeoutB)
Kojto 158:b23ee177fd68 1177 {
Anna Bridge 186:707f6e361f3e 1178 WRITE_REG(I2Cx->TIMEOUTR, TimeoutB << I2C_TIMEOUTR_TIMEOUTB_Pos);
Kojto 158:b23ee177fd68 1179 }
Kojto 158:b23ee177fd68 1180
Kojto 158:b23ee177fd68 1181 /**
Kojto 158:b23ee177fd68 1182 * @brief Get the SMBus Extented Cumulative Clock TimeoutB setting.
Kojto 158:b23ee177fd68 1183 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1184 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1185 * @rmtoll TIMEOUTR TIMEOUTB LL_I2C_GetSMBusTimeoutB
Kojto 158:b23ee177fd68 1186 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1187 * @retval Value between Min_Data=0 and Max_Data=0xFFF
Kojto 158:b23ee177fd68 1188 */
Kojto 158:b23ee177fd68 1189 __STATIC_INLINE uint32_t LL_I2C_GetSMBusTimeoutB(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1190 {
Anna Bridge 186:707f6e361f3e 1191 return (uint32_t)(READ_BIT(I2Cx->TIMEOUTR, I2C_TIMEOUTR_TIMEOUTB) >> I2C_TIMEOUTR_TIMEOUTB_Pos);
Kojto 158:b23ee177fd68 1192 }
Kojto 158:b23ee177fd68 1193
Kojto 158:b23ee177fd68 1194 /**
Kojto 158:b23ee177fd68 1195 * @brief Enable the SMBus Clock Timeout.
Kojto 158:b23ee177fd68 1196 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1197 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1198 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_EnableSMBusTimeout\n
Kojto 158:b23ee177fd68 1199 * TIMEOUTR TEXTEN LL_I2C_EnableSMBusTimeout
Kojto 158:b23ee177fd68 1200 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1201 * @param ClockTimeout This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1202 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
Kojto 158:b23ee177fd68 1203 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
Kojto 158:b23ee177fd68 1204 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
Kojto 158:b23ee177fd68 1205 * @retval None
Kojto 158:b23ee177fd68 1206 */
Kojto 158:b23ee177fd68 1207 __STATIC_INLINE void LL_I2C_EnableSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
Kojto 158:b23ee177fd68 1208 {
Kojto 158:b23ee177fd68 1209 SET_BIT(I2Cx->TIMEOUTR, ClockTimeout);
Kojto 158:b23ee177fd68 1210 }
Kojto 158:b23ee177fd68 1211
Kojto 158:b23ee177fd68 1212 /**
Kojto 158:b23ee177fd68 1213 * @brief Disable the SMBus Clock Timeout.
Kojto 158:b23ee177fd68 1214 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1215 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1216 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_DisableSMBusTimeout\n
Kojto 158:b23ee177fd68 1217 * TIMEOUTR TEXTEN LL_I2C_DisableSMBusTimeout
Kojto 158:b23ee177fd68 1218 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1219 * @param ClockTimeout This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1220 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
Kojto 158:b23ee177fd68 1221 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
Kojto 158:b23ee177fd68 1222 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
Kojto 158:b23ee177fd68 1223 * @retval None
Kojto 158:b23ee177fd68 1224 */
Kojto 158:b23ee177fd68 1225 __STATIC_INLINE void LL_I2C_DisableSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
Kojto 158:b23ee177fd68 1226 {
Kojto 158:b23ee177fd68 1227 CLEAR_BIT(I2Cx->TIMEOUTR, ClockTimeout);
Kojto 158:b23ee177fd68 1228 }
Kojto 158:b23ee177fd68 1229
Kojto 158:b23ee177fd68 1230 /**
Kojto 158:b23ee177fd68 1231 * @brief Check if the SMBus Clock Timeout is enabled or disabled.
Kojto 158:b23ee177fd68 1232 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1233 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1234 * @rmtoll TIMEOUTR TIMOUTEN LL_I2C_IsEnabledSMBusTimeout\n
Kojto 158:b23ee177fd68 1235 * TIMEOUTR TEXTEN LL_I2C_IsEnabledSMBusTimeout
Kojto 158:b23ee177fd68 1236 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1237 * @param ClockTimeout This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1238 * @arg @ref LL_I2C_SMBUS_TIMEOUTA
Kojto 158:b23ee177fd68 1239 * @arg @ref LL_I2C_SMBUS_TIMEOUTB
Kojto 158:b23ee177fd68 1240 * @arg @ref LL_I2C_SMBUS_ALL_TIMEOUT
Kojto 158:b23ee177fd68 1241 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1242 */
Kojto 158:b23ee177fd68 1243 __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusTimeout(I2C_TypeDef *I2Cx, uint32_t ClockTimeout)
Kojto 158:b23ee177fd68 1244 {
Kojto 158:b23ee177fd68 1245 return (READ_BIT(I2Cx->TIMEOUTR, (I2C_TIMEOUTR_TIMOUTEN | I2C_TIMEOUTR_TEXTEN)) == (ClockTimeout));
Kojto 158:b23ee177fd68 1246 }
Kojto 158:b23ee177fd68 1247
Kojto 158:b23ee177fd68 1248 /**
Kojto 158:b23ee177fd68 1249 * @}
Kojto 158:b23ee177fd68 1250 */
Kojto 158:b23ee177fd68 1251
Kojto 158:b23ee177fd68 1252 /** @defgroup I2C_LL_EF_IT_Management IT_Management
Kojto 158:b23ee177fd68 1253 * @{
Kojto 158:b23ee177fd68 1254 */
Kojto 158:b23ee177fd68 1255
Kojto 158:b23ee177fd68 1256 /**
Kojto 158:b23ee177fd68 1257 * @brief Enable TXIS interrupt.
Kojto 158:b23ee177fd68 1258 * @rmtoll CR1 TXIE LL_I2C_EnableIT_TX
Kojto 158:b23ee177fd68 1259 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1260 * @retval None
Kojto 158:b23ee177fd68 1261 */
Kojto 158:b23ee177fd68 1262 __STATIC_INLINE void LL_I2C_EnableIT_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1263 {
Kojto 158:b23ee177fd68 1264 SET_BIT(I2Cx->CR1, I2C_CR1_TXIE);
Kojto 158:b23ee177fd68 1265 }
Kojto 158:b23ee177fd68 1266
Kojto 158:b23ee177fd68 1267 /**
Kojto 158:b23ee177fd68 1268 * @brief Disable TXIS interrupt.
Kojto 158:b23ee177fd68 1269 * @rmtoll CR1 TXIE LL_I2C_DisableIT_TX
Kojto 158:b23ee177fd68 1270 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1271 * @retval None
Kojto 158:b23ee177fd68 1272 */
Kojto 158:b23ee177fd68 1273 __STATIC_INLINE void LL_I2C_DisableIT_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1274 {
Kojto 158:b23ee177fd68 1275 CLEAR_BIT(I2Cx->CR1, I2C_CR1_TXIE);
Kojto 158:b23ee177fd68 1276 }
Kojto 158:b23ee177fd68 1277
Kojto 158:b23ee177fd68 1278 /**
Kojto 158:b23ee177fd68 1279 * @brief Check if the TXIS Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1280 * @rmtoll CR1 TXIE LL_I2C_IsEnabledIT_TX
Kojto 158:b23ee177fd68 1281 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1282 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1283 */
Kojto 158:b23ee177fd68 1284 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1285 {
Kojto 158:b23ee177fd68 1286 return (READ_BIT(I2Cx->CR1, I2C_CR1_TXIE) == (I2C_CR1_TXIE));
Kojto 158:b23ee177fd68 1287 }
Kojto 158:b23ee177fd68 1288
Kojto 158:b23ee177fd68 1289 /**
Kojto 158:b23ee177fd68 1290 * @brief Enable RXNE interrupt.
Kojto 158:b23ee177fd68 1291 * @rmtoll CR1 RXIE LL_I2C_EnableIT_RX
Kojto 158:b23ee177fd68 1292 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1293 * @retval None
Kojto 158:b23ee177fd68 1294 */
Kojto 158:b23ee177fd68 1295 __STATIC_INLINE void LL_I2C_EnableIT_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1296 {
Kojto 158:b23ee177fd68 1297 SET_BIT(I2Cx->CR1, I2C_CR1_RXIE);
Kojto 158:b23ee177fd68 1298 }
Kojto 158:b23ee177fd68 1299
Kojto 158:b23ee177fd68 1300 /**
Kojto 158:b23ee177fd68 1301 * @brief Disable RXNE interrupt.
Kojto 158:b23ee177fd68 1302 * @rmtoll CR1 RXIE LL_I2C_DisableIT_RX
Kojto 158:b23ee177fd68 1303 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1304 * @retval None
Kojto 158:b23ee177fd68 1305 */
Kojto 158:b23ee177fd68 1306 __STATIC_INLINE void LL_I2C_DisableIT_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1307 {
Kojto 158:b23ee177fd68 1308 CLEAR_BIT(I2Cx->CR1, I2C_CR1_RXIE);
Kojto 158:b23ee177fd68 1309 }
Kojto 158:b23ee177fd68 1310
Kojto 158:b23ee177fd68 1311 /**
Kojto 158:b23ee177fd68 1312 * @brief Check if the RXNE Interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1313 * @rmtoll CR1 RXIE LL_I2C_IsEnabledIT_RX
Kojto 158:b23ee177fd68 1314 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1315 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1316 */
Kojto 158:b23ee177fd68 1317 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_RX(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1318 {
Kojto 158:b23ee177fd68 1319 return (READ_BIT(I2Cx->CR1, I2C_CR1_RXIE) == (I2C_CR1_RXIE));
Kojto 158:b23ee177fd68 1320 }
Kojto 158:b23ee177fd68 1321
Kojto 158:b23ee177fd68 1322 /**
Kojto 158:b23ee177fd68 1323 * @brief Enable Address match interrupt (slave mode only).
Kojto 158:b23ee177fd68 1324 * @rmtoll CR1 ADDRIE LL_I2C_EnableIT_ADDR
Kojto 158:b23ee177fd68 1325 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1326 * @retval None
Kojto 158:b23ee177fd68 1327 */
Kojto 158:b23ee177fd68 1328 __STATIC_INLINE void LL_I2C_EnableIT_ADDR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1329 {
Kojto 158:b23ee177fd68 1330 SET_BIT(I2Cx->CR1, I2C_CR1_ADDRIE);
Kojto 158:b23ee177fd68 1331 }
Kojto 158:b23ee177fd68 1332
Kojto 158:b23ee177fd68 1333 /**
Kojto 158:b23ee177fd68 1334 * @brief Disable Address match interrupt (slave mode only).
Kojto 158:b23ee177fd68 1335 * @rmtoll CR1 ADDRIE LL_I2C_DisableIT_ADDR
Kojto 158:b23ee177fd68 1336 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1337 * @retval None
Kojto 158:b23ee177fd68 1338 */
Kojto 158:b23ee177fd68 1339 __STATIC_INLINE void LL_I2C_DisableIT_ADDR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1340 {
Kojto 158:b23ee177fd68 1341 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ADDRIE);
Kojto 158:b23ee177fd68 1342 }
Kojto 158:b23ee177fd68 1343
Kojto 158:b23ee177fd68 1344 /**
Kojto 158:b23ee177fd68 1345 * @brief Check if Address match interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1346 * @rmtoll CR1 ADDRIE LL_I2C_IsEnabledIT_ADDR
Kojto 158:b23ee177fd68 1347 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1348 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1349 */
Kojto 158:b23ee177fd68 1350 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ADDR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1351 {
Kojto 158:b23ee177fd68 1352 return (READ_BIT(I2Cx->CR1, I2C_CR1_ADDRIE) == (I2C_CR1_ADDRIE));
Kojto 158:b23ee177fd68 1353 }
Kojto 158:b23ee177fd68 1354
Kojto 158:b23ee177fd68 1355 /**
Kojto 158:b23ee177fd68 1356 * @brief Enable Not acknowledge received interrupt.
Kojto 158:b23ee177fd68 1357 * @rmtoll CR1 NACKIE LL_I2C_EnableIT_NACK
Kojto 158:b23ee177fd68 1358 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1359 * @retval None
Kojto 158:b23ee177fd68 1360 */
Kojto 158:b23ee177fd68 1361 __STATIC_INLINE void LL_I2C_EnableIT_NACK(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1362 {
Kojto 158:b23ee177fd68 1363 SET_BIT(I2Cx->CR1, I2C_CR1_NACKIE);
Kojto 158:b23ee177fd68 1364 }
Kojto 158:b23ee177fd68 1365
Kojto 158:b23ee177fd68 1366 /**
Kojto 158:b23ee177fd68 1367 * @brief Disable Not acknowledge received interrupt.
Kojto 158:b23ee177fd68 1368 * @rmtoll CR1 NACKIE LL_I2C_DisableIT_NACK
Kojto 158:b23ee177fd68 1369 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1370 * @retval None
Kojto 158:b23ee177fd68 1371 */
Kojto 158:b23ee177fd68 1372 __STATIC_INLINE void LL_I2C_DisableIT_NACK(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1373 {
Kojto 158:b23ee177fd68 1374 CLEAR_BIT(I2Cx->CR1, I2C_CR1_NACKIE);
Kojto 158:b23ee177fd68 1375 }
Kojto 158:b23ee177fd68 1376
Kojto 158:b23ee177fd68 1377 /**
Kojto 158:b23ee177fd68 1378 * @brief Check if Not acknowledge received interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1379 * @rmtoll CR1 NACKIE LL_I2C_IsEnabledIT_NACK
Kojto 158:b23ee177fd68 1380 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1381 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1382 */
Kojto 158:b23ee177fd68 1383 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_NACK(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1384 {
Kojto 158:b23ee177fd68 1385 return (READ_BIT(I2Cx->CR1, I2C_CR1_NACKIE) == (I2C_CR1_NACKIE));
Kojto 158:b23ee177fd68 1386 }
Kojto 158:b23ee177fd68 1387
Kojto 158:b23ee177fd68 1388 /**
Kojto 158:b23ee177fd68 1389 * @brief Enable STOP detection interrupt.
Kojto 158:b23ee177fd68 1390 * @rmtoll CR1 STOPIE LL_I2C_EnableIT_STOP
Kojto 158:b23ee177fd68 1391 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1392 * @retval None
Kojto 158:b23ee177fd68 1393 */
Kojto 158:b23ee177fd68 1394 __STATIC_INLINE void LL_I2C_EnableIT_STOP(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1395 {
Kojto 158:b23ee177fd68 1396 SET_BIT(I2Cx->CR1, I2C_CR1_STOPIE);
Kojto 158:b23ee177fd68 1397 }
Kojto 158:b23ee177fd68 1398
Kojto 158:b23ee177fd68 1399 /**
Kojto 158:b23ee177fd68 1400 * @brief Disable STOP detection interrupt.
Kojto 158:b23ee177fd68 1401 * @rmtoll CR1 STOPIE LL_I2C_DisableIT_STOP
Kojto 158:b23ee177fd68 1402 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1403 * @retval None
Kojto 158:b23ee177fd68 1404 */
Kojto 158:b23ee177fd68 1405 __STATIC_INLINE void LL_I2C_DisableIT_STOP(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1406 {
Kojto 158:b23ee177fd68 1407 CLEAR_BIT(I2Cx->CR1, I2C_CR1_STOPIE);
Kojto 158:b23ee177fd68 1408 }
Kojto 158:b23ee177fd68 1409
Kojto 158:b23ee177fd68 1410 /**
Kojto 158:b23ee177fd68 1411 * @brief Check if STOP detection interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1412 * @rmtoll CR1 STOPIE LL_I2C_IsEnabledIT_STOP
Kojto 158:b23ee177fd68 1413 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1414 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1415 */
Kojto 158:b23ee177fd68 1416 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_STOP(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1417 {
Kojto 158:b23ee177fd68 1418 return (READ_BIT(I2Cx->CR1, I2C_CR1_STOPIE) == (I2C_CR1_STOPIE));
Kojto 158:b23ee177fd68 1419 }
Kojto 158:b23ee177fd68 1420
Kojto 158:b23ee177fd68 1421 /**
Kojto 158:b23ee177fd68 1422 * @brief Enable Transfer Complete interrupt.
Kojto 158:b23ee177fd68 1423 * @note Any of these events will generate interrupt :
Kojto 158:b23ee177fd68 1424 * Transfer Complete (TC)
Kojto 158:b23ee177fd68 1425 * Transfer Complete Reload (TCR)
Kojto 158:b23ee177fd68 1426 * @rmtoll CR1 TCIE LL_I2C_EnableIT_TC
Kojto 158:b23ee177fd68 1427 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1428 * @retval None
Kojto 158:b23ee177fd68 1429 */
Kojto 158:b23ee177fd68 1430 __STATIC_INLINE void LL_I2C_EnableIT_TC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1431 {
Kojto 158:b23ee177fd68 1432 SET_BIT(I2Cx->CR1, I2C_CR1_TCIE);
Kojto 158:b23ee177fd68 1433 }
Kojto 158:b23ee177fd68 1434
Kojto 158:b23ee177fd68 1435 /**
Kojto 158:b23ee177fd68 1436 * @brief Disable Transfer Complete interrupt.
Kojto 158:b23ee177fd68 1437 * @note Any of these events will generate interrupt :
Kojto 158:b23ee177fd68 1438 * Transfer Complete (TC)
Kojto 158:b23ee177fd68 1439 * Transfer Complete Reload (TCR)
Kojto 158:b23ee177fd68 1440 * @rmtoll CR1 TCIE LL_I2C_DisableIT_TC
Kojto 158:b23ee177fd68 1441 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1442 * @retval None
Kojto 158:b23ee177fd68 1443 */
Kojto 158:b23ee177fd68 1444 __STATIC_INLINE void LL_I2C_DisableIT_TC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1445 {
Kojto 158:b23ee177fd68 1446 CLEAR_BIT(I2Cx->CR1, I2C_CR1_TCIE);
Kojto 158:b23ee177fd68 1447 }
Kojto 158:b23ee177fd68 1448
Kojto 158:b23ee177fd68 1449 /**
Kojto 158:b23ee177fd68 1450 * @brief Check if Transfer Complete interrupt is enabled or disabled.
Kojto 158:b23ee177fd68 1451 * @rmtoll CR1 TCIE LL_I2C_IsEnabledIT_TC
Kojto 158:b23ee177fd68 1452 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1453 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1454 */
Kojto 158:b23ee177fd68 1455 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_TC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1456 {
Kojto 158:b23ee177fd68 1457 return (READ_BIT(I2Cx->CR1, I2C_CR1_TCIE) == (I2C_CR1_TCIE));
Kojto 158:b23ee177fd68 1458 }
Kojto 158:b23ee177fd68 1459
Kojto 158:b23ee177fd68 1460 /**
Kojto 158:b23ee177fd68 1461 * @brief Enable Error interrupts.
Anna Bridge 186:707f6e361f3e 1462 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Anna Bridge 186:707f6e361f3e 1463 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1464 * @note Any of these errors will generate interrupt :
Kojto 158:b23ee177fd68 1465 * Arbitration Loss (ARLO)
Kojto 158:b23ee177fd68 1466 * Bus Error detection (BERR)
Kojto 158:b23ee177fd68 1467 * Overrun/Underrun (OVR)
Kojto 158:b23ee177fd68 1468 * SMBus Timeout detection (TIMEOUT)
Kojto 158:b23ee177fd68 1469 * SMBus PEC error detection (PECERR)
Kojto 158:b23ee177fd68 1470 * SMBus Alert pin event detection (ALERT)
Kojto 158:b23ee177fd68 1471 * @rmtoll CR1 ERRIE LL_I2C_EnableIT_ERR
Kojto 158:b23ee177fd68 1472 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1473 * @retval None
Kojto 158:b23ee177fd68 1474 */
Kojto 158:b23ee177fd68 1475 __STATIC_INLINE void LL_I2C_EnableIT_ERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1476 {
Kojto 158:b23ee177fd68 1477 SET_BIT(I2Cx->CR1, I2C_CR1_ERRIE);
Kojto 158:b23ee177fd68 1478 }
Kojto 158:b23ee177fd68 1479
Kojto 158:b23ee177fd68 1480 /**
Kojto 158:b23ee177fd68 1481 * @brief Disable Error interrupts.
Anna Bridge 186:707f6e361f3e 1482 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Anna Bridge 186:707f6e361f3e 1483 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1484 * @note Any of these errors will generate interrupt :
Kojto 158:b23ee177fd68 1485 * Arbitration Loss (ARLO)
Kojto 158:b23ee177fd68 1486 * Bus Error detection (BERR)
Kojto 158:b23ee177fd68 1487 * Overrun/Underrun (OVR)
Kojto 158:b23ee177fd68 1488 * SMBus Timeout detection (TIMEOUT)
Kojto 158:b23ee177fd68 1489 * SMBus PEC error detection (PECERR)
Kojto 158:b23ee177fd68 1490 * SMBus Alert pin event detection (ALERT)
Kojto 158:b23ee177fd68 1491 * @rmtoll CR1 ERRIE LL_I2C_DisableIT_ERR
Kojto 158:b23ee177fd68 1492 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1493 * @retval None
Kojto 158:b23ee177fd68 1494 */
Kojto 158:b23ee177fd68 1495 __STATIC_INLINE void LL_I2C_DisableIT_ERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1496 {
Kojto 158:b23ee177fd68 1497 CLEAR_BIT(I2Cx->CR1, I2C_CR1_ERRIE);
Kojto 158:b23ee177fd68 1498 }
Kojto 158:b23ee177fd68 1499
Kojto 158:b23ee177fd68 1500 /**
Anna Bridge 186:707f6e361f3e 1501 * @brief Check if Error interrupts are enabled or disabled.
Kojto 158:b23ee177fd68 1502 * @rmtoll CR1 ERRIE LL_I2C_IsEnabledIT_ERR
Kojto 158:b23ee177fd68 1503 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1504 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1505 */
Kojto 158:b23ee177fd68 1506 __STATIC_INLINE uint32_t LL_I2C_IsEnabledIT_ERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1507 {
Kojto 158:b23ee177fd68 1508 return (READ_BIT(I2Cx->CR1, I2C_CR1_ERRIE) == (I2C_CR1_ERRIE));
Kojto 158:b23ee177fd68 1509 }
Kojto 158:b23ee177fd68 1510
Kojto 158:b23ee177fd68 1511 /**
Kojto 158:b23ee177fd68 1512 * @}
Kojto 158:b23ee177fd68 1513 */
Kojto 158:b23ee177fd68 1514
Kojto 158:b23ee177fd68 1515 /** @defgroup I2C_LL_EF_FLAG_management FLAG_management
Kojto 158:b23ee177fd68 1516 * @{
Kojto 158:b23ee177fd68 1517 */
Kojto 158:b23ee177fd68 1518
Kojto 158:b23ee177fd68 1519 /**
Kojto 158:b23ee177fd68 1520 * @brief Indicate the status of Transmit data register empty flag.
Kojto 158:b23ee177fd68 1521 * @note RESET: When next data is written in Transmit data register.
Kojto 158:b23ee177fd68 1522 * SET: When Transmit data register is empty.
Kojto 158:b23ee177fd68 1523 * @rmtoll ISR TXE LL_I2C_IsActiveFlag_TXE
Kojto 158:b23ee177fd68 1524 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1525 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1526 */
Kojto 158:b23ee177fd68 1527 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXE(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1528 {
Kojto 158:b23ee177fd68 1529 return (READ_BIT(I2Cx->ISR, I2C_ISR_TXE) == (I2C_ISR_TXE));
Kojto 158:b23ee177fd68 1530 }
Kojto 158:b23ee177fd68 1531
Kojto 158:b23ee177fd68 1532 /**
Kojto 158:b23ee177fd68 1533 * @brief Indicate the status of Transmit interrupt flag.
Kojto 158:b23ee177fd68 1534 * @note RESET: When next data is written in Transmit data register.
Kojto 158:b23ee177fd68 1535 * SET: When Transmit data register is empty.
Kojto 158:b23ee177fd68 1536 * @rmtoll ISR TXIS LL_I2C_IsActiveFlag_TXIS
Kojto 158:b23ee177fd68 1537 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1538 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1539 */
Kojto 158:b23ee177fd68 1540 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TXIS(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1541 {
Kojto 158:b23ee177fd68 1542 return (READ_BIT(I2Cx->ISR, I2C_ISR_TXIS) == (I2C_ISR_TXIS));
Kojto 158:b23ee177fd68 1543 }
Kojto 158:b23ee177fd68 1544
Kojto 158:b23ee177fd68 1545 /**
Kojto 158:b23ee177fd68 1546 * @brief Indicate the status of Receive data register not empty flag.
Kojto 158:b23ee177fd68 1547 * @note RESET: When Receive data register is read.
Kojto 158:b23ee177fd68 1548 * SET: When the received data is copied in Receive data register.
Kojto 158:b23ee177fd68 1549 * @rmtoll ISR RXNE LL_I2C_IsActiveFlag_RXNE
Kojto 158:b23ee177fd68 1550 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1551 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1552 */
Kojto 158:b23ee177fd68 1553 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_RXNE(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1554 {
Kojto 158:b23ee177fd68 1555 return (READ_BIT(I2Cx->ISR, I2C_ISR_RXNE) == (I2C_ISR_RXNE));
Kojto 158:b23ee177fd68 1556 }
Kojto 158:b23ee177fd68 1557
Kojto 158:b23ee177fd68 1558 /**
Kojto 158:b23ee177fd68 1559 * @brief Indicate the status of Address matched flag (slave mode).
Kojto 158:b23ee177fd68 1560 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1561 * SET: When the received slave address matched with one of the enabled slave address.
Kojto 158:b23ee177fd68 1562 * @rmtoll ISR ADDR LL_I2C_IsActiveFlag_ADDR
Kojto 158:b23ee177fd68 1563 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1564 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1565 */
Kojto 158:b23ee177fd68 1566 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ADDR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1567 {
Kojto 158:b23ee177fd68 1568 return (READ_BIT(I2Cx->ISR, I2C_ISR_ADDR) == (I2C_ISR_ADDR));
Kojto 158:b23ee177fd68 1569 }
Kojto 158:b23ee177fd68 1570
Kojto 158:b23ee177fd68 1571 /**
Kojto 158:b23ee177fd68 1572 * @brief Indicate the status of Not Acknowledge received flag.
Kojto 158:b23ee177fd68 1573 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1574 * SET: When a NACK is received after a byte transmission.
Kojto 158:b23ee177fd68 1575 * @rmtoll ISR NACKF LL_I2C_IsActiveFlag_NACK
Kojto 158:b23ee177fd68 1576 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1577 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1578 */
Kojto 158:b23ee177fd68 1579 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_NACK(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1580 {
Kojto 158:b23ee177fd68 1581 return (READ_BIT(I2Cx->ISR, I2C_ISR_NACKF) == (I2C_ISR_NACKF));
Kojto 158:b23ee177fd68 1582 }
Kojto 158:b23ee177fd68 1583
Kojto 158:b23ee177fd68 1584 /**
Kojto 158:b23ee177fd68 1585 * @brief Indicate the status of Stop detection flag.
Kojto 158:b23ee177fd68 1586 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1587 * SET: When a Stop condition is detected.
Kojto 158:b23ee177fd68 1588 * @rmtoll ISR STOPF LL_I2C_IsActiveFlag_STOP
Kojto 158:b23ee177fd68 1589 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1590 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1591 */
Kojto 158:b23ee177fd68 1592 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_STOP(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1593 {
Kojto 158:b23ee177fd68 1594 return (READ_BIT(I2Cx->ISR, I2C_ISR_STOPF) == (I2C_ISR_STOPF));
Kojto 158:b23ee177fd68 1595 }
Kojto 158:b23ee177fd68 1596
Kojto 158:b23ee177fd68 1597 /**
Kojto 158:b23ee177fd68 1598 * @brief Indicate the status of Transfer complete flag (master mode).
Kojto 158:b23ee177fd68 1599 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1600 * SET: When RELOAD=0, AUTOEND=0 and NBYTES date have been transferred.
Kojto 158:b23ee177fd68 1601 * @rmtoll ISR TC LL_I2C_IsActiveFlag_TC
Kojto 158:b23ee177fd68 1602 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1603 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1604 */
Kojto 158:b23ee177fd68 1605 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1606 {
Kojto 158:b23ee177fd68 1607 return (READ_BIT(I2Cx->ISR, I2C_ISR_TC) == (I2C_ISR_TC));
Kojto 158:b23ee177fd68 1608 }
Kojto 158:b23ee177fd68 1609
Kojto 158:b23ee177fd68 1610 /**
Kojto 158:b23ee177fd68 1611 * @brief Indicate the status of Transfer complete flag (master mode).
Kojto 158:b23ee177fd68 1612 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1613 * SET: When RELOAD=1 and NBYTES date have been transferred.
Kojto 158:b23ee177fd68 1614 * @rmtoll ISR TCR LL_I2C_IsActiveFlag_TCR
Kojto 158:b23ee177fd68 1615 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1616 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1617 */
Kojto 158:b23ee177fd68 1618 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_TCR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1619 {
Kojto 158:b23ee177fd68 1620 return (READ_BIT(I2Cx->ISR, I2C_ISR_TCR) == (I2C_ISR_TCR));
Kojto 158:b23ee177fd68 1621 }
Kojto 158:b23ee177fd68 1622
Kojto 158:b23ee177fd68 1623 /**
Kojto 158:b23ee177fd68 1624 * @brief Indicate the status of Bus error flag.
Kojto 158:b23ee177fd68 1625 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1626 * SET: When a misplaced Start or Stop condition is detected.
Kojto 158:b23ee177fd68 1627 * @rmtoll ISR BERR LL_I2C_IsActiveFlag_BERR
Kojto 158:b23ee177fd68 1628 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1629 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1630 */
Kojto 158:b23ee177fd68 1631 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1632 {
Kojto 158:b23ee177fd68 1633 return (READ_BIT(I2Cx->ISR, I2C_ISR_BERR) == (I2C_ISR_BERR));
Kojto 158:b23ee177fd68 1634 }
Kojto 158:b23ee177fd68 1635
Kojto 158:b23ee177fd68 1636 /**
Kojto 158:b23ee177fd68 1637 * @brief Indicate the status of Arbitration lost flag.
Kojto 158:b23ee177fd68 1638 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1639 * SET: When arbitration lost.
Kojto 158:b23ee177fd68 1640 * @rmtoll ISR ARLO LL_I2C_IsActiveFlag_ARLO
Kojto 158:b23ee177fd68 1641 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1642 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1643 */
Kojto 158:b23ee177fd68 1644 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_ARLO(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1645 {
Kojto 158:b23ee177fd68 1646 return (READ_BIT(I2Cx->ISR, I2C_ISR_ARLO) == (I2C_ISR_ARLO));
Kojto 158:b23ee177fd68 1647 }
Kojto 158:b23ee177fd68 1648
Kojto 158:b23ee177fd68 1649 /**
Kojto 158:b23ee177fd68 1650 * @brief Indicate the status of Overrun/Underrun flag (slave mode).
Kojto 158:b23ee177fd68 1651 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1652 * SET: When an overrun/underrun error occurs (Clock Stretching Disabled).
Kojto 158:b23ee177fd68 1653 * @rmtoll ISR OVR LL_I2C_IsActiveFlag_OVR
Kojto 158:b23ee177fd68 1654 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1655 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1656 */
Kojto 158:b23ee177fd68 1657 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_OVR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1658 {
Kojto 158:b23ee177fd68 1659 return (READ_BIT(I2Cx->ISR, I2C_ISR_OVR) == (I2C_ISR_OVR));
Kojto 158:b23ee177fd68 1660 }
Kojto 158:b23ee177fd68 1661
Kojto 158:b23ee177fd68 1662 /**
Anna Bridge 186:707f6e361f3e 1663 * @brief Indicate the status of SMBus PEC error flag in reception.
Anna Bridge 186:707f6e361f3e 1664 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Anna Bridge 186:707f6e361f3e 1665 * SMBus feature is supported by the I2Cx Instance.
Anna Bridge 186:707f6e361f3e 1666 * @note RESET: Clear default value.
Anna Bridge 186:707f6e361f3e 1667 * SET: When the received PEC does not match with the PEC register content.
Anna Bridge 186:707f6e361f3e 1668 * @rmtoll ISR PECERR LL_I2C_IsActiveSMBusFlag_PECERR
Anna Bridge 186:707f6e361f3e 1669 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 1670 * @retval State of bit (1 or 0).
Anna Bridge 186:707f6e361f3e 1671 */
Anna Bridge 186:707f6e361f3e 1672 __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
Anna Bridge 186:707f6e361f3e 1673 {
Anna Bridge 186:707f6e361f3e 1674 return (READ_BIT(I2Cx->ISR, I2C_ISR_PECERR) == (I2C_ISR_PECERR));
Anna Bridge 186:707f6e361f3e 1675 }
Anna Bridge 186:707f6e361f3e 1676
Anna Bridge 186:707f6e361f3e 1677 /**
Anna Bridge 186:707f6e361f3e 1678 * @brief Indicate the status of SMBus Timeout detection flag.
Anna Bridge 186:707f6e361f3e 1679 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Anna Bridge 186:707f6e361f3e 1680 * SMBus feature is supported by the I2Cx Instance.
Anna Bridge 186:707f6e361f3e 1681 * @note RESET: Clear default value.
Anna Bridge 186:707f6e361f3e 1682 * SET: When a timeout or extended clock timeout occurs.
Anna Bridge 186:707f6e361f3e 1683 * @rmtoll ISR TIMEOUT LL_I2C_IsActiveSMBusFlag_TIMEOUT
Anna Bridge 186:707f6e361f3e 1684 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 1685 * @retval State of bit (1 or 0).
Anna Bridge 186:707f6e361f3e 1686 */
Anna Bridge 186:707f6e361f3e 1687 __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
Anna Bridge 186:707f6e361f3e 1688 {
Anna Bridge 186:707f6e361f3e 1689 return (READ_BIT(I2Cx->ISR, I2C_ISR_TIMEOUT) == (I2C_ISR_TIMEOUT));
Anna Bridge 186:707f6e361f3e 1690 }
Anna Bridge 186:707f6e361f3e 1691
Anna Bridge 186:707f6e361f3e 1692 /**
Anna Bridge 186:707f6e361f3e 1693 * @brief Indicate the status of SMBus alert flag.
Anna Bridge 186:707f6e361f3e 1694 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Anna Bridge 186:707f6e361f3e 1695 * SMBus feature is supported by the I2Cx Instance.
Anna Bridge 186:707f6e361f3e 1696 * @note RESET: Clear default value.
Anna Bridge 186:707f6e361f3e 1697 * SET: When SMBus host configuration, SMBus alert enabled and
Anna Bridge 186:707f6e361f3e 1698 * a falling edge event occurs on SMBA pin.
Anna Bridge 186:707f6e361f3e 1699 * @rmtoll ISR ALERT LL_I2C_IsActiveSMBusFlag_ALERT
Anna Bridge 186:707f6e361f3e 1700 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 1701 * @retval State of bit (1 or 0).
Anna Bridge 186:707f6e361f3e 1702 */
Anna Bridge 186:707f6e361f3e 1703 __STATIC_INLINE uint32_t LL_I2C_IsActiveSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
Anna Bridge 186:707f6e361f3e 1704 {
Anna Bridge 186:707f6e361f3e 1705 return (READ_BIT(I2Cx->ISR, I2C_ISR_ALERT) == (I2C_ISR_ALERT));
Anna Bridge 186:707f6e361f3e 1706 }
Anna Bridge 186:707f6e361f3e 1707
Anna Bridge 186:707f6e361f3e 1708 /**
Kojto 158:b23ee177fd68 1709 * @brief Indicate the status of Bus Busy flag.
Kojto 158:b23ee177fd68 1710 * @note RESET: Clear default value.
Kojto 158:b23ee177fd68 1711 * SET: When a Start condition is detected.
Kojto 158:b23ee177fd68 1712 * @rmtoll ISR BUSY LL_I2C_IsActiveFlag_BUSY
Kojto 158:b23ee177fd68 1713 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1714 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1715 */
Kojto 158:b23ee177fd68 1716 __STATIC_INLINE uint32_t LL_I2C_IsActiveFlag_BUSY(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1717 {
Kojto 158:b23ee177fd68 1718 return (READ_BIT(I2Cx->ISR, I2C_ISR_BUSY) == (I2C_ISR_BUSY));
Kojto 158:b23ee177fd68 1719 }
Kojto 158:b23ee177fd68 1720
Kojto 158:b23ee177fd68 1721 /**
Kojto 158:b23ee177fd68 1722 * @brief Clear Address Matched flag.
Kojto 158:b23ee177fd68 1723 * @rmtoll ICR ADDRCF LL_I2C_ClearFlag_ADDR
Kojto 158:b23ee177fd68 1724 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1725 * @retval None
Kojto 158:b23ee177fd68 1726 */
Kojto 158:b23ee177fd68 1727 __STATIC_INLINE void LL_I2C_ClearFlag_ADDR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1728 {
Kojto 158:b23ee177fd68 1729 SET_BIT(I2Cx->ICR, I2C_ICR_ADDRCF);
Kojto 158:b23ee177fd68 1730 }
Kojto 158:b23ee177fd68 1731
Kojto 158:b23ee177fd68 1732 /**
Kojto 158:b23ee177fd68 1733 * @brief Clear Not Acknowledge flag.
Kojto 158:b23ee177fd68 1734 * @rmtoll ICR NACKCF LL_I2C_ClearFlag_NACK
Kojto 158:b23ee177fd68 1735 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1736 * @retval None
Kojto 158:b23ee177fd68 1737 */
Kojto 158:b23ee177fd68 1738 __STATIC_INLINE void LL_I2C_ClearFlag_NACK(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1739 {
Kojto 158:b23ee177fd68 1740 SET_BIT(I2Cx->ICR, I2C_ICR_NACKCF);
Kojto 158:b23ee177fd68 1741 }
Kojto 158:b23ee177fd68 1742
Kojto 158:b23ee177fd68 1743 /**
Kojto 158:b23ee177fd68 1744 * @brief Clear Stop detection flag.
Kojto 158:b23ee177fd68 1745 * @rmtoll ICR STOPCF LL_I2C_ClearFlag_STOP
Kojto 158:b23ee177fd68 1746 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1747 * @retval None
Kojto 158:b23ee177fd68 1748 */
Kojto 158:b23ee177fd68 1749 __STATIC_INLINE void LL_I2C_ClearFlag_STOP(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1750 {
Kojto 158:b23ee177fd68 1751 SET_BIT(I2Cx->ICR, I2C_ICR_STOPCF);
Kojto 158:b23ee177fd68 1752 }
Kojto 158:b23ee177fd68 1753
Kojto 158:b23ee177fd68 1754 /**
Kojto 158:b23ee177fd68 1755 * @brief Clear Transmit data register empty flag (TXE).
Kojto 158:b23ee177fd68 1756 * @note This bit can be clear by software in order to flush the transmit data register (TXDR).
Kojto 158:b23ee177fd68 1757 * @rmtoll ISR TXE LL_I2C_ClearFlag_TXE
Kojto 158:b23ee177fd68 1758 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1759 * @retval None
Kojto 158:b23ee177fd68 1760 */
Kojto 158:b23ee177fd68 1761 __STATIC_INLINE void LL_I2C_ClearFlag_TXE(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1762 {
Kojto 158:b23ee177fd68 1763 WRITE_REG(I2Cx->ISR, I2C_ISR_TXE);
Kojto 158:b23ee177fd68 1764 }
Kojto 158:b23ee177fd68 1765
Kojto 158:b23ee177fd68 1766 /**
Kojto 158:b23ee177fd68 1767 * @brief Clear Bus error flag.
Kojto 158:b23ee177fd68 1768 * @rmtoll ICR BERRCF LL_I2C_ClearFlag_BERR
Kojto 158:b23ee177fd68 1769 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1770 * @retval None
Kojto 158:b23ee177fd68 1771 */
Kojto 158:b23ee177fd68 1772 __STATIC_INLINE void LL_I2C_ClearFlag_BERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1773 {
Kojto 158:b23ee177fd68 1774 SET_BIT(I2Cx->ICR, I2C_ICR_BERRCF);
Kojto 158:b23ee177fd68 1775 }
Kojto 158:b23ee177fd68 1776
Kojto 158:b23ee177fd68 1777 /**
Kojto 158:b23ee177fd68 1778 * @brief Clear Arbitration lost flag.
Kojto 158:b23ee177fd68 1779 * @rmtoll ICR ARLOCF LL_I2C_ClearFlag_ARLO
Kojto 158:b23ee177fd68 1780 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1781 * @retval None
Kojto 158:b23ee177fd68 1782 */
Kojto 158:b23ee177fd68 1783 __STATIC_INLINE void LL_I2C_ClearFlag_ARLO(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1784 {
Kojto 158:b23ee177fd68 1785 SET_BIT(I2Cx->ICR, I2C_ICR_ARLOCF);
Kojto 158:b23ee177fd68 1786 }
Kojto 158:b23ee177fd68 1787
Kojto 158:b23ee177fd68 1788 /**
Kojto 158:b23ee177fd68 1789 * @brief Clear Overrun/Underrun flag.
Kojto 158:b23ee177fd68 1790 * @rmtoll ICR OVRCF LL_I2C_ClearFlag_OVR
Kojto 158:b23ee177fd68 1791 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1792 * @retval None
Kojto 158:b23ee177fd68 1793 */
Kojto 158:b23ee177fd68 1794 __STATIC_INLINE void LL_I2C_ClearFlag_OVR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1795 {
Kojto 158:b23ee177fd68 1796 SET_BIT(I2Cx->ICR, I2C_ICR_OVRCF);
Kojto 158:b23ee177fd68 1797 }
Kojto 158:b23ee177fd68 1798
Kojto 158:b23ee177fd68 1799 /**
Kojto 158:b23ee177fd68 1800 * @brief Clear SMBus PEC error flag.
Kojto 158:b23ee177fd68 1801 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1802 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1803 * @rmtoll ICR PECCF LL_I2C_ClearSMBusFlag_PECERR
Kojto 158:b23ee177fd68 1804 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1805 * @retval None
Kojto 158:b23ee177fd68 1806 */
Kojto 158:b23ee177fd68 1807 __STATIC_INLINE void LL_I2C_ClearSMBusFlag_PECERR(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1808 {
Kojto 158:b23ee177fd68 1809 SET_BIT(I2Cx->ICR, I2C_ICR_PECCF);
Kojto 158:b23ee177fd68 1810 }
Kojto 158:b23ee177fd68 1811
Kojto 158:b23ee177fd68 1812 /**
Kojto 158:b23ee177fd68 1813 * @brief Clear SMBus Timeout detection flag.
Kojto 158:b23ee177fd68 1814 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1815 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1816 * @rmtoll ICR TIMOUTCF LL_I2C_ClearSMBusFlag_TIMEOUT
Kojto 158:b23ee177fd68 1817 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1818 * @retval None
Kojto 158:b23ee177fd68 1819 */
Kojto 158:b23ee177fd68 1820 __STATIC_INLINE void LL_I2C_ClearSMBusFlag_TIMEOUT(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1821 {
Kojto 158:b23ee177fd68 1822 SET_BIT(I2Cx->ICR, I2C_ICR_TIMOUTCF);
Kojto 158:b23ee177fd68 1823 }
Kojto 158:b23ee177fd68 1824
Kojto 158:b23ee177fd68 1825 /**
Kojto 158:b23ee177fd68 1826 * @brief Clear SMBus Alert flag.
Kojto 158:b23ee177fd68 1827 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 1828 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 1829 * @rmtoll ICR ALERTCF LL_I2C_ClearSMBusFlag_ALERT
Kojto 158:b23ee177fd68 1830 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1831 * @retval None
Kojto 158:b23ee177fd68 1832 */
Kojto 158:b23ee177fd68 1833 __STATIC_INLINE void LL_I2C_ClearSMBusFlag_ALERT(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1834 {
Kojto 158:b23ee177fd68 1835 SET_BIT(I2Cx->ICR, I2C_ICR_ALERTCF);
Kojto 158:b23ee177fd68 1836 }
Kojto 158:b23ee177fd68 1837
Kojto 158:b23ee177fd68 1838 /**
Kojto 158:b23ee177fd68 1839 * @}
Kojto 158:b23ee177fd68 1840 */
Kojto 158:b23ee177fd68 1841
Kojto 158:b23ee177fd68 1842 /** @defgroup I2C_LL_EF_Data_Management Data_Management
Kojto 158:b23ee177fd68 1843 * @{
Kojto 158:b23ee177fd68 1844 */
Kojto 158:b23ee177fd68 1845
Kojto 158:b23ee177fd68 1846 /**
Kojto 158:b23ee177fd68 1847 * @brief Enable automatic STOP condition generation (master mode).
Kojto 158:b23ee177fd68 1848 * @note Automatic end mode : a STOP condition is automatically sent when NBYTES data are transferred.
Kojto 158:b23ee177fd68 1849 * This bit has no effect in slave mode or when RELOAD bit is set.
Kojto 158:b23ee177fd68 1850 * @rmtoll CR2 AUTOEND LL_I2C_EnableAutoEndMode
Kojto 158:b23ee177fd68 1851 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1852 * @retval None
Kojto 158:b23ee177fd68 1853 */
Kojto 158:b23ee177fd68 1854 __STATIC_INLINE void LL_I2C_EnableAutoEndMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1855 {
Kojto 158:b23ee177fd68 1856 SET_BIT(I2Cx->CR2, I2C_CR2_AUTOEND);
Kojto 158:b23ee177fd68 1857 }
Kojto 158:b23ee177fd68 1858
Kojto 158:b23ee177fd68 1859 /**
Kojto 158:b23ee177fd68 1860 * @brief Disable automatic STOP condition generation (master mode).
Kojto 158:b23ee177fd68 1861 * @note Software end mode : TC flag is set when NBYTES data are transferre, stretching SCL low.
Kojto 158:b23ee177fd68 1862 * @rmtoll CR2 AUTOEND LL_I2C_DisableAutoEndMode
Kojto 158:b23ee177fd68 1863 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1864 * @retval None
Kojto 158:b23ee177fd68 1865 */
Kojto 158:b23ee177fd68 1866 __STATIC_INLINE void LL_I2C_DisableAutoEndMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1867 {
Kojto 158:b23ee177fd68 1868 CLEAR_BIT(I2Cx->CR2, I2C_CR2_AUTOEND);
Kojto 158:b23ee177fd68 1869 }
Kojto 158:b23ee177fd68 1870
Kojto 158:b23ee177fd68 1871 /**
Kojto 158:b23ee177fd68 1872 * @brief Check if automatic STOP condition is enabled or disabled.
Kojto 158:b23ee177fd68 1873 * @rmtoll CR2 AUTOEND LL_I2C_IsEnabledAutoEndMode
Kojto 158:b23ee177fd68 1874 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1875 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1876 */
Kojto 158:b23ee177fd68 1877 __STATIC_INLINE uint32_t LL_I2C_IsEnabledAutoEndMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1878 {
Kojto 158:b23ee177fd68 1879 return (READ_BIT(I2Cx->CR2, I2C_CR2_AUTOEND) == (I2C_CR2_AUTOEND));
Kojto 158:b23ee177fd68 1880 }
Kojto 158:b23ee177fd68 1881
Kojto 158:b23ee177fd68 1882 /**
Kojto 158:b23ee177fd68 1883 * @brief Enable reload mode (master mode).
Kojto 158:b23ee177fd68 1884 * @note The transfer is not completed after the NBYTES data transfer, NBYTES will be reloaded when TCR flag is set.
Kojto 158:b23ee177fd68 1885 * @rmtoll CR2 RELOAD LL_I2C_EnableReloadMode
Kojto 158:b23ee177fd68 1886 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1887 * @retval None
Kojto 158:b23ee177fd68 1888 */
Kojto 158:b23ee177fd68 1889 __STATIC_INLINE void LL_I2C_EnableReloadMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1890 {
Kojto 158:b23ee177fd68 1891 SET_BIT(I2Cx->CR2, I2C_CR2_RELOAD);
Kojto 158:b23ee177fd68 1892 }
Kojto 158:b23ee177fd68 1893
Kojto 158:b23ee177fd68 1894 /**
Kojto 158:b23ee177fd68 1895 * @brief Disable reload mode (master mode).
Kojto 158:b23ee177fd68 1896 * @note The transfer is completed after the NBYTES data transfer(STOP or RESTART will follow).
Kojto 158:b23ee177fd68 1897 * @rmtoll CR2 RELOAD LL_I2C_DisableReloadMode
Kojto 158:b23ee177fd68 1898 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1899 * @retval None
Kojto 158:b23ee177fd68 1900 */
Kojto 158:b23ee177fd68 1901 __STATIC_INLINE void LL_I2C_DisableReloadMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1902 {
Kojto 158:b23ee177fd68 1903 CLEAR_BIT(I2Cx->CR2, I2C_CR2_RELOAD);
Kojto 158:b23ee177fd68 1904 }
Kojto 158:b23ee177fd68 1905
Kojto 158:b23ee177fd68 1906 /**
Kojto 158:b23ee177fd68 1907 * @brief Check if reload mode is enabled or disabled.
Kojto 158:b23ee177fd68 1908 * @rmtoll CR2 RELOAD LL_I2C_IsEnabledReloadMode
Kojto 158:b23ee177fd68 1909 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1910 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 1911 */
Kojto 158:b23ee177fd68 1912 __STATIC_INLINE uint32_t LL_I2C_IsEnabledReloadMode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1913 {
Kojto 158:b23ee177fd68 1914 return (READ_BIT(I2Cx->CR2, I2C_CR2_RELOAD) == (I2C_CR2_RELOAD));
Kojto 158:b23ee177fd68 1915 }
Kojto 158:b23ee177fd68 1916
Kojto 158:b23ee177fd68 1917 /**
Kojto 158:b23ee177fd68 1918 * @brief Configure the number of bytes for transfer.
Kojto 158:b23ee177fd68 1919 * @note Changing these bits when START bit is set is not allowed.
Kojto 158:b23ee177fd68 1920 * @rmtoll CR2 NBYTES LL_I2C_SetTransferSize
Kojto 158:b23ee177fd68 1921 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1922 * @param TransferSize This parameter must be a value between Min_Data=0x00 and Max_Data=0xFF.
Kojto 158:b23ee177fd68 1923 * @retval None
Kojto 158:b23ee177fd68 1924 */
Kojto 158:b23ee177fd68 1925 __STATIC_INLINE void LL_I2C_SetTransferSize(I2C_TypeDef *I2Cx, uint32_t TransferSize)
Kojto 158:b23ee177fd68 1926 {
Anna Bridge 186:707f6e361f3e 1927 MODIFY_REG(I2Cx->CR2, I2C_CR2_NBYTES, TransferSize << I2C_CR2_NBYTES_Pos);
Kojto 158:b23ee177fd68 1928 }
Kojto 158:b23ee177fd68 1929
Kojto 158:b23ee177fd68 1930 /**
Kojto 158:b23ee177fd68 1931 * @brief Get the number of bytes configured for transfer.
Kojto 158:b23ee177fd68 1932 * @rmtoll CR2 NBYTES LL_I2C_GetTransferSize
Kojto 158:b23ee177fd68 1933 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1934 * @retval Value between Min_Data=0x0 and Max_Data=0xFF
Kojto 158:b23ee177fd68 1935 */
Kojto 158:b23ee177fd68 1936 __STATIC_INLINE uint32_t LL_I2C_GetTransferSize(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1937 {
Anna Bridge 186:707f6e361f3e 1938 return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_NBYTES) >> I2C_CR2_NBYTES_Pos);
Kojto 158:b23ee177fd68 1939 }
Kojto 158:b23ee177fd68 1940
Kojto 158:b23ee177fd68 1941 /**
Kojto 158:b23ee177fd68 1942 * @brief Prepare the generation of a ACKnowledge or Non ACKnowledge condition after the address receive match code or next received byte.
Kojto 158:b23ee177fd68 1943 * @note Usage in Slave mode only.
Kojto 158:b23ee177fd68 1944 * @rmtoll CR2 NACK LL_I2C_AcknowledgeNextData
Kojto 158:b23ee177fd68 1945 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1946 * @param TypeAcknowledge This parameter can be one of the following values:
Kojto 158:b23ee177fd68 1947 * @arg @ref LL_I2C_ACK
Kojto 158:b23ee177fd68 1948 * @arg @ref LL_I2C_NACK
Kojto 158:b23ee177fd68 1949 * @retval None
Kojto 158:b23ee177fd68 1950 */
Kojto 158:b23ee177fd68 1951 __STATIC_INLINE void LL_I2C_AcknowledgeNextData(I2C_TypeDef *I2Cx, uint32_t TypeAcknowledge)
Kojto 158:b23ee177fd68 1952 {
Kojto 158:b23ee177fd68 1953 MODIFY_REG(I2Cx->CR2, I2C_CR2_NACK, TypeAcknowledge);
Kojto 158:b23ee177fd68 1954 }
Kojto 158:b23ee177fd68 1955
Kojto 158:b23ee177fd68 1956 /**
Kojto 158:b23ee177fd68 1957 * @brief Generate a START or RESTART condition
Kojto 158:b23ee177fd68 1958 * @note The START bit can be set even if bus is BUSY or I2C is in slave mode.
Kojto 158:b23ee177fd68 1959 * This action has no effect when RELOAD is set.
Kojto 158:b23ee177fd68 1960 * @rmtoll CR2 START LL_I2C_GenerateStartCondition
Kojto 158:b23ee177fd68 1961 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1962 * @retval None
Kojto 158:b23ee177fd68 1963 */
Kojto 158:b23ee177fd68 1964 __STATIC_INLINE void LL_I2C_GenerateStartCondition(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1965 {
Kojto 158:b23ee177fd68 1966 SET_BIT(I2Cx->CR2, I2C_CR2_START);
Kojto 158:b23ee177fd68 1967 }
Kojto 158:b23ee177fd68 1968
Kojto 158:b23ee177fd68 1969 /**
Anna Bridge 186:707f6e361f3e 1970 * @brief Generate a STOP condition after the current byte transfer (master mode).
Anna Bridge 186:707f6e361f3e 1971 * @rmtoll CR2 STOP LL_I2C_GenerateStopCondition
Anna Bridge 186:707f6e361f3e 1972 * @param I2Cx I2C Instance.
Anna Bridge 186:707f6e361f3e 1973 * @retval None
Anna Bridge 186:707f6e361f3e 1974 */
Anna Bridge 186:707f6e361f3e 1975 __STATIC_INLINE void LL_I2C_GenerateStopCondition(I2C_TypeDef *I2Cx)
Anna Bridge 186:707f6e361f3e 1976 {
Anna Bridge 186:707f6e361f3e 1977 SET_BIT(I2Cx->CR2, I2C_CR2_STOP);
Anna Bridge 186:707f6e361f3e 1978 }
Anna Bridge 186:707f6e361f3e 1979
Anna Bridge 186:707f6e361f3e 1980 /**
Kojto 158:b23ee177fd68 1981 * @brief Enable automatic RESTART Read request condition for 10bit address header (master mode).
Kojto 158:b23ee177fd68 1982 * @note The master sends the complete 10bit slave address read sequence :
Kojto 158:b23ee177fd68 1983 * Start + 2 bytes 10bit address in Write direction + Restart + first 7 bits of 10bit address in Read direction.
Kojto 158:b23ee177fd68 1984 * @rmtoll CR2 HEAD10R LL_I2C_EnableAuto10BitRead
Kojto 158:b23ee177fd68 1985 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1986 * @retval None
Kojto 158:b23ee177fd68 1987 */
Kojto 158:b23ee177fd68 1988 __STATIC_INLINE void LL_I2C_EnableAuto10BitRead(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 1989 {
Kojto 158:b23ee177fd68 1990 CLEAR_BIT(I2Cx->CR2, I2C_CR2_HEAD10R);
Kojto 158:b23ee177fd68 1991 }
Kojto 158:b23ee177fd68 1992
Kojto 158:b23ee177fd68 1993 /**
Kojto 158:b23ee177fd68 1994 * @brief Disable automatic RESTART Read request condition for 10bit address header (master mode).
Kojto 158:b23ee177fd68 1995 * @note The master only sends the first 7 bits of 10bit address in Read direction.
Kojto 158:b23ee177fd68 1996 * @rmtoll CR2 HEAD10R LL_I2C_DisableAuto10BitRead
Kojto 158:b23ee177fd68 1997 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 1998 * @retval None
Kojto 158:b23ee177fd68 1999 */
Kojto 158:b23ee177fd68 2000 __STATIC_INLINE void LL_I2C_DisableAuto10BitRead(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2001 {
Kojto 158:b23ee177fd68 2002 SET_BIT(I2Cx->CR2, I2C_CR2_HEAD10R);
Kojto 158:b23ee177fd68 2003 }
Kojto 158:b23ee177fd68 2004
Kojto 158:b23ee177fd68 2005 /**
Kojto 158:b23ee177fd68 2006 * @brief Check if automatic RESTART Read request condition for 10bit address header is enabled or disabled.
Kojto 158:b23ee177fd68 2007 * @rmtoll CR2 HEAD10R LL_I2C_IsEnabledAuto10BitRead
Kojto 158:b23ee177fd68 2008 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2009 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2010 */
Kojto 158:b23ee177fd68 2011 __STATIC_INLINE uint32_t LL_I2C_IsEnabledAuto10BitRead(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2012 {
Kojto 158:b23ee177fd68 2013 return (READ_BIT(I2Cx->CR2, I2C_CR2_HEAD10R) != (I2C_CR2_HEAD10R));
Kojto 158:b23ee177fd68 2014 }
Kojto 158:b23ee177fd68 2015
Kojto 158:b23ee177fd68 2016 /**
Kojto 158:b23ee177fd68 2017 * @brief Configure the transfer direction (master mode).
Kojto 158:b23ee177fd68 2018 * @note Changing these bits when START bit is set is not allowed.
Kojto 158:b23ee177fd68 2019 * @rmtoll CR2 RD_WRN LL_I2C_SetTransferRequest
Kojto 158:b23ee177fd68 2020 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2021 * @param TransferRequest This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2022 * @arg @ref LL_I2C_REQUEST_WRITE
Kojto 158:b23ee177fd68 2023 * @arg @ref LL_I2C_REQUEST_READ
Kojto 158:b23ee177fd68 2024 * @retval None
Kojto 158:b23ee177fd68 2025 */
Kojto 158:b23ee177fd68 2026 __STATIC_INLINE void LL_I2C_SetTransferRequest(I2C_TypeDef *I2Cx, uint32_t TransferRequest)
Kojto 158:b23ee177fd68 2027 {
Kojto 158:b23ee177fd68 2028 MODIFY_REG(I2Cx->CR2, I2C_CR2_RD_WRN, TransferRequest);
Kojto 158:b23ee177fd68 2029 }
Kojto 158:b23ee177fd68 2030
Kojto 158:b23ee177fd68 2031 /**
Kojto 158:b23ee177fd68 2032 * @brief Get the transfer direction requested (master mode).
Kojto 158:b23ee177fd68 2033 * @rmtoll CR2 RD_WRN LL_I2C_GetTransferRequest
Kojto 158:b23ee177fd68 2034 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2035 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2036 * @arg @ref LL_I2C_REQUEST_WRITE
Kojto 158:b23ee177fd68 2037 * @arg @ref LL_I2C_REQUEST_READ
Kojto 158:b23ee177fd68 2038 */
Kojto 158:b23ee177fd68 2039 __STATIC_INLINE uint32_t LL_I2C_GetTransferRequest(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2040 {
Kojto 158:b23ee177fd68 2041 return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_RD_WRN));
Kojto 158:b23ee177fd68 2042 }
Kojto 158:b23ee177fd68 2043
Kojto 158:b23ee177fd68 2044 /**
Kojto 158:b23ee177fd68 2045 * @brief Configure the slave address for transfer (master mode).
Kojto 158:b23ee177fd68 2046 * @note Changing these bits when START bit is set is not allowed.
Kojto 158:b23ee177fd68 2047 * @rmtoll CR2 SADD LL_I2C_SetSlaveAddr
Kojto 158:b23ee177fd68 2048 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2049 * @param SlaveAddr This parameter must be a value between Min_Data=0x00 and Max_Data=0x3F.
Kojto 158:b23ee177fd68 2050 * @retval None
Kojto 158:b23ee177fd68 2051 */
Kojto 158:b23ee177fd68 2052 __STATIC_INLINE void LL_I2C_SetSlaveAddr(I2C_TypeDef *I2Cx, uint32_t SlaveAddr)
Kojto 158:b23ee177fd68 2053 {
Kojto 158:b23ee177fd68 2054 MODIFY_REG(I2Cx->CR2, I2C_CR2_SADD, SlaveAddr);
Kojto 158:b23ee177fd68 2055 }
Kojto 158:b23ee177fd68 2056
Kojto 158:b23ee177fd68 2057 /**
Kojto 158:b23ee177fd68 2058 * @brief Get the slave address programmed for transfer.
Kojto 158:b23ee177fd68 2059 * @rmtoll CR2 SADD LL_I2C_GetSlaveAddr
Kojto 158:b23ee177fd68 2060 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2061 * @retval Value between Min_Data=0x0 and Max_Data=0x3F
Kojto 158:b23ee177fd68 2062 */
Kojto 158:b23ee177fd68 2063 __STATIC_INLINE uint32_t LL_I2C_GetSlaveAddr(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2064 {
Kojto 158:b23ee177fd68 2065 return (uint32_t)(READ_BIT(I2Cx->CR2, I2C_CR2_SADD));
Kojto 158:b23ee177fd68 2066 }
Kojto 158:b23ee177fd68 2067
Kojto 158:b23ee177fd68 2068 /**
Kojto 158:b23ee177fd68 2069 * @brief Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set).
Kojto 158:b23ee177fd68 2070 * @rmtoll CR2 SADD LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2071 * CR2 ADD10 LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2072 * CR2 RD_WRN LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2073 * CR2 START LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2074 * CR2 STOP LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2075 * CR2 RELOAD LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2076 * CR2 NBYTES LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2077 * CR2 AUTOEND LL_I2C_HandleTransfer\n
Kojto 158:b23ee177fd68 2078 * CR2 HEAD10R LL_I2C_HandleTransfer
Kojto 158:b23ee177fd68 2079 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2080 * @param SlaveAddr Specifies the slave address to be programmed.
Kojto 158:b23ee177fd68 2081 * @param SlaveAddrSize This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2082 * @arg @ref LL_I2C_ADDRSLAVE_7BIT
Kojto 158:b23ee177fd68 2083 * @arg @ref LL_I2C_ADDRSLAVE_10BIT
Kojto 158:b23ee177fd68 2084 * @param TransferSize Specifies the number of bytes to be programmed.
Anna Bridge 186:707f6e361f3e 2085 * This parameter must be a value between Min_Data=0 and Max_Data=255.
Kojto 158:b23ee177fd68 2086 * @param EndMode This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2087 * @arg @ref LL_I2C_MODE_RELOAD
Kojto 158:b23ee177fd68 2088 * @arg @ref LL_I2C_MODE_AUTOEND
Kojto 158:b23ee177fd68 2089 * @arg @ref LL_I2C_MODE_SOFTEND
Kojto 158:b23ee177fd68 2090 * @arg @ref LL_I2C_MODE_SMBUS_RELOAD
Kojto 158:b23ee177fd68 2091 * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_NO_PEC
Kojto 158:b23ee177fd68 2092 * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_NO_PEC
Kojto 158:b23ee177fd68 2093 * @arg @ref LL_I2C_MODE_SMBUS_AUTOEND_WITH_PEC
Kojto 158:b23ee177fd68 2094 * @arg @ref LL_I2C_MODE_SMBUS_SOFTEND_WITH_PEC
Kojto 158:b23ee177fd68 2095 * @param Request This parameter can be one of the following values:
Kojto 158:b23ee177fd68 2096 * @arg @ref LL_I2C_GENERATE_NOSTARTSTOP
Kojto 158:b23ee177fd68 2097 * @arg @ref LL_I2C_GENERATE_STOP
Kojto 158:b23ee177fd68 2098 * @arg @ref LL_I2C_GENERATE_START_READ
Kojto 158:b23ee177fd68 2099 * @arg @ref LL_I2C_GENERATE_START_WRITE
Kojto 158:b23ee177fd68 2100 * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_READ
Kojto 158:b23ee177fd68 2101 * @arg @ref LL_I2C_GENERATE_RESTART_7BIT_WRITE
Kojto 158:b23ee177fd68 2102 * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_READ
Kojto 158:b23ee177fd68 2103 * @arg @ref LL_I2C_GENERATE_RESTART_10BIT_WRITE
Kojto 158:b23ee177fd68 2104 * @retval None
Kojto 158:b23ee177fd68 2105 */
Kojto 158:b23ee177fd68 2106 __STATIC_INLINE void LL_I2C_HandleTransfer(I2C_TypeDef *I2Cx, uint32_t SlaveAddr, uint32_t SlaveAddrSize,
Anna Bridge 186:707f6e361f3e 2107 uint32_t TransferSize, uint32_t EndMode, uint32_t Request)
Kojto 158:b23ee177fd68 2108 {
Anna Bridge 186:707f6e361f3e 2109 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 |
Kojto 158:b23ee177fd68 2110 I2C_CR2_NBYTES | I2C_CR2_AUTOEND | I2C_CR2_HEAD10R,
Anna Bridge 186:707f6e361f3e 2111 SlaveAddr | SlaveAddrSize | TransferSize << I2C_CR2_NBYTES_Pos | EndMode | Request);
Kojto 158:b23ee177fd68 2112 }
Kojto 158:b23ee177fd68 2113
Kojto 158:b23ee177fd68 2114 /**
Kojto 158:b23ee177fd68 2115 * @brief Indicate the value of transfer direction (slave mode).
Kojto 158:b23ee177fd68 2116 * @note RESET: Write transfer, Slave enters in receiver mode.
Kojto 158:b23ee177fd68 2117 * SET: Read transfer, Slave enters in transmitter mode.
Kojto 158:b23ee177fd68 2118 * @rmtoll ISR DIR LL_I2C_GetTransferDirection
Kojto 158:b23ee177fd68 2119 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2120 * @retval Returned value can be one of the following values:
Kojto 158:b23ee177fd68 2121 * @arg @ref LL_I2C_DIRECTION_WRITE
Kojto 158:b23ee177fd68 2122 * @arg @ref LL_I2C_DIRECTION_READ
Kojto 158:b23ee177fd68 2123 */
Kojto 158:b23ee177fd68 2124 __STATIC_INLINE uint32_t LL_I2C_GetTransferDirection(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2125 {
Kojto 158:b23ee177fd68 2126 return (uint32_t)(READ_BIT(I2Cx->ISR, I2C_ISR_DIR));
Kojto 158:b23ee177fd68 2127 }
Kojto 158:b23ee177fd68 2128
Kojto 158:b23ee177fd68 2129 /**
Kojto 158:b23ee177fd68 2130 * @brief Return the slave matched address.
Kojto 158:b23ee177fd68 2131 * @rmtoll ISR ADDCODE LL_I2C_GetAddressMatchCode
Kojto 158:b23ee177fd68 2132 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2133 * @retval Value between Min_Data=0x00 and Max_Data=0x3F
Kojto 158:b23ee177fd68 2134 */
Kojto 158:b23ee177fd68 2135 __STATIC_INLINE uint32_t LL_I2C_GetAddressMatchCode(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2136 {
Anna Bridge 186:707f6e361f3e 2137 return (uint32_t)(READ_BIT(I2Cx->ISR, I2C_ISR_ADDCODE) >> I2C_ISR_ADDCODE_Pos << 1);
Kojto 158:b23ee177fd68 2138 }
Kojto 158:b23ee177fd68 2139
Kojto 158:b23ee177fd68 2140 /**
Anna Bridge 186:707f6e361f3e 2141 * @brief Enable internal comparison of the SMBus Packet Error byte (transmission or reception mode).
Kojto 158:b23ee177fd68 2142 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 2143 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 2144 * @note This feature is cleared by hardware when the PEC byte is transferred, or when a STOP condition or an Address Matched is received.
Kojto 158:b23ee177fd68 2145 * This bit has no effect when RELOAD bit is set.
Kojto 158:b23ee177fd68 2146 * This bit has no effect in device mode when SBC bit is not set.
Kojto 158:b23ee177fd68 2147 * @rmtoll CR2 PECBYTE LL_I2C_EnableSMBusPECCompare
Kojto 158:b23ee177fd68 2148 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2149 * @retval None
Kojto 158:b23ee177fd68 2150 */
Kojto 158:b23ee177fd68 2151 __STATIC_INLINE void LL_I2C_EnableSMBusPECCompare(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2152 {
Kojto 158:b23ee177fd68 2153 SET_BIT(I2Cx->CR2, I2C_CR2_PECBYTE);
Kojto 158:b23ee177fd68 2154 }
Kojto 158:b23ee177fd68 2155
Kojto 158:b23ee177fd68 2156 /**
Anna Bridge 186:707f6e361f3e 2157 * @brief Check if the SMBus Packet Error byte internal comparison is requested or not.
Kojto 158:b23ee177fd68 2158 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 2159 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 2160 * @rmtoll CR2 PECBYTE LL_I2C_IsEnabledSMBusPECCompare
Kojto 158:b23ee177fd68 2161 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2162 * @retval State of bit (1 or 0).
Kojto 158:b23ee177fd68 2163 */
Kojto 158:b23ee177fd68 2164 __STATIC_INLINE uint32_t LL_I2C_IsEnabledSMBusPECCompare(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2165 {
Kojto 158:b23ee177fd68 2166 return (READ_BIT(I2Cx->CR2, I2C_CR2_PECBYTE) == (I2C_CR2_PECBYTE));
Kojto 158:b23ee177fd68 2167 }
Kojto 158:b23ee177fd68 2168
Kojto 158:b23ee177fd68 2169 /**
Anna Bridge 186:707f6e361f3e 2170 * @brief Get the SMBus Packet Error byte calculated.
Kojto 158:b23ee177fd68 2171 * @note Macro @ref IS_SMBUS_INSTANCE(I2Cx) can be used to check whether or not
Kojto 158:b23ee177fd68 2172 * SMBus feature is supported by the I2Cx Instance.
Kojto 158:b23ee177fd68 2173 * @rmtoll PECR PEC LL_I2C_GetSMBusPEC
Kojto 158:b23ee177fd68 2174 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2175 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 2176 */
Kojto 158:b23ee177fd68 2177 __STATIC_INLINE uint32_t LL_I2C_GetSMBusPEC(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2178 {
Kojto 158:b23ee177fd68 2179 return (uint32_t)(READ_BIT(I2Cx->PECR, I2C_PECR_PEC));
Kojto 158:b23ee177fd68 2180 }
Kojto 158:b23ee177fd68 2181
Kojto 158:b23ee177fd68 2182 /**
Kojto 158:b23ee177fd68 2183 * @brief Read Receive Data register.
Kojto 158:b23ee177fd68 2184 * @rmtoll RXDR RXDATA LL_I2C_ReceiveData8
Kojto 158:b23ee177fd68 2185 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2186 * @retval Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 2187 */
Kojto 158:b23ee177fd68 2188 __STATIC_INLINE uint8_t LL_I2C_ReceiveData8(I2C_TypeDef *I2Cx)
Kojto 158:b23ee177fd68 2189 {
Kojto 158:b23ee177fd68 2190 return (uint8_t)(READ_BIT(I2Cx->RXDR, I2C_RXDR_RXDATA));
Kojto 158:b23ee177fd68 2191 }
Kojto 158:b23ee177fd68 2192
Kojto 158:b23ee177fd68 2193 /**
Kojto 158:b23ee177fd68 2194 * @brief Write in Transmit Data Register .
Kojto 158:b23ee177fd68 2195 * @rmtoll TXDR TXDATA LL_I2C_TransmitData8
Kojto 158:b23ee177fd68 2196 * @param I2Cx I2C Instance.
Kojto 158:b23ee177fd68 2197 * @param Data Value between Min_Data=0x00 and Max_Data=0xFF
Kojto 158:b23ee177fd68 2198 * @retval None
Kojto 158:b23ee177fd68 2199 */
Kojto 158:b23ee177fd68 2200 __STATIC_INLINE void LL_I2C_TransmitData8(I2C_TypeDef *I2Cx, uint8_t Data)
Kojto 158:b23ee177fd68 2201 {
Kojto 158:b23ee177fd68 2202 WRITE_REG(I2Cx->TXDR, Data);
Kojto 158:b23ee177fd68 2203 }
Kojto 158:b23ee177fd68 2204
Kojto 158:b23ee177fd68 2205 /**
Kojto 158:b23ee177fd68 2206 * @}
Kojto 158:b23ee177fd68 2207 */
Kojto 158:b23ee177fd68 2208
Kojto 158:b23ee177fd68 2209 #if defined(USE_FULL_LL_DRIVER)
Kojto 158:b23ee177fd68 2210 /** @defgroup I2C_LL_EF_Init Initialization and de-initialization functions
Kojto 158:b23ee177fd68 2211 * @{
Kojto 158:b23ee177fd68 2212 */
Kojto 158:b23ee177fd68 2213
Kojto 158:b23ee177fd68 2214 uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct);
Kojto 158:b23ee177fd68 2215 uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx);
Kojto 158:b23ee177fd68 2216 void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct);
Kojto 158:b23ee177fd68 2217
Kojto 158:b23ee177fd68 2218
Kojto 158:b23ee177fd68 2219 /**
Kojto 158:b23ee177fd68 2220 * @}
Kojto 158:b23ee177fd68 2221 */
Kojto 158:b23ee177fd68 2222 #endif /* USE_FULL_LL_DRIVER */
Kojto 158:b23ee177fd68 2223
Kojto 158:b23ee177fd68 2224 /**
Kojto 158:b23ee177fd68 2225 * @}
Kojto 158:b23ee177fd68 2226 */
Kojto 158:b23ee177fd68 2227
Kojto 158:b23ee177fd68 2228 /**
Kojto 158:b23ee177fd68 2229 * @}
Kojto 158:b23ee177fd68 2230 */
Kojto 158:b23ee177fd68 2231
Kojto 158:b23ee177fd68 2232 #endif /* I2C1 || I2C2 || I2C3 */
Kojto 158:b23ee177fd68 2233
Kojto 158:b23ee177fd68 2234 /**
Kojto 158:b23ee177fd68 2235 * @}
Kojto 158:b23ee177fd68 2236 */
Kojto 158:b23ee177fd68 2237
Kojto 158:b23ee177fd68 2238 #ifdef __cplusplus
Kojto 158:b23ee177fd68 2239 }
Kojto 158:b23ee177fd68 2240 #endif
Kojto 158:b23ee177fd68 2241
Kojto 158:b23ee177fd68 2242 #endif /* __STM32L0xx_LL_I2C_H */
Kojto 158:b23ee177fd68 2243
Kojto 158:b23ee177fd68 2244 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/