Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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