Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed Sep 16 15:32:31 2015 +0100
Revision:
107:4f6c30876dfa
Release 107  of the mbed library

Changes:
- new platforms - DISCO_F746NG, DISCO_L476VG, NUCLEO_L476RG
- KL43Z - bugfix RTC init function
- K20 - SPI mode fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32l4xx_hal_i2c.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 107:4f6c30876dfa 5 * @version V1.0.0
Kojto 107:4f6c30876dfa 6 * @date 26-June-2015
Kojto 107:4f6c30876dfa 7 * @brief Header file of I2C HAL module.
Kojto 107:4f6c30876dfa 8 ******************************************************************************
Kojto 107:4f6c30876dfa 9 * @attention
Kojto 107:4f6c30876dfa 10 *
Kojto 107:4f6c30876dfa 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 107:4f6c30876dfa 12 *
Kojto 107:4f6c30876dfa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 107:4f6c30876dfa 14 * are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 16 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 19 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 107:4f6c30876dfa 21 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 22 * without specific prior written permission.
Kojto 107:4f6c30876dfa 23 *
Kojto 107:4f6c30876dfa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 34 *
Kojto 107:4f6c30876dfa 35 ******************************************************************************
Kojto 107:4f6c30876dfa 36 */
Kojto 107:4f6c30876dfa 37
Kojto 107:4f6c30876dfa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 107:4f6c30876dfa 39 #ifndef __STM32L4xx_HAL_I2C_H
Kojto 107:4f6c30876dfa 40 #define __STM32L4xx_HAL_I2C_H
Kojto 107:4f6c30876dfa 41
Kojto 107:4f6c30876dfa 42 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 43 extern "C" {
Kojto 107:4f6c30876dfa 44 #endif
Kojto 107:4f6c30876dfa 45
Kojto 107:4f6c30876dfa 46 /* Includes ------------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 47 #include "stm32l4xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 107:4f6c30876dfa 50 * @{
Kojto 107:4f6c30876dfa 51 */
Kojto 107:4f6c30876dfa 52
Kojto 107:4f6c30876dfa 53 /** @addtogroup I2C
Kojto 107:4f6c30876dfa 54 * @{
Kojto 107:4f6c30876dfa 55 */
Kojto 107:4f6c30876dfa 56
Kojto 107:4f6c30876dfa 57 /* Exported types ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 58 /** @defgroup I2C_Exported_Types I2C Exported Types
Kojto 107:4f6c30876dfa 59 * @{
Kojto 107:4f6c30876dfa 60 */
Kojto 107:4f6c30876dfa 61
Kojto 107:4f6c30876dfa 62 /** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
Kojto 107:4f6c30876dfa 63 * @brief I2C Configuration Structure definition
Kojto 107:4f6c30876dfa 64 * @{
Kojto 107:4f6c30876dfa 65 */
Kojto 107:4f6c30876dfa 66 typedef struct
Kojto 107:4f6c30876dfa 67 {
Kojto 107:4f6c30876dfa 68 uint32_t Timing; /*!< Specifies the I2C_TIMINGR_register value.
Kojto 107:4f6c30876dfa 69 This parameter calculated by referring to I2C initialization
Kojto 107:4f6c30876dfa 70 section in Reference manual */
Kojto 107:4f6c30876dfa 71
Kojto 107:4f6c30876dfa 72 uint32_t OwnAddress1; /*!< Specifies the first device own address.
Kojto 107:4f6c30876dfa 73 This parameter can be a 7-bit or 10-bit address. */
Kojto 107:4f6c30876dfa 74
Kojto 107:4f6c30876dfa 75 uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
Kojto 107:4f6c30876dfa 76 This parameter can be a value of @ref I2C_addressing_mode */
Kojto 107:4f6c30876dfa 77
Kojto 107:4f6c30876dfa 78 uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
Kojto 107:4f6c30876dfa 79 This parameter can be a value of @ref I2C_dual_addressing_mode */
Kojto 107:4f6c30876dfa 80
Kojto 107:4f6c30876dfa 81 uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
Kojto 107:4f6c30876dfa 82 This parameter can be a 7-bit address. */
Kojto 107:4f6c30876dfa 83
Kojto 107:4f6c30876dfa 84 uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing mode is selected
Kojto 107:4f6c30876dfa 85 This parameter can be a value of @ref I2C_own_address2_masks */
Kojto 107:4f6c30876dfa 86
Kojto 107:4f6c30876dfa 87 uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
Kojto 107:4f6c30876dfa 88 This parameter can be a value of @ref I2C_general_call_addressing_mode */
Kojto 107:4f6c30876dfa 89
Kojto 107:4f6c30876dfa 90 uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
Kojto 107:4f6c30876dfa 91 This parameter can be a value of @ref I2C_nostretch_mode */
Kojto 107:4f6c30876dfa 92
Kojto 107:4f6c30876dfa 93 }I2C_InitTypeDef;
Kojto 107:4f6c30876dfa 94
Kojto 107:4f6c30876dfa 95 /**
Kojto 107:4f6c30876dfa 96 * @}
Kojto 107:4f6c30876dfa 97 */
Kojto 107:4f6c30876dfa 98
Kojto 107:4f6c30876dfa 99 /** @defgroup HAL_state_structure_definition HAL state structure definition
Kojto 107:4f6c30876dfa 100 * @brief HAL State structure definition
Kojto 107:4f6c30876dfa 101 * @{
Kojto 107:4f6c30876dfa 102 */
Kojto 107:4f6c30876dfa 103
Kojto 107:4f6c30876dfa 104 typedef enum
Kojto 107:4f6c30876dfa 105 {
Kojto 107:4f6c30876dfa 106 HAL_I2C_STATE_RESET = 0x00, /*!< I2C not yet initialized or disabled */
Kojto 107:4f6c30876dfa 107 HAL_I2C_STATE_READY = 0x01, /*!< I2C initialized and ready for use */
Kojto 107:4f6c30876dfa 108 HAL_I2C_STATE_BUSY = 0x02, /*!< I2C internal process is ongoing */
Kojto 107:4f6c30876dfa 109 HAL_I2C_STATE_MASTER_BUSY_TX = 0x12, /*!< Master Data Transmission process is ongoing */
Kojto 107:4f6c30876dfa 110 HAL_I2C_STATE_MASTER_BUSY_RX = 0x22, /*!< Master Data Reception process is ongoing */
Kojto 107:4f6c30876dfa 111 HAL_I2C_STATE_SLAVE_BUSY_TX = 0x32, /*!< Slave Data Transmission process is ongoing */
Kojto 107:4f6c30876dfa 112 HAL_I2C_STATE_SLAVE_BUSY_RX = 0x42, /*!< Slave Data Reception process is ongoing */
Kojto 107:4f6c30876dfa 113 HAL_I2C_STATE_MEM_BUSY_TX = 0x52, /*!< Memory Data Transmission process is ongoing */
Kojto 107:4f6c30876dfa 114 HAL_I2C_STATE_MEM_BUSY_RX = 0x62, /*!< Memory Data Reception process is ongoing */
Kojto 107:4f6c30876dfa 115 HAL_I2C_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 107:4f6c30876dfa 116 HAL_I2C_STATE_ERROR = 0x04 /*!< Reception process is ongoing */
Kojto 107:4f6c30876dfa 117 }HAL_I2C_StateTypeDef;
Kojto 107:4f6c30876dfa 118
Kojto 107:4f6c30876dfa 119 /**
Kojto 107:4f6c30876dfa 120 * @}
Kojto 107:4f6c30876dfa 121 */
Kojto 107:4f6c30876dfa 122
Kojto 107:4f6c30876dfa 123 /** @defgroup I2C_Error_Code_definition I2C Error Code definition
Kojto 107:4f6c30876dfa 124 * @brief I2C Error Code definition
Kojto 107:4f6c30876dfa 125 * @{
Kojto 107:4f6c30876dfa 126 */
Kojto 107:4f6c30876dfa 127 #define HAL_I2C_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 107:4f6c30876dfa 128 #define HAL_I2C_ERROR_BERR ((uint32_t)0x00000001) /*!< BERR error */
Kojto 107:4f6c30876dfa 129 #define HAL_I2C_ERROR_ARLO ((uint32_t)0x00000002) /*!< ARLO error */
Kojto 107:4f6c30876dfa 130 #define HAL_I2C_ERROR_AF ((uint32_t)0x00000004) /*!< ACKF error */
Kojto 107:4f6c30876dfa 131 #define HAL_I2C_ERROR_OVR ((uint32_t)0x00000008) /*!< OVR error */
Kojto 107:4f6c30876dfa 132 #define HAL_I2C_ERROR_DMA ((uint32_t)0x00000010) /*!< DMA transfer error */
Kojto 107:4f6c30876dfa 133 #define HAL_I2C_ERROR_TIMEOUT ((uint32_t)0x00000020) /*!< Timeout error */
Kojto 107:4f6c30876dfa 134 #define HAL_I2C_ERROR_SIZE ((uint32_t)0x00000040) /*!< Size Management error */
Kojto 107:4f6c30876dfa 135 /**
Kojto 107:4f6c30876dfa 136 * @}
Kojto 107:4f6c30876dfa 137 */
Kojto 107:4f6c30876dfa 138
Kojto 107:4f6c30876dfa 139 /** @defgroup I2C_handle_Structure_definition I2C handle Structure definition
Kojto 107:4f6c30876dfa 140 * @brief I2C handle Structure definition
Kojto 107:4f6c30876dfa 141 * @{
Kojto 107:4f6c30876dfa 142 */
Kojto 107:4f6c30876dfa 143 typedef struct
Kojto 107:4f6c30876dfa 144 {
Kojto 107:4f6c30876dfa 145 I2C_TypeDef *Instance; /*!< I2C registers base address */
Kojto 107:4f6c30876dfa 146
Kojto 107:4f6c30876dfa 147 I2C_InitTypeDef Init; /*!< I2C communication parameters */
Kojto 107:4f6c30876dfa 148
Kojto 107:4f6c30876dfa 149 uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
Kojto 107:4f6c30876dfa 150
Kojto 107:4f6c30876dfa 151 uint16_t XferSize; /*!< I2C transfer size */
Kojto 107:4f6c30876dfa 152
Kojto 107:4f6c30876dfa 153 __IO uint16_t XferCount; /*!< I2C transfer counter */
Kojto 107:4f6c30876dfa 154
Kojto 107:4f6c30876dfa 155 DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
Kojto 107:4f6c30876dfa 156
Kojto 107:4f6c30876dfa 157 DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
Kojto 107:4f6c30876dfa 158
Kojto 107:4f6c30876dfa 159 HAL_LockTypeDef Lock; /*!< I2C locking object */
Kojto 107:4f6c30876dfa 160
Kojto 107:4f6c30876dfa 161 __IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
Kojto 107:4f6c30876dfa 162
Kojto 107:4f6c30876dfa 163 __IO uint32_t ErrorCode; /* I2C Error code */
Kojto 107:4f6c30876dfa 164
Kojto 107:4f6c30876dfa 165 }I2C_HandleTypeDef;
Kojto 107:4f6c30876dfa 166 /**
Kojto 107:4f6c30876dfa 167 * @}
Kojto 107:4f6c30876dfa 168 */
Kojto 107:4f6c30876dfa 169
Kojto 107:4f6c30876dfa 170 /**
Kojto 107:4f6c30876dfa 171 * @}
Kojto 107:4f6c30876dfa 172 */
Kojto 107:4f6c30876dfa 173 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 174
Kojto 107:4f6c30876dfa 175 /** @defgroup I2C_Exported_Constants I2C Exported Constants
Kojto 107:4f6c30876dfa 176 * @{
Kojto 107:4f6c30876dfa 177 */
Kojto 107:4f6c30876dfa 178
Kojto 107:4f6c30876dfa 179 /** @defgroup I2C_addressing_mode I2C addressing mode
Kojto 107:4f6c30876dfa 180 * @{
Kojto 107:4f6c30876dfa 181 */
Kojto 107:4f6c30876dfa 182 #define I2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 183 #define I2C_ADDRESSINGMODE_10BIT ((uint32_t)0x00000002)
Kojto 107:4f6c30876dfa 184 /**
Kojto 107:4f6c30876dfa 185 * @}
Kojto 107:4f6c30876dfa 186 */
Kojto 107:4f6c30876dfa 187
Kojto 107:4f6c30876dfa 188 /** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
Kojto 107:4f6c30876dfa 189 * @{
Kojto 107:4f6c30876dfa 190 */
Kojto 107:4f6c30876dfa 191 #define I2C_DUALADDRESS_DISABLE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 192 #define I2C_DUALADDRESS_ENABLE I2C_OAR2_OA2EN
Kojto 107:4f6c30876dfa 193 /**
Kojto 107:4f6c30876dfa 194 * @}
Kojto 107:4f6c30876dfa 195 */
Kojto 107:4f6c30876dfa 196
Kojto 107:4f6c30876dfa 197 /** @defgroup I2C_own_address2_masks I2C own address2 masks
Kojto 107:4f6c30876dfa 198 * @{
Kojto 107:4f6c30876dfa 199 */
Kojto 107:4f6c30876dfa 200 #define I2C_OA2_NOMASK ((uint8_t)0x00)
Kojto 107:4f6c30876dfa 201 #define I2C_OA2_MASK01 ((uint8_t)0x01)
Kojto 107:4f6c30876dfa 202 #define I2C_OA2_MASK02 ((uint8_t)0x02)
Kojto 107:4f6c30876dfa 203 #define I2C_OA2_MASK03 ((uint8_t)0x03)
Kojto 107:4f6c30876dfa 204 #define I2C_OA2_MASK04 ((uint8_t)0x04)
Kojto 107:4f6c30876dfa 205 #define I2C_OA2_MASK05 ((uint8_t)0x05)
Kojto 107:4f6c30876dfa 206 #define I2C_OA2_MASK06 ((uint8_t)0x06)
Kojto 107:4f6c30876dfa 207 #define I2C_OA2_MASK07 ((uint8_t)0x07)
Kojto 107:4f6c30876dfa 208 /**
Kojto 107:4f6c30876dfa 209 * @}
Kojto 107:4f6c30876dfa 210 */
Kojto 107:4f6c30876dfa 211
Kojto 107:4f6c30876dfa 212 /** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
Kojto 107:4f6c30876dfa 213 * @{
Kojto 107:4f6c30876dfa 214 */
Kojto 107:4f6c30876dfa 215 #define I2C_GENERALCALL_DISABLE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 216 #define I2C_GENERALCALL_ENABLE I2C_CR1_GCEN
Kojto 107:4f6c30876dfa 217 /**
Kojto 107:4f6c30876dfa 218 * @}
Kojto 107:4f6c30876dfa 219 */
Kojto 107:4f6c30876dfa 220
Kojto 107:4f6c30876dfa 221 /** @defgroup I2C_nostretch_mode I2C nostretch mode
Kojto 107:4f6c30876dfa 222 * @{
Kojto 107:4f6c30876dfa 223 */
Kojto 107:4f6c30876dfa 224 #define I2C_NOSTRETCH_DISABLE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 225 #define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
Kojto 107:4f6c30876dfa 226 /**
Kojto 107:4f6c30876dfa 227 * @}
Kojto 107:4f6c30876dfa 228 */
Kojto 107:4f6c30876dfa 229
Kojto 107:4f6c30876dfa 230 /** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
Kojto 107:4f6c30876dfa 231 * @{
Kojto 107:4f6c30876dfa 232 */
Kojto 107:4f6c30876dfa 233 #define I2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 234 #define I2C_MEMADD_SIZE_16BIT ((uint32_t)0x00000002)
Kojto 107:4f6c30876dfa 235 /**
Kojto 107:4f6c30876dfa 236 * @}
Kojto 107:4f6c30876dfa 237 */
Kojto 107:4f6c30876dfa 238
Kojto 107:4f6c30876dfa 239 /** @defgroup I2C_ReloadEndMode_definition I2C ReloadEndMode definition
Kojto 107:4f6c30876dfa 240 * @{
Kojto 107:4f6c30876dfa 241 */
Kojto 107:4f6c30876dfa 242 #define I2C_RELOAD_MODE I2C_CR2_RELOAD
Kojto 107:4f6c30876dfa 243 #define I2C_AUTOEND_MODE I2C_CR2_AUTOEND
Kojto 107:4f6c30876dfa 244 #define I2C_SOFTEND_MODE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 245 /**
Kojto 107:4f6c30876dfa 246 * @}
Kojto 107:4f6c30876dfa 247 */
Kojto 107:4f6c30876dfa 248
Kojto 107:4f6c30876dfa 249 /** @defgroup I2C_StartStopMode_definition I2C StartStopMode definition
Kojto 107:4f6c30876dfa 250 * @{
Kojto 107:4f6c30876dfa 251 */
Kojto 107:4f6c30876dfa 252 #define I2C_NO_STARTSTOP ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 253 #define I2C_GENERATE_STOP I2C_CR2_STOP
Kojto 107:4f6c30876dfa 254 #define I2C_GENERATE_START_READ (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)
Kojto 107:4f6c30876dfa 255 #define I2C_GENERATE_START_WRITE I2C_CR2_START
Kojto 107:4f6c30876dfa 256 /**
Kojto 107:4f6c30876dfa 257 * @}
Kojto 107:4f6c30876dfa 258 */
Kojto 107:4f6c30876dfa 259
Kojto 107:4f6c30876dfa 260 /** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
Kojto 107:4f6c30876dfa 261 * @brief I2C Interrupt definition
Kojto 107:4f6c30876dfa 262 * Elements values convention: 0xXXXXXXXX
Kojto 107:4f6c30876dfa 263 * - XXXXXXXX : Interrupt control mask
Kojto 107:4f6c30876dfa 264 * @{
Kojto 107:4f6c30876dfa 265 */
Kojto 107:4f6c30876dfa 266 #define I2C_IT_ERRI I2C_CR1_ERRIE
Kojto 107:4f6c30876dfa 267 #define I2C_IT_TCI I2C_CR1_TCIE
Kojto 107:4f6c30876dfa 268 #define I2C_IT_STOPI I2C_CR1_STOPIE
Kojto 107:4f6c30876dfa 269 #define I2C_IT_NACKI I2C_CR1_NACKIE
Kojto 107:4f6c30876dfa 270 #define I2C_IT_ADDRI I2C_CR1_ADDRIE
Kojto 107:4f6c30876dfa 271 #define I2C_IT_RXI I2C_CR1_RXIE
Kojto 107:4f6c30876dfa 272 #define I2C_IT_TXI I2C_CR1_TXIE
Kojto 107:4f6c30876dfa 273
Kojto 107:4f6c30876dfa 274 /**
Kojto 107:4f6c30876dfa 275 * @}
Kojto 107:4f6c30876dfa 276 */
Kojto 107:4f6c30876dfa 277
Kojto 107:4f6c30876dfa 278
Kojto 107:4f6c30876dfa 279 /** @defgroup I2C_Flag_definition I2C Flag definition
Kojto 107:4f6c30876dfa 280 * @{
Kojto 107:4f6c30876dfa 281 */
Kojto 107:4f6c30876dfa 282 #define I2C_FLAG_TXE I2C_ISR_TXE
Kojto 107:4f6c30876dfa 283 #define I2C_FLAG_TXIS I2C_ISR_TXIS
Kojto 107:4f6c30876dfa 284 #define I2C_FLAG_RXNE I2C_ISR_RXNE
Kojto 107:4f6c30876dfa 285 #define I2C_FLAG_ADDR I2C_ISR_ADDR
Kojto 107:4f6c30876dfa 286 #define I2C_FLAG_AF I2C_ISR_NACKF
Kojto 107:4f6c30876dfa 287 #define I2C_FLAG_STOPF I2C_ISR_STOPF
Kojto 107:4f6c30876dfa 288 #define I2C_FLAG_TC I2C_ISR_TC
Kojto 107:4f6c30876dfa 289 #define I2C_FLAG_TCR I2C_ISR_TCR
Kojto 107:4f6c30876dfa 290 #define I2C_FLAG_BERR I2C_ISR_BERR
Kojto 107:4f6c30876dfa 291 #define I2C_FLAG_ARLO I2C_ISR_ARLO
Kojto 107:4f6c30876dfa 292 #define I2C_FLAG_OVR I2C_ISR_OVR
Kojto 107:4f6c30876dfa 293 #define I2C_FLAG_PECERR I2C_ISR_PECERR
Kojto 107:4f6c30876dfa 294 #define I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT
Kojto 107:4f6c30876dfa 295 #define I2C_FLAG_ALERT I2C_ISR_ALERT
Kojto 107:4f6c30876dfa 296 #define I2C_FLAG_BUSY I2C_ISR_BUSY
Kojto 107:4f6c30876dfa 297 #define I2C_FLAG_DIR I2C_ISR_DIR
Kojto 107:4f6c30876dfa 298 /**
Kojto 107:4f6c30876dfa 299 * @}
Kojto 107:4f6c30876dfa 300 */
Kojto 107:4f6c30876dfa 301
Kojto 107:4f6c30876dfa 302 /**
Kojto 107:4f6c30876dfa 303 * @}
Kojto 107:4f6c30876dfa 304 */
Kojto 107:4f6c30876dfa 305
Kojto 107:4f6c30876dfa 306 /* Exported macros -----------------------------------------------------------*/
Kojto 107:4f6c30876dfa 307
Kojto 107:4f6c30876dfa 308 /** @defgroup I2C_Exported_Macros I2C Exported Macros
Kojto 107:4f6c30876dfa 309 * @{
Kojto 107:4f6c30876dfa 310 */
Kojto 107:4f6c30876dfa 311
Kojto 107:4f6c30876dfa 312 /** @brief Reset I2C handle state.
Kojto 107:4f6c30876dfa 313 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 314 * @retval None
Kojto 107:4f6c30876dfa 315 */
Kojto 107:4f6c30876dfa 316 #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
Kojto 107:4f6c30876dfa 317
Kojto 107:4f6c30876dfa 318 /** @brief Enable the specified I2C interrupt.
Kojto 107:4f6c30876dfa 319 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 320 * @param __INTERRUPT__: specifies the interrupt source to enable.
Kojto 107:4f6c30876dfa 321 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 322 * @arg I2C_IT_ERRI: Errors interrupt enable
Kojto 107:4f6c30876dfa 323 * @arg I2C_IT_TCI: Transfer complete interrupt enable
Kojto 107:4f6c30876dfa 324 * @arg I2C_IT_STOPI: STOP detection interrupt enable
Kojto 107:4f6c30876dfa 325 * @arg I2C_IT_NACKI: NACK received interrupt enable
Kojto 107:4f6c30876dfa 326 * @arg I2C_IT_ADDRI: Address match interrupt enable
Kojto 107:4f6c30876dfa 327 * @arg I2C_IT_RXI: RX interrupt enable
Kojto 107:4f6c30876dfa 328 * @arg I2C_IT_TXI: TX interrupt enable
Kojto 107:4f6c30876dfa 329 *
Kojto 107:4f6c30876dfa 330 * @retval None
Kojto 107:4f6c30876dfa 331 */
Kojto 107:4f6c30876dfa 332
Kojto 107:4f6c30876dfa 333 #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
Kojto 107:4f6c30876dfa 334
Kojto 107:4f6c30876dfa 335 /** @brief Disable the specified I2C interrupt.
Kojto 107:4f6c30876dfa 336 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 337 * @param __INTERRUPT__: specifies the interrupt source to disable.
Kojto 107:4f6c30876dfa 338 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 339 * @arg I2C_IT_ERRI: Errors interrupt enable
Kojto 107:4f6c30876dfa 340 * @arg I2C_IT_TCI: Transfer complete interrupt enable
Kojto 107:4f6c30876dfa 341 * @arg I2C_IT_STOPI: STOP detection interrupt enable
Kojto 107:4f6c30876dfa 342 * @arg I2C_IT_NACKI: NACK received interrupt enable
Kojto 107:4f6c30876dfa 343 * @arg I2C_IT_ADDRI: Address match interrupt enable
Kojto 107:4f6c30876dfa 344 * @arg I2C_IT_RXI: RX interrupt enable
Kojto 107:4f6c30876dfa 345 * @arg I2C_IT_TXI: TX interrupt enable
Kojto 107:4f6c30876dfa 346 *
Kojto 107:4f6c30876dfa 347 * @retval None
Kojto 107:4f6c30876dfa 348 */
Kojto 107:4f6c30876dfa 349 #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
Kojto 107:4f6c30876dfa 350
Kojto 107:4f6c30876dfa 351 /** @brief Check whether the specified I2C interrupt source is enabled or not.
Kojto 107:4f6c30876dfa 352 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 353 * @param __INTERRUPT__: specifies the I2C interrupt source to check.
Kojto 107:4f6c30876dfa 354 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 355 * @arg I2C_IT_ERRI: Errors interrupt enable
Kojto 107:4f6c30876dfa 356 * @arg I2C_IT_TCI: Transfer complete interrupt enable
Kojto 107:4f6c30876dfa 357 * @arg I2C_IT_STOPI: STOP detection interrupt enable
Kojto 107:4f6c30876dfa 358 * @arg I2C_IT_NACKI: NACK received interrupt enable
Kojto 107:4f6c30876dfa 359 * @arg I2C_IT_ADDRI: Address match interrupt enable
Kojto 107:4f6c30876dfa 360 * @arg I2C_IT_RXI: RX interrupt enable
Kojto 107:4f6c30876dfa 361 * @arg I2C_IT_TXI: TX interrupt enable
Kojto 107:4f6c30876dfa 362 *
Kojto 107:4f6c30876dfa 363 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
Kojto 107:4f6c30876dfa 364 */
Kojto 107:4f6c30876dfa 365 #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 107:4f6c30876dfa 366
Kojto 107:4f6c30876dfa 367 /** @brief Check whether the specified I2C flag is set or not.
Kojto 107:4f6c30876dfa 368 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 369 * @param __FLAG__: specifies the flag to check.
Kojto 107:4f6c30876dfa 370 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 371 * @arg I2C_FLAG_TXE: Transmit data register empty
Kojto 107:4f6c30876dfa 372 * @arg I2C_FLAG_TXIS: Transmit interrupt status
Kojto 107:4f6c30876dfa 373 * @arg I2C_FLAG_RXNE: Receive data register not empty
Kojto 107:4f6c30876dfa 374 * @arg I2C_FLAG_ADDR: Address matched (slave mode)
Kojto 107:4f6c30876dfa 375 * @arg I2C_FLAG_AF: Acknowledge failure received flag
Kojto 107:4f6c30876dfa 376 * @arg I2C_FLAG_STOPF: STOP detection flag
Kojto 107:4f6c30876dfa 377 * @arg I2C_FLAG_TC: Transfer complete (master mode)
Kojto 107:4f6c30876dfa 378 * @arg I2C_FLAG_TCR: Transfer complete reload
Kojto 107:4f6c30876dfa 379 * @arg I2C_FLAG_BERR: Bus error
Kojto 107:4f6c30876dfa 380 * @arg I2C_FLAG_ARLO: Arbitration lost
Kojto 107:4f6c30876dfa 381 * @arg I2C_FLAG_OVR: Overrun/Underrun
Kojto 107:4f6c30876dfa 382 * @arg I2C_FLAG_PECERR: PEC error in reception
Kojto 107:4f6c30876dfa 383 * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
Kojto 107:4f6c30876dfa 384 * @arg I2C_FLAG_ALERT: SMBus alert
Kojto 107:4f6c30876dfa 385 * @arg I2C_FLAG_BUSY: Bus busy
Kojto 107:4f6c30876dfa 386 * @arg I2C_FLAG_DIR: Transfer direction (slave mode)
Kojto 107:4f6c30876dfa 387 *
Kojto 107:4f6c30876dfa 388 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 107:4f6c30876dfa 389 */
Kojto 107:4f6c30876dfa 390 #define I2C_FLAG_MASK ((uint32_t)0x0001FFFF)
Kojto 107:4f6c30876dfa 391 #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)))
Kojto 107:4f6c30876dfa 392
Kojto 107:4f6c30876dfa 393 /** @brief Clear the I2C pending flags which are cleared by writing 1 in a specific bit.
Kojto 107:4f6c30876dfa 394 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 395 * @param __FLAG__: specifies the flag to clear.
Kojto 107:4f6c30876dfa 396 * This parameter can be any combination of the following values:
Kojto 107:4f6c30876dfa 397 * @arg I2C_FLAG_ADDR: Address matched (slave mode)
Kojto 107:4f6c30876dfa 398 * @arg I2C_FLAG_AF: Acknowledge failure received flag
Kojto 107:4f6c30876dfa 399 * @arg I2C_FLAG_STOPF: STOP detection flag
Kojto 107:4f6c30876dfa 400 * @arg I2C_FLAG_BERR: Bus error
Kojto 107:4f6c30876dfa 401 * @arg I2C_FLAG_ARLO: Arbitration lost
Kojto 107:4f6c30876dfa 402 * @arg I2C_FLAG_OVR: Overrun/Underrun
Kojto 107:4f6c30876dfa 403 * @arg I2C_FLAG_PECERR: PEC error in reception
Kojto 107:4f6c30876dfa 404 * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag
Kojto 107:4f6c30876dfa 405 * @arg I2C_FLAG_ALERT: SMBus alert
Kojto 107:4f6c30876dfa 406 *
Kojto 107:4f6c30876dfa 407 * @retval None
Kojto 107:4f6c30876dfa 408 */
Kojto 107:4f6c30876dfa 409 #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = ((__FLAG__) & I2C_FLAG_MASK))
Kojto 107:4f6c30876dfa 410
Kojto 107:4f6c30876dfa 411 /** @brief Enable the specified I2C peripheral.
Kojto 107:4f6c30876dfa 412 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 413 * @retval None
Kojto 107:4f6c30876dfa 414 */
Kojto 107:4f6c30876dfa 415 #define __HAL_I2C_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
Kojto 107:4f6c30876dfa 416
Kojto 107:4f6c30876dfa 417 /** @brief Disable the specified I2C peripheral.
Kojto 107:4f6c30876dfa 418 * @param __HANDLE__: specifies the I2C Handle.
Kojto 107:4f6c30876dfa 419 * @retval None
Kojto 107:4f6c30876dfa 420 */
Kojto 107:4f6c30876dfa 421 #define __HAL_I2C_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE))
Kojto 107:4f6c30876dfa 422
Kojto 107:4f6c30876dfa 423 /**
Kojto 107:4f6c30876dfa 424 * @}
Kojto 107:4f6c30876dfa 425 */
Kojto 107:4f6c30876dfa 426
Kojto 107:4f6c30876dfa 427 /* Include I2C HAL Extended module */
Kojto 107:4f6c30876dfa 428 #include "stm32l4xx_hal_i2c_ex.h"
Kojto 107:4f6c30876dfa 429
Kojto 107:4f6c30876dfa 430 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 431 /** @addtogroup I2C_Exported_Functions
Kojto 107:4f6c30876dfa 432 * @{
Kojto 107:4f6c30876dfa 433 */
Kojto 107:4f6c30876dfa 434
Kojto 107:4f6c30876dfa 435 /** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 107:4f6c30876dfa 436 * @{
Kojto 107:4f6c30876dfa 437 */
Kojto 107:4f6c30876dfa 438 /* Initialization and de-initialization functions******************************/
Kojto 107:4f6c30876dfa 439 HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 440 HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 441 void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 442 void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 443 /**
Kojto 107:4f6c30876dfa 444 * @}
Kojto 107:4f6c30876dfa 445 */
Kojto 107:4f6c30876dfa 446
Kojto 107:4f6c30876dfa 447 /** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
Kojto 107:4f6c30876dfa 448 * @{
Kojto 107:4f6c30876dfa 449 */
Kojto 107:4f6c30876dfa 450 /* IO operation functions ****************************************************/
Kojto 107:4f6c30876dfa 451 /******* Blocking mode: Polling */
Kojto 107:4f6c30876dfa 452 HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 453 HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 454 HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 455 HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 456 HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 457 HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 107:4f6c30876dfa 458 HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
Kojto 107:4f6c30876dfa 459
Kojto 107:4f6c30876dfa 460 /******* Non-Blocking mode: Interrupt */
Kojto 107:4f6c30876dfa 461 HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 462 HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 463 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 464 HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 465 HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 466 HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 467
Kojto 107:4f6c30876dfa 468 /******* Non-Blocking mode: DMA */
Kojto 107:4f6c30876dfa 469 HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 470 HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 471 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 472 HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 473 HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 474 HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 107:4f6c30876dfa 475 /**
Kojto 107:4f6c30876dfa 476 * @}
Kojto 107:4f6c30876dfa 477 */
Kojto 107:4f6c30876dfa 478
Kojto 107:4f6c30876dfa 479 /** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
Kojto 107:4f6c30876dfa 480 * @{
Kojto 107:4f6c30876dfa 481 */
Kojto 107:4f6c30876dfa 482 /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
Kojto 107:4f6c30876dfa 483 void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 484 void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 485 void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 486 void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 487 void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 488 void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 489 void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 490 void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 491 void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 492 /**
Kojto 107:4f6c30876dfa 493 * @}
Kojto 107:4f6c30876dfa 494 */
Kojto 107:4f6c30876dfa 495
Kojto 107:4f6c30876dfa 496 /** @addtogroup I2C_Exported_Functions_Group3 Peripheral State and Errors functions
Kojto 107:4f6c30876dfa 497 * @{
Kojto 107:4f6c30876dfa 498 */
Kojto 107:4f6c30876dfa 499 /* Peripheral State and Errors functions *************************************/
Kojto 107:4f6c30876dfa 500 HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 501 uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
Kojto 107:4f6c30876dfa 502
Kojto 107:4f6c30876dfa 503 /**
Kojto 107:4f6c30876dfa 504 * @}
Kojto 107:4f6c30876dfa 505 */
Kojto 107:4f6c30876dfa 506
Kojto 107:4f6c30876dfa 507 /**
Kojto 107:4f6c30876dfa 508 * @}
Kojto 107:4f6c30876dfa 509 */
Kojto 107:4f6c30876dfa 510
Kojto 107:4f6c30876dfa 511 /* Private constants ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 512 /** @defgroup I2C_Private_Constants I2C Private Constants
Kojto 107:4f6c30876dfa 513 * @{
Kojto 107:4f6c30876dfa 514 */
Kojto 107:4f6c30876dfa 515
Kojto 107:4f6c30876dfa 516 /**
Kojto 107:4f6c30876dfa 517 * @}
Kojto 107:4f6c30876dfa 518 */
Kojto 107:4f6c30876dfa 519
Kojto 107:4f6c30876dfa 520 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 521 /** @defgroup I2C_Private_Macro I2C Private Macros
Kojto 107:4f6c30876dfa 522 * @{
Kojto 107:4f6c30876dfa 523 */
Kojto 107:4f6c30876dfa 524
Kojto 107:4f6c30876dfa 525 #define IS_I2C_ADDRESSING_MODE(MODE) (((MODE) == I2C_ADDRESSINGMODE_7BIT) || \
Kojto 107:4f6c30876dfa 526 ((MODE) == I2C_ADDRESSINGMODE_10BIT))
Kojto 107:4f6c30876dfa 527
Kojto 107:4f6c30876dfa 528 #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
Kojto 107:4f6c30876dfa 529 ((ADDRESS) == I2C_DUALADDRESS_ENABLE))
Kojto 107:4f6c30876dfa 530
Kojto 107:4f6c30876dfa 531 #define IS_I2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == I2C_OA2_NOMASK) || \
Kojto 107:4f6c30876dfa 532 ((MASK) == I2C_OA2_MASK01) || \
Kojto 107:4f6c30876dfa 533 ((MASK) == I2C_OA2_MASK02) || \
Kojto 107:4f6c30876dfa 534 ((MASK) == I2C_OA2_MASK03) || \
Kojto 107:4f6c30876dfa 535 ((MASK) == I2C_OA2_MASK04) || \
Kojto 107:4f6c30876dfa 536 ((MASK) == I2C_OA2_MASK05) || \
Kojto 107:4f6c30876dfa 537 ((MASK) == I2C_OA2_MASK06) || \
Kojto 107:4f6c30876dfa 538 ((MASK) == I2C_OA2_MASK07))
Kojto 107:4f6c30876dfa 539
Kojto 107:4f6c30876dfa 540 #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
Kojto 107:4f6c30876dfa 541 ((CALL) == I2C_GENERALCALL_ENABLE))
Kojto 107:4f6c30876dfa 542
Kojto 107:4f6c30876dfa 543 #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
Kojto 107:4f6c30876dfa 544 ((STRETCH) == I2C_NOSTRETCH_ENABLE))
Kojto 107:4f6c30876dfa 545
Kojto 107:4f6c30876dfa 546 #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
Kojto 107:4f6c30876dfa 547 ((SIZE) == I2C_MEMADD_SIZE_16BIT))
Kojto 107:4f6c30876dfa 548
Kojto 107:4f6c30876dfa 549
Kojto 107:4f6c30876dfa 550 #define IS_TRANSFER_MODE(MODE) (((MODE) == I2C_RELOAD_MODE) || \
Kojto 107:4f6c30876dfa 551 ((MODE) == I2C_AUTOEND_MODE) || \
Kojto 107:4f6c30876dfa 552 ((MODE) == I2C_SOFTEND_MODE))
Kojto 107:4f6c30876dfa 553
Kojto 107:4f6c30876dfa 554 #define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == I2C_GENERATE_STOP) || \
Kojto 107:4f6c30876dfa 555 ((REQUEST) == I2C_GENERATE_START_READ) || \
Kojto 107:4f6c30876dfa 556 ((REQUEST) == I2C_GENERATE_START_WRITE) || \
Kojto 107:4f6c30876dfa 557 ((REQUEST) == I2C_NO_STARTSTOP))
Kojto 107:4f6c30876dfa 558
Kojto 107:4f6c30876dfa 559
Kojto 107:4f6c30876dfa 560 #define I2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN)))
Kojto 107:4f6c30876dfa 561
Kojto 107:4f6c30876dfa 562 #define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= (uint32_t)0x000003FF)
Kojto 107:4f6c30876dfa 563 #define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF)
Kojto 107:4f6c30876dfa 564
Kojto 107:4f6c30876dfa 565 #define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8)))
Kojto 107:4f6c30876dfa 566 #define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
Kojto 107:4f6c30876dfa 567
Kojto 107:4f6c30876dfa 568 #define I2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \
Kojto 107:4f6c30876dfa 569 (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN)))
Kojto 107:4f6c30876dfa 570 /**
Kojto 107:4f6c30876dfa 571 * @}
Kojto 107:4f6c30876dfa 572 */
Kojto 107:4f6c30876dfa 573
Kojto 107:4f6c30876dfa 574 /* Private Functions ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 575 /** @defgroup I2C_Private_Functions I2C Private Functions
Kojto 107:4f6c30876dfa 576 * @{
Kojto 107:4f6c30876dfa 577 */
Kojto 107:4f6c30876dfa 578 /* Private functions are defined in stm32l4xx_hal_i2c.c file */
Kojto 107:4f6c30876dfa 579 /**
Kojto 107:4f6c30876dfa 580 * @}
Kojto 107:4f6c30876dfa 581 */
Kojto 107:4f6c30876dfa 582
Kojto 107:4f6c30876dfa 583 /**
Kojto 107:4f6c30876dfa 584 * @}
Kojto 107:4f6c30876dfa 585 */
Kojto 107:4f6c30876dfa 586
Kojto 107:4f6c30876dfa 587 /**
Kojto 107:4f6c30876dfa 588 * @}
Kojto 107:4f6c30876dfa 589 */
Kojto 107:4f6c30876dfa 590
Kojto 107:4f6c30876dfa 591 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 592 }
Kojto 107:4f6c30876dfa 593 #endif
Kojto 107:4f6c30876dfa 594
Kojto 107:4f6c30876dfa 595
Kojto 107:4f6c30876dfa 596 #endif /* __STM32L4xx_HAL_I2C_H */
Kojto 107:4f6c30876dfa 597
Kojto 107:4f6c30876dfa 598 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/