mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
110:165afa46840b
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 101:7cff1c4259d7 1 /**
Kojto 101:7cff1c4259d7 2 ******************************************************************************
Kojto 101:7cff1c4259d7 3 * @file stm32f4xx_hal_i2c.h
Kojto 101:7cff1c4259d7 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.0
Kojto 122:f9eeca106725 6 * @date 06-May-2016
Kojto 101:7cff1c4259d7 7 * @brief Header file of I2C HAL module.
Kojto 101:7cff1c4259d7 8 ******************************************************************************
Kojto 101:7cff1c4259d7 9 * @attention
Kojto 101:7cff1c4259d7 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 101:7cff1c4259d7 12 *
Kojto 101:7cff1c4259d7 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 101:7cff1c4259d7 14 * are permitted provided that the following conditions are met:
Kojto 101:7cff1c4259d7 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 101:7cff1c4259d7 16 * this list of conditions and the following disclaimer.
Kojto 101:7cff1c4259d7 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 101:7cff1c4259d7 18 * this list of conditions and the following disclaimer in the documentation
Kojto 101:7cff1c4259d7 19 * and/or other materials provided with the distribution.
Kojto 101:7cff1c4259d7 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 101:7cff1c4259d7 21 * may be used to endorse or promote products derived from this software
Kojto 101:7cff1c4259d7 22 * without specific prior written permission.
Kojto 101:7cff1c4259d7 23 *
Kojto 101:7cff1c4259d7 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 101:7cff1c4259d7 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 101:7cff1c4259d7 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 101:7cff1c4259d7 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 101:7cff1c4259d7 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 101:7cff1c4259d7 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 101:7cff1c4259d7 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 101:7cff1c4259d7 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 101:7cff1c4259d7 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 101:7cff1c4259d7 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 101:7cff1c4259d7 34 *
Kojto 101:7cff1c4259d7 35 ******************************************************************************
Kojto 101:7cff1c4259d7 36 */
Kojto 101:7cff1c4259d7 37
Kojto 101:7cff1c4259d7 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 101:7cff1c4259d7 39 #ifndef __STM32F4xx_HAL_I2C_H
Kojto 101:7cff1c4259d7 40 #define __STM32F4xx_HAL_I2C_H
Kojto 101:7cff1c4259d7 41
Kojto 101:7cff1c4259d7 42 #ifdef __cplusplus
Kojto 101:7cff1c4259d7 43 extern "C" {
Kojto 101:7cff1c4259d7 44 #endif
Kojto 101:7cff1c4259d7 45
Kojto 101:7cff1c4259d7 46 /* Includes ------------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 47 #include "stm32f4xx_hal_def.h"
Kojto 101:7cff1c4259d7 48
Kojto 101:7cff1c4259d7 49 /** @addtogroup STM32F4xx_HAL_Driver
Kojto 101:7cff1c4259d7 50 * @{
Kojto 101:7cff1c4259d7 51 */
Kojto 101:7cff1c4259d7 52
Kojto 101:7cff1c4259d7 53 /** @addtogroup I2C
Kojto 101:7cff1c4259d7 54 * @{
Kojto 101:7cff1c4259d7 55 */
Kojto 101:7cff1c4259d7 56
Kojto 101:7cff1c4259d7 57 /* Exported types ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 58 /** @defgroup I2C_Exported_Types I2C Exported Types
Kojto 101:7cff1c4259d7 59 * @{
Kojto 101:7cff1c4259d7 60 */
Kojto 101:7cff1c4259d7 61
Kojto 101:7cff1c4259d7 62 /**
Kojto 101:7cff1c4259d7 63 * @brief I2C Configuration Structure definition
Kojto 101:7cff1c4259d7 64 */
Kojto 101:7cff1c4259d7 65 typedef struct
Kojto 101:7cff1c4259d7 66 {
Kojto 101:7cff1c4259d7 67 uint32_t ClockSpeed; /*!< Specifies the clock frequency.
Kojto 101:7cff1c4259d7 68 This parameter must be set to a value lower than 400kHz */
Kojto 101:7cff1c4259d7 69
Kojto 101:7cff1c4259d7 70 uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
Kojto 101:7cff1c4259d7 71 This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
Kojto 101:7cff1c4259d7 72
Kojto 101:7cff1c4259d7 73 uint32_t OwnAddress1; /*!< Specifies the first device own address.
Kojto 101:7cff1c4259d7 74 This parameter can be a 7-bit or 10-bit address. */
Kojto 101:7cff1c4259d7 75
Kojto 101:7cff1c4259d7 76 uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
Kojto 101:7cff1c4259d7 77 This parameter can be a value of @ref I2C_addressing_mode */
Kojto 101:7cff1c4259d7 78
Kojto 101:7cff1c4259d7 79 uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
Kojto 101:7cff1c4259d7 80 This parameter can be a value of @ref I2C_dual_addressing_mode */
Kojto 101:7cff1c4259d7 81
Kojto 101:7cff1c4259d7 82 uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
Kojto 101:7cff1c4259d7 83 This parameter can be a 7-bit address. */
Kojto 101:7cff1c4259d7 84
Kojto 101:7cff1c4259d7 85 uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
Kojto 101:7cff1c4259d7 86 This parameter can be a value of @ref I2C_general_call_addressing_mode */
Kojto 101:7cff1c4259d7 87
Kojto 101:7cff1c4259d7 88 uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
Kojto 101:7cff1c4259d7 89 This parameter can be a value of @ref I2C_nostretch_mode */
Kojto 101:7cff1c4259d7 90
Kojto 101:7cff1c4259d7 91 }I2C_InitTypeDef;
Kojto 101:7cff1c4259d7 92
Kojto 101:7cff1c4259d7 93 /**
Kojto 122:f9eeca106725 94 * @brief HAL State structure definition
Kojto 122:f9eeca106725 95 * @note HAL I2C State value coding follow below described bitmap :
Kojto 122:f9eeca106725 96 * b7-b6 Error information
Kojto 122:f9eeca106725 97 * 00 : No Error
Kojto 122:f9eeca106725 98 * 01 : Abort (Abort user request on going)
Kojto 122:f9eeca106725 99 * 10 : Timeout
Kojto 122:f9eeca106725 100 * 11 : Error
Kojto 122:f9eeca106725 101 * b5 IP initilisation status
Kojto 122:f9eeca106725 102 * 0 : Reset (IP not initialized)
Kojto 122:f9eeca106725 103 * 1 : Init done (IP initialized and ready to use. HAL I2C Init function called)
Kojto 122:f9eeca106725 104 * b4 (not used)
Kojto 122:f9eeca106725 105 * x : Should be set to 0
Kojto 122:f9eeca106725 106 * b3
Kojto 122:f9eeca106725 107 * 0 : Ready or Busy (No Listen mode ongoing)
Kojto 122:f9eeca106725 108 * 1 : Listen (IP in Address Listen Mode)
Kojto 122:f9eeca106725 109 * b2 Intrinsic process state
Kojto 122:f9eeca106725 110 * 0 : Ready
Kojto 122:f9eeca106725 111 * 1 : Busy (IP busy with some configuration or internal operations)
Kojto 122:f9eeca106725 112 * b1 Rx state
Kojto 122:f9eeca106725 113 * 0 : Ready (no Rx operation ongoing)
Kojto 122:f9eeca106725 114 * 1 : Busy (Rx operation ongoing)
Kojto 122:f9eeca106725 115 * b0 Tx state
Kojto 122:f9eeca106725 116 * 0 : Ready (no Tx operation ongoing)
Kojto 122:f9eeca106725 117 * 1 : Busy (Tx operation ongoing)
Kojto 101:7cff1c4259d7 118 */
Kojto 101:7cff1c4259d7 119 typedef enum
Kojto 101:7cff1c4259d7 120 {
Kojto 122:f9eeca106725 121 HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
Kojto 122:f9eeca106725 122 HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
Kojto 122:f9eeca106725 123 HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
Kojto 122:f9eeca106725 124 HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
Kojto 122:f9eeca106725 125 HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
Kojto 122:f9eeca106725 126 HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
Kojto 122:f9eeca106725 127 HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
Kojto 122:f9eeca106725 128 process is ongoing */
Kojto 122:f9eeca106725 129 HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
Kojto 122:f9eeca106725 130 process is ongoing */
Kojto 122:f9eeca106725 131 HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
Kojto 122:f9eeca106725 132 HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
Kojto 122:f9eeca106725 133 HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
Kojto 101:7cff1c4259d7 134
Kojto 101:7cff1c4259d7 135 }HAL_I2C_StateTypeDef;
Kojto 101:7cff1c4259d7 136
Kojto 101:7cff1c4259d7 137 /**
Kojto 122:f9eeca106725 138 * @brief HAL Mode structure definition
Kojto 122:f9eeca106725 139 * @note HAL I2C Mode value coding follow below described bitmap :
Kojto 122:f9eeca106725 140 * b7 (not used)
Kojto 122:f9eeca106725 141 * x : Should be set to 0
Kojto 122:f9eeca106725 142 * b6
Kojto 122:f9eeca106725 143 * 0 : None
Kojto 122:f9eeca106725 144 * 1 : Memory (HAL I2C communication is in Memory Mode)
Kojto 122:f9eeca106725 145 * b5
Kojto 122:f9eeca106725 146 * 0 : None
Kojto 122:f9eeca106725 147 * 1 : Slave (HAL I2C communication is in Slave Mode)
Kojto 122:f9eeca106725 148 * b4
Kojto 122:f9eeca106725 149 * 0 : None
Kojto 122:f9eeca106725 150 * 1 : Master (HAL I2C communication is in Master Mode)
Kojto 122:f9eeca106725 151 * b3-b2-b1-b0 (not used)
Kojto 122:f9eeca106725 152 * xxxx : Should be set to 0000
Kojto 122:f9eeca106725 153 */
Kojto 122:f9eeca106725 154 typedef enum
Kojto 122:f9eeca106725 155 {
Kojto 122:f9eeca106725 156 HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
Kojto 122:f9eeca106725 157 HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
Kojto 122:f9eeca106725 158 HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
Kojto 122:f9eeca106725 159 HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
Kojto 122:f9eeca106725 160
Kojto 122:f9eeca106725 161 }HAL_I2C_ModeTypeDef;
Kojto 122:f9eeca106725 162
Kojto 122:f9eeca106725 163 /**
Kojto 101:7cff1c4259d7 164 * @brief I2C handle Structure definition
Kojto 101:7cff1c4259d7 165 */
Kojto 101:7cff1c4259d7 166 typedef struct
Kojto 101:7cff1c4259d7 167 {
Kojto 122:f9eeca106725 168 I2C_TypeDef *Instance; /*!< I2C registers base address */
Kojto 122:f9eeca106725 169
Kojto 122:f9eeca106725 170 I2C_InitTypeDef Init; /*!< I2C communication parameters */
Kojto 122:f9eeca106725 171
Kojto 122:f9eeca106725 172 uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
Kojto 122:f9eeca106725 173
Kojto 122:f9eeca106725 174 uint16_t XferSize; /*!< I2C transfer size */
Kojto 122:f9eeca106725 175
Kojto 122:f9eeca106725 176 __IO uint16_t XferCount; /*!< I2C transfer counter */
Kojto 122:f9eeca106725 177
Kojto 122:f9eeca106725 178 __IO uint32_t XferOptions; /*!< I2C transfer options */
Kojto 122:f9eeca106725 179
Kojto 122:f9eeca106725 180 __IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
Kojto 122:f9eeca106725 181 context for internal usage */
Kojto 122:f9eeca106725 182
Kojto 122:f9eeca106725 183 DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
Kojto 122:f9eeca106725 184
Kojto 122:f9eeca106725 185 DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 HAL_LockTypeDef Lock; /*!< I2C locking object */
Kojto 122:f9eeca106725 188
Kojto 122:f9eeca106725 189 __IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
Kojto 122:f9eeca106725 190
Kojto 122:f9eeca106725 191 __IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
Kojto 122:f9eeca106725 192
Kojto 122:f9eeca106725 193 __IO uint32_t ErrorCode; /*!< I2C Error code */
Kojto 101:7cff1c4259d7 194
Kojto 122:f9eeca106725 195 __IO uint32_t Devaddress; /*!< I2C Target device address */
Kojto 101:7cff1c4259d7 196
Kojto 122:f9eeca106725 197 __IO uint32_t Memaddress; /*!< I2C Target memory address */
Kojto 101:7cff1c4259d7 198
Kojto 122:f9eeca106725 199 __IO uint32_t MemaddSize; /*!< I2C Target memory address size */
Kojto 101:7cff1c4259d7 200
Kojto 122:f9eeca106725 201 __IO uint32_t EventCount; /*!< I2C Event counter */
Kojto 122:f9eeca106725 202
Kojto 122:f9eeca106725 203 }I2C_HandleTypeDef;
Kojto 101:7cff1c4259d7 204
Kojto 101:7cff1c4259d7 205 /**
Kojto 101:7cff1c4259d7 206 * @}
Kojto 101:7cff1c4259d7 207 */
Kojto 101:7cff1c4259d7 208
Kojto 101:7cff1c4259d7 209 /* Exported constants --------------------------------------------------------*/
Kojto 101:7cff1c4259d7 210 /** @defgroup I2C_Exported_Constants I2C Exported Constants
Kojto 101:7cff1c4259d7 211 * @{
Kojto 101:7cff1c4259d7 212 */
Kojto 101:7cff1c4259d7 213
Kojto 101:7cff1c4259d7 214 /** @defgroup I2C_Error_Code I2C Error Code
Kojto 101:7cff1c4259d7 215 * @brief I2C Error Code
Kojto 101:7cff1c4259d7 216 * @{
Kojto 101:7cff1c4259d7 217 */
Kojto 122:f9eeca106725 218 #define HAL_I2C_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
Kojto 122:f9eeca106725 219 #define HAL_I2C_ERROR_BERR ((uint32_t)0x00000001U) /*!< BERR error */
Kojto 122:f9eeca106725 220 #define HAL_I2C_ERROR_ARLO ((uint32_t)0x00000002U) /*!< ARLO error */
Kojto 122:f9eeca106725 221 #define HAL_I2C_ERROR_AF ((uint32_t)0x00000004U) /*!< AF error */
Kojto 122:f9eeca106725 222 #define HAL_I2C_ERROR_OVR ((uint32_t)0x00000008U) /*!< OVR error */
Kojto 122:f9eeca106725 223 #define HAL_I2C_ERROR_DMA ((uint32_t)0x00000010U) /*!< DMA transfer error */
Kojto 122:f9eeca106725 224 #define HAL_I2C_ERROR_TIMEOUT ((uint32_t)0x00000020U) /*!< Timeout Error */
Kojto 101:7cff1c4259d7 225 /**
Kojto 101:7cff1c4259d7 226 * @}
Kojto 101:7cff1c4259d7 227 */
Kojto 101:7cff1c4259d7 228
Kojto 101:7cff1c4259d7 229 /** @defgroup I2C_duty_cycle_in_fast_mode I2C duty cycle in fast mode
Kojto 101:7cff1c4259d7 230 * @{
Kojto 101:7cff1c4259d7 231 */
Kojto 122:f9eeca106725 232 #define I2C_DUTYCYCLE_2 ((uint32_t)0x00000000U)
Kojto 101:7cff1c4259d7 233 #define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
Kojto 101:7cff1c4259d7 234 /**
Kojto 101:7cff1c4259d7 235 * @}
Kojto 101:7cff1c4259d7 236 */
Kojto 101:7cff1c4259d7 237
Kojto 101:7cff1c4259d7 238 /** @defgroup I2C_addressing_mode I2C addressing mode
Kojto 101:7cff1c4259d7 239 * @{
Kojto 101:7cff1c4259d7 240 */
Kojto 122:f9eeca106725 241 #define I2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00004000U)
Kojto 122:f9eeca106725 242 #define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | ((uint32_t)0x00004000U))
Kojto 101:7cff1c4259d7 243 /**
Kojto 101:7cff1c4259d7 244 * @}
Kojto 101:7cff1c4259d7 245 */
Kojto 101:7cff1c4259d7 246
Kojto 101:7cff1c4259d7 247 /** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
Kojto 101:7cff1c4259d7 248 * @{
Kojto 101:7cff1c4259d7 249 */
Kojto 122:f9eeca106725 250 #define I2C_DUALADDRESS_DISABLE ((uint32_t)0x00000000U)
Kojto 101:7cff1c4259d7 251 #define I2C_DUALADDRESS_ENABLE I2C_OAR2_ENDUAL
Kojto 101:7cff1c4259d7 252 /**
Kojto 101:7cff1c4259d7 253 * @}
Kojto 101:7cff1c4259d7 254 */
Kojto 101:7cff1c4259d7 255
Kojto 101:7cff1c4259d7 256 /** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
Kojto 101:7cff1c4259d7 257 * @{
Kojto 101:7cff1c4259d7 258 */
Kojto 122:f9eeca106725 259 #define I2C_GENERALCALL_DISABLE ((uint32_t)0x00000000U)
Kojto 101:7cff1c4259d7 260 #define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
Kojto 101:7cff1c4259d7 261 /**
Kojto 101:7cff1c4259d7 262 * @}
Kojto 101:7cff1c4259d7 263 */
Kojto 101:7cff1c4259d7 264
Kojto 101:7cff1c4259d7 265 /** @defgroup I2C_nostretch_mode I2C nostretch mode
Kojto 101:7cff1c4259d7 266 * @{
Kojto 101:7cff1c4259d7 267 */
Kojto 122:f9eeca106725 268 #define I2C_NOSTRETCH_DISABLE ((uint32_t)0x00000000U)
Kojto 101:7cff1c4259d7 269 #define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
Kojto 101:7cff1c4259d7 270 /**
Kojto 101:7cff1c4259d7 271 * @}
Kojto 101:7cff1c4259d7 272 */
Kojto 101:7cff1c4259d7 273
Kojto 101:7cff1c4259d7 274 /** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
Kojto 101:7cff1c4259d7 275 * @{
Kojto 101:7cff1c4259d7 276 */
Kojto 122:f9eeca106725 277 #define I2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 278 #define I2C_MEMADD_SIZE_16BIT ((uint32_t)0x00000010U)
Kojto 122:f9eeca106725 279 /**
Kojto 122:f9eeca106725 280 * @}
Kojto 122:f9eeca106725 281 */
Kojto 122:f9eeca106725 282
Kojto 122:f9eeca106725 283 /** @defgroup I2C_XferDirection_definition I2C XferDirection definition
Kojto 122:f9eeca106725 284 * @{
Kojto 122:f9eeca106725 285 */
Kojto 122:f9eeca106725 286 #define I2C_DIRECTION_RECEIVE ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 287 #define I2C_DIRECTION_TRANSMIT ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 288 /**
Kojto 122:f9eeca106725 289 * @}
Kojto 122:f9eeca106725 290 */
Kojto 122:f9eeca106725 291
Kojto 122:f9eeca106725 292 /** @defgroup I2C_XferOptions_definition I2C XferOptions definition
Kojto 122:f9eeca106725 293 * @{
Kojto 122:f9eeca106725 294 */
Kojto 122:f9eeca106725 295 #define I2C_FIRST_FRAME ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 296 #define I2C_NEXT_FRAME ((uint32_t)0x00000002U)
Kojto 122:f9eeca106725 297 #define I2C_FIRST_AND_LAST_FRAME ((uint32_t)0x00000004U)
Kojto 122:f9eeca106725 298 #define I2C_LAST_FRAME ((uint32_t)0x00000008U)
Kojto 101:7cff1c4259d7 299 /**
Kojto 101:7cff1c4259d7 300 * @}
Kojto 101:7cff1c4259d7 301 */
Kojto 101:7cff1c4259d7 302
Kojto 101:7cff1c4259d7 303 /** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
Kojto 101:7cff1c4259d7 304 * @{
Kojto 101:7cff1c4259d7 305 */
Kojto 101:7cff1c4259d7 306 #define I2C_IT_BUF I2C_CR2_ITBUFEN
Kojto 101:7cff1c4259d7 307 #define I2C_IT_EVT I2C_CR2_ITEVTEN
Kojto 101:7cff1c4259d7 308 #define I2C_IT_ERR I2C_CR2_ITERREN
Kojto 101:7cff1c4259d7 309 /**
Kojto 101:7cff1c4259d7 310 * @}
Kojto 101:7cff1c4259d7 311 */
Kojto 101:7cff1c4259d7 312
Kojto 101:7cff1c4259d7 313 /** @defgroup I2C_Flag_definition I2C Flag definition
Kojto 101:7cff1c4259d7 314 * @{
Kojto 101:7cff1c4259d7 315 */
Kojto 122:f9eeca106725 316 #define I2C_FLAG_SMBALERT ((uint32_t)0x00018000U)
Kojto 122:f9eeca106725 317 #define I2C_FLAG_TIMEOUT ((uint32_t)0x00014000U)
Kojto 122:f9eeca106725 318 #define I2C_FLAG_PECERR ((uint32_t)0x00011000U)
Kojto 122:f9eeca106725 319 #define I2C_FLAG_OVR ((uint32_t)0x00010800U)
Kojto 122:f9eeca106725 320 #define I2C_FLAG_AF ((uint32_t)0x00010400U)
Kojto 122:f9eeca106725 321 #define I2C_FLAG_ARLO ((uint32_t)0x00010200U)
Kojto 122:f9eeca106725 322 #define I2C_FLAG_BERR ((uint32_t)0x00010100U)
Kojto 122:f9eeca106725 323 #define I2C_FLAG_TXE ((uint32_t)0x00010080U)
Kojto 122:f9eeca106725 324 #define I2C_FLAG_RXNE ((uint32_t)0x00010040U)
Kojto 122:f9eeca106725 325 #define I2C_FLAG_STOPF ((uint32_t)0x00010010U)
Kojto 122:f9eeca106725 326 #define I2C_FLAG_ADD10 ((uint32_t)0x00010008U)
Kojto 122:f9eeca106725 327 #define I2C_FLAG_BTF ((uint32_t)0x00010004U)
Kojto 122:f9eeca106725 328 #define I2C_FLAG_ADDR ((uint32_t)0x00010002U)
Kojto 122:f9eeca106725 329 #define I2C_FLAG_SB ((uint32_t)0x00010001U)
Kojto 122:f9eeca106725 330 #define I2C_FLAG_DUALF ((uint32_t)0x00100080U)
Kojto 122:f9eeca106725 331 #define I2C_FLAG_SMBHOST ((uint32_t)0x00100040U)
Kojto 122:f9eeca106725 332 #define I2C_FLAG_SMBDEFAULT ((uint32_t)0x00100020U)
Kojto 122:f9eeca106725 333 #define I2C_FLAG_GENCALL ((uint32_t)0x00100010U)
Kojto 122:f9eeca106725 334 #define I2C_FLAG_TRA ((uint32_t)0x00100004U)
Kojto 122:f9eeca106725 335 #define I2C_FLAG_BUSY ((uint32_t)0x00100002U)
Kojto 122:f9eeca106725 336 #define I2C_FLAG_MSL ((uint32_t)0x00100001U)
Kojto 101:7cff1c4259d7 337 /**
Kojto 101:7cff1c4259d7 338 * @}
Kojto 101:7cff1c4259d7 339 */
Kojto 101:7cff1c4259d7 340
Kojto 101:7cff1c4259d7 341 /**
Kojto 101:7cff1c4259d7 342 * @}
Kojto 101:7cff1c4259d7 343 */
Kojto 101:7cff1c4259d7 344
Kojto 101:7cff1c4259d7 345 /* Exported macro ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 346 /** @defgroup I2C_Exported_Macros I2C Exported Macros
Kojto 101:7cff1c4259d7 347 * @{
Kojto 101:7cff1c4259d7 348 */
Kojto 101:7cff1c4259d7 349
Kojto 101:7cff1c4259d7 350 /** @brief Reset I2C handle state
Kojto 101:7cff1c4259d7 351 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 352 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 353 * @retval None
Kojto 101:7cff1c4259d7 354 */
Kojto 101:7cff1c4259d7 355 #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
Kojto 101:7cff1c4259d7 356
Kojto 101:7cff1c4259d7 357 /** @brief Enable or disable the specified I2C interrupts.
Kojto 101:7cff1c4259d7 358 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 359 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 360 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
Kojto 101:7cff1c4259d7 361 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 362 * @arg I2C_IT_BUF: Buffer interrupt enable
Kojto 101:7cff1c4259d7 363 * @arg I2C_IT_EVT: Event interrupt enable
Kojto 101:7cff1c4259d7 364 * @arg I2C_IT_ERR: Error interrupt enable
Kojto 101:7cff1c4259d7 365 * @retval None
Kojto 101:7cff1c4259d7 366 */
Kojto 101:7cff1c4259d7 367 #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
Kojto 101:7cff1c4259d7 368 #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
Kojto 101:7cff1c4259d7 369
Kojto 101:7cff1c4259d7 370 /** @brief Checks if the specified I2C interrupt source is enabled or disabled.
Kojto 101:7cff1c4259d7 371 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 372 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 373 * @param __INTERRUPT__: specifies the I2C interrupt source to check.
Kojto 101:7cff1c4259d7 374 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 375 * @arg I2C_IT_BUF: Buffer interrupt enable
Kojto 101:7cff1c4259d7 376 * @arg I2C_IT_EVT: Event interrupt enable
Kojto 101:7cff1c4259d7 377 * @arg I2C_IT_ERR: Error interrupt enable
Kojto 101:7cff1c4259d7 378 * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
Kojto 101:7cff1c4259d7 379 */
Kojto 101:7cff1c4259d7 380 #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 101:7cff1c4259d7 381
Kojto 101:7cff1c4259d7 382 /** @brief Checks whether the specified I2C flag is set or not.
Kojto 101:7cff1c4259d7 383 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 384 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 385 * @param __FLAG__: specifies the flag to check.
Kojto 101:7cff1c4259d7 386 * This parameter can be one of the following values:
Kojto 101:7cff1c4259d7 387 * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
Kojto 101:7cff1c4259d7 388 * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
Kojto 101:7cff1c4259d7 389 * @arg I2C_FLAG_PECERR: PEC error in reception flag
Kojto 101:7cff1c4259d7 390 * @arg I2C_FLAG_OVR: Overrun/Underrun flag
Kojto 101:7cff1c4259d7 391 * @arg I2C_FLAG_AF: Acknowledge failure flag
Kojto 101:7cff1c4259d7 392 * @arg I2C_FLAG_ARLO: Arbitration lost flag
Kojto 101:7cff1c4259d7 393 * @arg I2C_FLAG_BERR: Bus error flag
Kojto 101:7cff1c4259d7 394 * @arg I2C_FLAG_TXE: Data register empty flag
Kojto 101:7cff1c4259d7 395 * @arg I2C_FLAG_RXNE: Data register not empty flag
Kojto 101:7cff1c4259d7 396 * @arg I2C_FLAG_STOPF: Stop detection flag
Kojto 101:7cff1c4259d7 397 * @arg I2C_FLAG_ADD10: 10-bit header sent flag
Kojto 101:7cff1c4259d7 398 * @arg I2C_FLAG_BTF: Byte transfer finished flag
Kojto 101:7cff1c4259d7 399 * @arg I2C_FLAG_ADDR: Address sent flag
Kojto 101:7cff1c4259d7 400 * Address matched flag
Kojto 101:7cff1c4259d7 401 * @arg I2C_FLAG_SB: Start bit flag
Kojto 101:7cff1c4259d7 402 * @arg I2C_FLAG_DUALF: Dual flag
Kojto 101:7cff1c4259d7 403 * @arg I2C_FLAG_SMBHOST: SMBus host header
Kojto 101:7cff1c4259d7 404 * @arg I2C_FLAG_SMBDEFAULT: SMBus default header
Kojto 101:7cff1c4259d7 405 * @arg I2C_FLAG_GENCALL: General call header flag
Kojto 101:7cff1c4259d7 406 * @arg I2C_FLAG_TRA: Transmitter/Receiver flag
Kojto 101:7cff1c4259d7 407 * @arg I2C_FLAG_BUSY: Bus busy flag
Kojto 101:7cff1c4259d7 408 * @arg I2C_FLAG_MSL: Master/Slave flag
Kojto 101:7cff1c4259d7 409 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 101:7cff1c4259d7 410 */
Kojto 122:f9eeca106725 411 #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U)?((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)): \
Kojto 101:7cff1c4259d7 412 ((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)))
Kojto 101:7cff1c4259d7 413
Kojto 101:7cff1c4259d7 414 /** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
Kojto 101:7cff1c4259d7 415 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 416 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 417 * @param __FLAG__: specifies the flag to clear.
Kojto 101:7cff1c4259d7 418 * This parameter can be any combination of the following values:
Kojto 101:7cff1c4259d7 419 * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
Kojto 101:7cff1c4259d7 420 * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
Kojto 101:7cff1c4259d7 421 * @arg I2C_FLAG_PECERR: PEC error in reception flag
Kojto 101:7cff1c4259d7 422 * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
Kojto 101:7cff1c4259d7 423 * @arg I2C_FLAG_AF: Acknowledge failure flag
Kojto 101:7cff1c4259d7 424 * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
Kojto 101:7cff1c4259d7 425 * @arg I2C_FLAG_BERR: Bus error flag
Kojto 101:7cff1c4259d7 426 * @retval None
Kojto 101:7cff1c4259d7 427 */
Kojto 101:7cff1c4259d7 428 #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK))
Kojto 101:7cff1c4259d7 429
Kojto 101:7cff1c4259d7 430 /** @brief Clears the I2C ADDR pending flag.
Kojto 101:7cff1c4259d7 431 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 432 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 433 * @retval None
Kojto 101:7cff1c4259d7 434 */
Kojto 101:7cff1c4259d7 435 #define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
Kojto 101:7cff1c4259d7 436 do{ \
Kojto 122:f9eeca106725 437 __IO uint32_t tmpreg = 0x00U; \
Kojto 101:7cff1c4259d7 438 tmpreg = (__HANDLE__)->Instance->SR1; \
Kojto 101:7cff1c4259d7 439 tmpreg = (__HANDLE__)->Instance->SR2; \
Kojto 101:7cff1c4259d7 440 UNUSED(tmpreg); \
Kojto 101:7cff1c4259d7 441 } while(0)
Kojto 101:7cff1c4259d7 442
Kojto 101:7cff1c4259d7 443 /** @brief Clears the I2C STOPF pending flag.
Kojto 101:7cff1c4259d7 444 * @param __HANDLE__: specifies the I2C Handle.
Kojto 101:7cff1c4259d7 445 * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
Kojto 101:7cff1c4259d7 446 * @retval None
Kojto 101:7cff1c4259d7 447 */
Kojto 101:7cff1c4259d7 448 #define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
Kojto 101:7cff1c4259d7 449 do{ \
Kojto 122:f9eeca106725 450 __IO uint32_t tmpreg = 0x00U; \
Kojto 101:7cff1c4259d7 451 tmpreg = (__HANDLE__)->Instance->SR1; \
Kojto 101:7cff1c4259d7 452 (__HANDLE__)->Instance->CR1 |= I2C_CR1_PE; \
Kojto 101:7cff1c4259d7 453 UNUSED(tmpreg); \
Kojto 101:7cff1c4259d7 454 } while(0)
Kojto 101:7cff1c4259d7 455
Kojto 122:f9eeca106725 456 /** @brief Enable the I2C peripheral.
Kojto 122:f9eeca106725 457 * @param __HANDLE__: specifies the I2C Handle.
Kojto 122:f9eeca106725 458 * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral.
Kojto 122:f9eeca106725 459 * @retval None
Kojto 122:f9eeca106725 460 */
Kojto 101:7cff1c4259d7 461 #define __HAL_I2C_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= I2C_CR1_PE)
Kojto 122:f9eeca106725 462
Kojto 122:f9eeca106725 463 /** @brief Disable the I2C peripheral.
Kojto 122:f9eeca106725 464 * @param __HANDLE__: specifies the I2C Handle.
Kojto 122:f9eeca106725 465 * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral.
Kojto 122:f9eeca106725 466 * @retval None
Kojto 122:f9eeca106725 467 */
Kojto 101:7cff1c4259d7 468 #define __HAL_I2C_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~I2C_CR1_PE)
Kojto 101:7cff1c4259d7 469
Kojto 101:7cff1c4259d7 470 /**
Kojto 101:7cff1c4259d7 471 * @}
Kojto 101:7cff1c4259d7 472 */
Kojto 101:7cff1c4259d7 473
Kojto 101:7cff1c4259d7 474 /* Include I2C HAL Extension module */
Kojto 101:7cff1c4259d7 475 #include "stm32f4xx_hal_i2c_ex.h"
Kojto 101:7cff1c4259d7 476
Kojto 101:7cff1c4259d7 477 /* Exported functions --------------------------------------------------------*/
Kojto 101:7cff1c4259d7 478 /** @addtogroup I2C_Exported_Functions
Kojto 101:7cff1c4259d7 479 * @{
Kojto 101:7cff1c4259d7 480 */
Kojto 101:7cff1c4259d7 481
Kojto 101:7cff1c4259d7 482 /** @addtogroup I2C_Exported_Functions_Group1
Kojto 101:7cff1c4259d7 483 * @{
Kojto 101:7cff1c4259d7 484 */
Kojto 101:7cff1c4259d7 485 /* Initialization/de-initialization functions **********************************/
Kojto 101:7cff1c4259d7 486 HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 487 HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 488 void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 489 void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 490 /**
Kojto 101:7cff1c4259d7 491 * @}
Kojto 101:7cff1c4259d7 492 */
Kojto 101:7cff1c4259d7 493
Kojto 101:7cff1c4259d7 494 /** @addtogroup I2C_Exported_Functions_Group2
Kojto 101:7cff1c4259d7 495 * @{
Kojto 101:7cff1c4259d7 496 */
Kojto 101:7cff1c4259d7 497 /* I/O operation functions *****************************************************/
Kojto 101:7cff1c4259d7 498 /******* Blocking mode: Polling */
Kojto 101:7cff1c4259d7 499 HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 500 HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 501 HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 502 HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 503 HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 504 HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 101:7cff1c4259d7 505 HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
Kojto 101:7cff1c4259d7 506
Kojto 101:7cff1c4259d7 507 /******* Non-Blocking mode: Interrupt */
Kojto 101:7cff1c4259d7 508 HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 509 HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 510 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 511 HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 512 HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 513 HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 514
Kojto 122:f9eeca106725 515 HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
Kojto 122:f9eeca106725 516 HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
Kojto 122:f9eeca106725 517 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
Kojto 122:f9eeca106725 518 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
Kojto 122:f9eeca106725 519 HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress);
Kojto 122:f9eeca106725 520 HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c);
Kojto 122:f9eeca106725 521 HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c);
Kojto 122:f9eeca106725 522
Kojto 101:7cff1c4259d7 523 /******* Non-Blocking mode: DMA */
Kojto 101:7cff1c4259d7 524 HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 525 HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 526 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 527 HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 528 HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
Kojto 101:7cff1c4259d7 529 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 101:7cff1c4259d7 530
Kojto 101:7cff1c4259d7 531 /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
Kojto 101:7cff1c4259d7 532 void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 533 void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 534 void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 535 void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 536 void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 537 void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 122:f9eeca106725 538 void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
Kojto 122:f9eeca106725 539 void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 540 void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 541 void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 542 void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
Kojto 122:f9eeca106725 543 void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 544 /**
Kojto 101:7cff1c4259d7 545 * @}
Kojto 101:7cff1c4259d7 546 */
Kojto 101:7cff1c4259d7 547
Kojto 101:7cff1c4259d7 548 /** @addtogroup I2C_Exported_Functions_Group3
Kojto 101:7cff1c4259d7 549 * @{
Kojto 101:7cff1c4259d7 550 */
Kojto 122:f9eeca106725 551 /* Peripheral State, Mode and Errors functions *********************************/
Kojto 101:7cff1c4259d7 552 HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
Kojto 122:f9eeca106725 553 HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 554 uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
Kojto 101:7cff1c4259d7 555
Kojto 101:7cff1c4259d7 556 /**
Kojto 101:7cff1c4259d7 557 * @}
Kojto 101:7cff1c4259d7 558 */
Kojto 101:7cff1c4259d7 559
Kojto 101:7cff1c4259d7 560 /**
Kojto 101:7cff1c4259d7 561 * @}
Kojto 101:7cff1c4259d7 562 */
Kojto 101:7cff1c4259d7 563 /* Private types -------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 564 /* Private variables ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 565 /* Private constants ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 566 /** @defgroup I2C_Private_Constants I2C Private Constants
Kojto 101:7cff1c4259d7 567 * @{
Kojto 101:7cff1c4259d7 568 */
Kojto 122:f9eeca106725 569 #define I2C_FLAG_MASK ((uint32_t)0x0000FFFFU)
Kojto 101:7cff1c4259d7 570 /**
Kojto 101:7cff1c4259d7 571 * @}
Kojto 101:7cff1c4259d7 572 */
Kojto 101:7cff1c4259d7 573
Kojto 101:7cff1c4259d7 574 /* Private macros ------------------------------------------------------------*/
Kojto 101:7cff1c4259d7 575 /** @defgroup I2C_Private_Macros I2C Private Macros
Kojto 101:7cff1c4259d7 576 * @{
Kojto 101:7cff1c4259d7 577 */
Kojto 101:7cff1c4259d7 578
Kojto 122:f9eeca106725 579 #define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000U)
Kojto 122:f9eeca106725 580 #define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
Kojto 122:f9eeca106725 581 #define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) (((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
Kojto 122:f9eeca106725 582 #define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? ((__PCLK__) / ((__SPEED__) * 3U)) : (((__PCLK__) / ((__SPEED__) * 25U)) | I2C_DUTYCYCLE_16_9))
Kojto 122:f9eeca106725 583 #define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000U)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \
Kojto 122:f9eeca106725 584 ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U)? 1U : \
Kojto 101:7cff1c4259d7 585 ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
Kojto 101:7cff1c4259d7 586
Kojto 101:7cff1c4259d7 587 #define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (~I2C_OAR1_ADD0)))
Kojto 101:7cff1c4259d7 588 #define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0))
Kojto 101:7cff1c4259d7 589
Kojto 122:f9eeca106725 590 #define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
Kojto 122:f9eeca106725 591 #define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300U))) >> 7U) | (uint16_t)(0x00F0U))))
Kojto 122:f9eeca106725 592 #define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300U))) >> 7U) | (uint16_t)(0x00F1U))))
Kojto 101:7cff1c4259d7 593
Kojto 122:f9eeca106725 594 #define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00U))) >> 8U)))
Kojto 122:f9eeca106725 595 #define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
Kojto 101:7cff1c4259d7 596
Kojto 101:7cff1c4259d7 597 /** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
Kojto 101:7cff1c4259d7 598 * @{
Kojto 101:7cff1c4259d7 599 */
Kojto 101:7cff1c4259d7 600 #define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \
Kojto 101:7cff1c4259d7 601 ((CYCLE) == I2C_DUTYCYCLE_16_9))
Kojto 101:7cff1c4259d7 602 #define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \
Kojto 101:7cff1c4259d7 603 ((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
Kojto 101:7cff1c4259d7 604 #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
Kojto 101:7cff1c4259d7 605 ((ADDRESS) == I2C_DUALADDRESS_ENABLE))
Kojto 101:7cff1c4259d7 606 #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
Kojto 101:7cff1c4259d7 607 ((CALL) == I2C_GENERALCALL_ENABLE))
Kojto 101:7cff1c4259d7 608 #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
Kojto 101:7cff1c4259d7 609 ((STRETCH) == I2C_NOSTRETCH_ENABLE))
Kojto 101:7cff1c4259d7 610 #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
Kojto 101:7cff1c4259d7 611 ((SIZE) == I2C_MEMADD_SIZE_16BIT))
Kojto 122:f9eeca106725 612 #define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0) && ((SPEED) <= 400000U))
Kojto 122:f9eeca106725 613 #define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & (uint32_t)(0xFFFFFC00U)) == 0U)
Kojto 122:f9eeca106725 614 #define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & (uint32_t)(0xFFFFFF01U)) == 0U)
Kojto 122:f9eeca106725 615 #define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
Kojto 122:f9eeca106725 616 ((REQUEST) == I2C_NEXT_FRAME) || \
Kojto 122:f9eeca106725 617 ((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
Kojto 122:f9eeca106725 618 ((REQUEST) == I2C_LAST_FRAME))
Kojto 101:7cff1c4259d7 619 /**
Kojto 101:7cff1c4259d7 620 * @}
Kojto 101:7cff1c4259d7 621 */
Kojto 101:7cff1c4259d7 622
Kojto 101:7cff1c4259d7 623 /**
Kojto 101:7cff1c4259d7 624 * @}
Kojto 101:7cff1c4259d7 625 */
Kojto 101:7cff1c4259d7 626
Kojto 101:7cff1c4259d7 627 /* Private functions ---------------------------------------------------------*/
Kojto 101:7cff1c4259d7 628 /** @defgroup I2C_Private_Functions I2C Private Functions
Kojto 101:7cff1c4259d7 629 * @{
Kojto 101:7cff1c4259d7 630 */
Kojto 101:7cff1c4259d7 631
Kojto 101:7cff1c4259d7 632 /**
Kojto 101:7cff1c4259d7 633 * @}
Kojto 101:7cff1c4259d7 634 */
Kojto 101:7cff1c4259d7 635
Kojto 101:7cff1c4259d7 636 /**
Kojto 101:7cff1c4259d7 637 * @}
Kojto 101:7cff1c4259d7 638 */
Kojto 101:7cff1c4259d7 639
Kojto 101:7cff1c4259d7 640 /**
Kojto 101:7cff1c4259d7 641 * @}
Kojto 101:7cff1c4259d7 642 */
Kojto 101:7cff1c4259d7 643
Kojto 101:7cff1c4259d7 644 #ifdef __cplusplus
Kojto 101:7cff1c4259d7 645 }
Kojto 101:7cff1c4259d7 646 #endif
Kojto 101:7cff1c4259d7 647
Kojto 101:7cff1c4259d7 648
Kojto 101:7cff1c4259d7 649 #endif /* __STM32F4xx_HAL_I2C_H */
Kojto 101:7cff1c4259d7 650
Kojto 101:7cff1c4259d7 651 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/