mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Sep 28 10:45:10 2015 +0100
Revision:
630:825f75ca301e
Parent:
441:d2c15dda23c1
Synchronized with git revision 54fbe4144faf309c37205a5d39fa665daa919f10

Full URL: https://github.com/mbedmicro/mbed/commit/54fbe4144faf309c37205a5d39fa665daa919f10/

NUCLEO_F031K6 : Add new target

Who changed what in which revision?

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