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