meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

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