inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_hal_fmpi2c.h
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief Header file of FMPI2C HAL module.
NYX 0:85b3fd62ea1a 8 ******************************************************************************
NYX 0:85b3fd62ea1a 9 * @attention
NYX 0:85b3fd62ea1a 10 *
NYX 0:85b3fd62ea1a 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 14 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 15 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 16 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 18 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 19 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 21 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 22 * without specific prior written permission.
NYX 0:85b3fd62ea1a 23 *
NYX 0:85b3fd62ea1a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 34 *
NYX 0:85b3fd62ea1a 35 ******************************************************************************
NYX 0:85b3fd62ea1a 36 */
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 /* Define to prevent recursive inclusion -------------------------------------*/
NYX 0:85b3fd62ea1a 39 #ifndef __STM32F4xx_HAL_FMPI2C_H
NYX 0:85b3fd62ea1a 40 #define __STM32F4xx_HAL_FMPI2C_H
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 43 extern "C" {
NYX 0:85b3fd62ea1a 44 #endif
NYX 0:85b3fd62ea1a 45
NYX 0:85b3fd62ea1a 46 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
NYX 0:85b3fd62ea1a 47 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
NYX 0:85b3fd62ea1a 48
NYX 0:85b3fd62ea1a 49 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 50 #include "stm32f4xx_hal_def.h"
NYX 0:85b3fd62ea1a 51
NYX 0:85b3fd62ea1a 52 /** @addtogroup STM32F4xx_HAL_Driver
NYX 0:85b3fd62ea1a 53 * @{
NYX 0:85b3fd62ea1a 54 */
NYX 0:85b3fd62ea1a 55
NYX 0:85b3fd62ea1a 56 /** @addtogroup FMPI2C
NYX 0:85b3fd62ea1a 57 * @{
NYX 0:85b3fd62ea1a 58 */
NYX 0:85b3fd62ea1a 59
NYX 0:85b3fd62ea1a 60 /* Exported types ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 61 /** @defgroup FMPI2C_Exported_Types FMPI2C Exported Types
NYX 0:85b3fd62ea1a 62 * @{
NYX 0:85b3fd62ea1a 63 */
NYX 0:85b3fd62ea1a 64
NYX 0:85b3fd62ea1a 65 /** @defgroup FMPI2C_Configuration_Structure_definition FMPI2C Configuration Structure definition
NYX 0:85b3fd62ea1a 66 * @brief FMPI2C Configuration Structure definition
NYX 0:85b3fd62ea1a 67 * @{
NYX 0:85b3fd62ea1a 68 */
NYX 0:85b3fd62ea1a 69 typedef struct
NYX 0:85b3fd62ea1a 70 {
NYX 0:85b3fd62ea1a 71 uint32_t Timing; /*!< Specifies the FMPI2C_TIMINGR_register value.
NYX 0:85b3fd62ea1a 72 This parameter calculated by referring to FMPI2C initialization
NYX 0:85b3fd62ea1a 73 section in Reference manual */
NYX 0:85b3fd62ea1a 74
NYX 0:85b3fd62ea1a 75 uint32_t OwnAddress1; /*!< Specifies the first device own address.
NYX 0:85b3fd62ea1a 76 This parameter can be a 7-bit or 10-bit address. */
NYX 0:85b3fd62ea1a 77
NYX 0:85b3fd62ea1a 78 uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
NYX 0:85b3fd62ea1a 79 This parameter can be a value of @ref FMPI2C_ADDRESSING_MODE */
NYX 0:85b3fd62ea1a 80
NYX 0:85b3fd62ea1a 81 uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
NYX 0:85b3fd62ea1a 82 This parameter can be a value of @ref FMPI2C_DUAL_ADDRESSING_MODE */
NYX 0:85b3fd62ea1a 83
NYX 0:85b3fd62ea1a 84 uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
NYX 0:85b3fd62ea1a 85 This parameter can be a 7-bit address. */
NYX 0:85b3fd62ea1a 86
NYX 0:85b3fd62ea1a 87 uint32_t OwnAddress2Masks; /*!< Specifies the acknowledge mask address second device own address if dual addressing mode is selected
NYX 0:85b3fd62ea1a 88 This parameter can be a value of @ref FMPI2C_OWN_ADDRESS2_MASKS */
NYX 0:85b3fd62ea1a 89
NYX 0:85b3fd62ea1a 90 uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
NYX 0:85b3fd62ea1a 91 This parameter can be a value of @ref FMPI2C_GENERAL_CALL_ADDRESSING_MODE */
NYX 0:85b3fd62ea1a 92
NYX 0:85b3fd62ea1a 93 uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
NYX 0:85b3fd62ea1a 94 This parameter can be a value of @ref FMPI2C_NOSTRETCH_MODE */
NYX 0:85b3fd62ea1a 95
NYX 0:85b3fd62ea1a 96 }FMPI2C_InitTypeDef;
NYX 0:85b3fd62ea1a 97
NYX 0:85b3fd62ea1a 98 /**
NYX 0:85b3fd62ea1a 99 * @}
NYX 0:85b3fd62ea1a 100 */
NYX 0:85b3fd62ea1a 101
NYX 0:85b3fd62ea1a 102 /** @defgroup HAL_state_structure_definition HAL state structure definition
NYX 0:85b3fd62ea1a 103 * @brief HAL State structure definition
NYX 0:85b3fd62ea1a 104 * @note HAL FMPI2C State value coding follow below described bitmap :
NYX 0:85b3fd62ea1a 105 * b7-b6 Error information
NYX 0:85b3fd62ea1a 106 * 00 : No Error
NYX 0:85b3fd62ea1a 107 * 01 : Abort (Abort user request on going)
NYX 0:85b3fd62ea1a 108 * 10 : Timeout
NYX 0:85b3fd62ea1a 109 * 11 : Error
NYX 0:85b3fd62ea1a 110 * b5 IP initilisation status
NYX 0:85b3fd62ea1a 111 * 0 : Reset (IP not initialized)
NYX 0:85b3fd62ea1a 112 * 1 : Init done (IP initialized and ready to use. HAL FMPI2C Init function called)
NYX 0:85b3fd62ea1a 113 * b4 (not used)
NYX 0:85b3fd62ea1a 114 * x : Should be set to 0
NYX 0:85b3fd62ea1a 115 * b3
NYX 0:85b3fd62ea1a 116 * 0 : Ready or Busy (No Listen mode ongoing)
NYX 0:85b3fd62ea1a 117 * 1 : Listen (IP in Address Listen Mode)
NYX 0:85b3fd62ea1a 118 * b2 Intrinsic process state
NYX 0:85b3fd62ea1a 119 * 0 : Ready
NYX 0:85b3fd62ea1a 120 * 1 : Busy (IP busy with some configuration or internal operations)
NYX 0:85b3fd62ea1a 121 * b1 Rx state
NYX 0:85b3fd62ea1a 122 * 0 : Ready (no Rx operation ongoing)
NYX 0:85b3fd62ea1a 123 * 1 : Busy (Rx operation ongoing)
NYX 0:85b3fd62ea1a 124 * b0 Tx state
NYX 0:85b3fd62ea1a 125 * 0 : Ready (no Tx operation ongoing)
NYX 0:85b3fd62ea1a 126 * 1 : Busy (Tx operation ongoing)
NYX 0:85b3fd62ea1a 127 * @{
NYX 0:85b3fd62ea1a 128 */
NYX 0:85b3fd62ea1a 129 typedef enum
NYX 0:85b3fd62ea1a 130 {
NYX 0:85b3fd62ea1a 131 HAL_FMPI2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
NYX 0:85b3fd62ea1a 132 HAL_FMPI2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
NYX 0:85b3fd62ea1a 133 HAL_FMPI2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
NYX 0:85b3fd62ea1a 134 HAL_FMPI2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
NYX 0:85b3fd62ea1a 135 HAL_FMPI2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
NYX 0:85b3fd62ea1a 136 HAL_FMPI2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
NYX 0:85b3fd62ea1a 137 HAL_FMPI2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
NYX 0:85b3fd62ea1a 138 process is ongoing */
NYX 0:85b3fd62ea1a 139 HAL_FMPI2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
NYX 0:85b3fd62ea1a 140 process is ongoing */
NYX 0:85b3fd62ea1a 141 HAL_FMPI2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
NYX 0:85b3fd62ea1a 142 HAL_FMPI2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
NYX 0:85b3fd62ea1a 143 HAL_FMPI2C_STATE_ERROR = 0xE0U /*!< Error */
NYX 0:85b3fd62ea1a 144
NYX 0:85b3fd62ea1a 145 }HAL_FMPI2C_StateTypeDef;
NYX 0:85b3fd62ea1a 146
NYX 0:85b3fd62ea1a 147 /**
NYX 0:85b3fd62ea1a 148 * @}
NYX 0:85b3fd62ea1a 149 */
NYX 0:85b3fd62ea1a 150
NYX 0:85b3fd62ea1a 151 /** @defgroup HAL_mode_structure_definition HAL mode structure definition
NYX 0:85b3fd62ea1a 152 * @brief HAL Mode structure definition
NYX 0:85b3fd62ea1a 153 * @note HAL FMPI2C Mode value coding follow below described bitmap :
NYX 0:85b3fd62ea1a 154 * b7 (not used)
NYX 0:85b3fd62ea1a 155 * x : Should be set to 0
NYX 0:85b3fd62ea1a 156 * b6
NYX 0:85b3fd62ea1a 157 * 0 : None
NYX 0:85b3fd62ea1a 158 * 1 : Memory (HAL FMPI2C communication is in Memory Mode)
NYX 0:85b3fd62ea1a 159 * b5
NYX 0:85b3fd62ea1a 160 * 0 : None
NYX 0:85b3fd62ea1a 161 * 1 : Slave (HAL FMPI2C communication is in Slave Mode)
NYX 0:85b3fd62ea1a 162 * b4
NYX 0:85b3fd62ea1a 163 * 0 : None
NYX 0:85b3fd62ea1a 164 * 1 : Master (HAL FMPI2C communication is in Master Mode)
NYX 0:85b3fd62ea1a 165 * b3-b2-b1-b0 (not used)
NYX 0:85b3fd62ea1a 166 * xxxx : Should be set to 0000
NYX 0:85b3fd62ea1a 167 * @{
NYX 0:85b3fd62ea1a 168 */
NYX 0:85b3fd62ea1a 169 typedef enum
NYX 0:85b3fd62ea1a 170 {
NYX 0:85b3fd62ea1a 171 HAL_FMPI2C_MODE_NONE = 0x00U, /*!< No FMPI2C communication on going */
NYX 0:85b3fd62ea1a 172 HAL_FMPI2C_MODE_MASTER = 0x10U, /*!< FMPI2C communication is in Master Mode */
NYX 0:85b3fd62ea1a 173 HAL_FMPI2C_MODE_SLAVE = 0x20U, /*!< FMPI2C communication is in Slave Mode */
NYX 0:85b3fd62ea1a 174 HAL_FMPI2C_MODE_MEM = 0x40U /*!< FMPI2C communication is in Memory Mode */
NYX 0:85b3fd62ea1a 175
NYX 0:85b3fd62ea1a 176 }HAL_FMPI2C_ModeTypeDef;
NYX 0:85b3fd62ea1a 177
NYX 0:85b3fd62ea1a 178 /**
NYX 0:85b3fd62ea1a 179 * @}
NYX 0:85b3fd62ea1a 180 */
NYX 0:85b3fd62ea1a 181
NYX 0:85b3fd62ea1a 182 /** @defgroup FMPI2C_Error_Code_definition FMPI2C Error Code definition
NYX 0:85b3fd62ea1a 183 * @brief FMPI2C Error Code definition
NYX 0:85b3fd62ea1a 184 * @{
NYX 0:85b3fd62ea1a 185 */
NYX 0:85b3fd62ea1a 186 #define HAL_FMPI2C_ERROR_NONE 0x00000000U /*!< No error */
NYX 0:85b3fd62ea1a 187 #define HAL_FMPI2C_ERROR_BERR 0x00000001U /*!< BERR error */
NYX 0:85b3fd62ea1a 188 #define HAL_FMPI2C_ERROR_ARLO 0x00000002U /*!< ARLO error */
NYX 0:85b3fd62ea1a 189 #define HAL_FMPI2C_ERROR_AF 0x00000004U /*!< ACKF error */
NYX 0:85b3fd62ea1a 190 #define HAL_FMPI2C_ERROR_OVR 0x00000008U /*!< OVR error */
NYX 0:85b3fd62ea1a 191 #define HAL_FMPI2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
NYX 0:85b3fd62ea1a 192 #define HAL_FMPI2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout error */
NYX 0:85b3fd62ea1a 193 #define HAL_FMPI2C_ERROR_SIZE 0x00000040U /*!< Size Management error */
NYX 0:85b3fd62ea1a 194 /**
NYX 0:85b3fd62ea1a 195 * @}
NYX 0:85b3fd62ea1a 196 */
NYX 0:85b3fd62ea1a 197
NYX 0:85b3fd62ea1a 198 /** @defgroup FMPI2C_handle_Structure_definition FMPI2C handle Structure definition
NYX 0:85b3fd62ea1a 199 * @brief FMPI2C handle Structure definition
NYX 0:85b3fd62ea1a 200 * @{
NYX 0:85b3fd62ea1a 201 */
NYX 0:85b3fd62ea1a 202 typedef struct __FMPI2C_HandleTypeDef
NYX 0:85b3fd62ea1a 203 {
NYX 0:85b3fd62ea1a 204 FMPI2C_TypeDef *Instance; /*!< FMPI2C registers base address */
NYX 0:85b3fd62ea1a 205
NYX 0:85b3fd62ea1a 206 FMPI2C_InitTypeDef Init; /*!< FMPI2C communication parameters */
NYX 0:85b3fd62ea1a 207
NYX 0:85b3fd62ea1a 208 uint8_t *pBuffPtr; /*!< Pointer to FMPI2C transfer buffer */
NYX 0:85b3fd62ea1a 209
NYX 0:85b3fd62ea1a 210 uint16_t XferSize; /*!< FMPI2C transfer size */
NYX 0:85b3fd62ea1a 211
NYX 0:85b3fd62ea1a 212 __IO uint16_t XferCount; /*!< FMPI2C transfer counter */
NYX 0:85b3fd62ea1a 213
NYX 0:85b3fd62ea1a 214 __IO uint32_t XferOptions; /*!< FMPI2C sequantial transfer options, this parameter can
NYX 0:85b3fd62ea1a 215 be a value of @ref FMPI2C_XFEROPTIONS */
NYX 0:85b3fd62ea1a 216
NYX 0:85b3fd62ea1a 217 __IO uint32_t PreviousState; /*!< FMPI2C communication Previous state */
NYX 0:85b3fd62ea1a 218
NYX 0:85b3fd62ea1a 219 HAL_StatusTypeDef (*XferISR)(struct __FMPI2C_HandleTypeDef *hfmpi2c, uint32_t ITFlags, uint32_t ITSources); /*!< FMPI2C transfer IRQ handler function pointer */
NYX 0:85b3fd62ea1a 220
NYX 0:85b3fd62ea1a 221 DMA_HandleTypeDef *hdmatx; /*!< FMPI2C Tx DMA handle parameters */
NYX 0:85b3fd62ea1a 222
NYX 0:85b3fd62ea1a 223 DMA_HandleTypeDef *hdmarx; /*!< FMPI2C Rx DMA handle parameters */
NYX 0:85b3fd62ea1a 224
NYX 0:85b3fd62ea1a 225 HAL_LockTypeDef Lock; /*!< FMPI2C locking object */
NYX 0:85b3fd62ea1a 226
NYX 0:85b3fd62ea1a 227 __IO HAL_FMPI2C_StateTypeDef State; /*!< FMPI2C communication state */
NYX 0:85b3fd62ea1a 228
NYX 0:85b3fd62ea1a 229 __IO HAL_FMPI2C_ModeTypeDef Mode; /*!< FMPI2C communication mode */
NYX 0:85b3fd62ea1a 230
NYX 0:85b3fd62ea1a 231 __IO uint32_t ErrorCode; /*!< FMPI2C Error code */
NYX 0:85b3fd62ea1a 232
NYX 0:85b3fd62ea1a 233 __IO uint32_t AddrEventCount; /*!< FMPI2C Address Event counter */
NYX 0:85b3fd62ea1a 234 }FMPI2C_HandleTypeDef;
NYX 0:85b3fd62ea1a 235 /**
NYX 0:85b3fd62ea1a 236 * @}
NYX 0:85b3fd62ea1a 237 */
NYX 0:85b3fd62ea1a 238
NYX 0:85b3fd62ea1a 239 /**
NYX 0:85b3fd62ea1a 240 * @}
NYX 0:85b3fd62ea1a 241 */
NYX 0:85b3fd62ea1a 242 /* Exported constants --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 243
NYX 0:85b3fd62ea1a 244 /** @defgroup FMPI2C_Exported_Constants FMPI2C Exported Constants
NYX 0:85b3fd62ea1a 245 * @{
NYX 0:85b3fd62ea1a 246 */
NYX 0:85b3fd62ea1a 247
NYX 0:85b3fd62ea1a 248 /** @defgroup FMPI2C_XFEROPTIONS FMPI2C Sequential Transfer Options
NYX 0:85b3fd62ea1a 249 * @{
NYX 0:85b3fd62ea1a 250 */
NYX 0:85b3fd62ea1a 251 #define FMPI2C_FIRST_FRAME ((uint32_t)FMPI2C_SOFTEND_MODE)
NYX 0:85b3fd62ea1a 252 #define FMPI2C_FIRST_AND_NEXT_FRAME ((uint32_t)(FMPI2C_RELOAD_MODE | FMPI2C_SOFTEND_MODE))
NYX 0:85b3fd62ea1a 253 #define FMPI2C_NEXT_FRAME ((uint32_t)(FMPI2C_RELOAD_MODE | FMPI2C_SOFTEND_MODE))
NYX 0:85b3fd62ea1a 254 #define FMPI2C_FIRST_AND_LAST_FRAME ((uint32_t)FMPI2C_AUTOEND_MODE)
NYX 0:85b3fd62ea1a 255 #define FMPI2C_LAST_FRAME ((uint32_t)FMPI2C_AUTOEND_MODE)
NYX 0:85b3fd62ea1a 256 /**
NYX 0:85b3fd62ea1a 257 * @}
NYX 0:85b3fd62ea1a 258 */
NYX 0:85b3fd62ea1a 259
NYX 0:85b3fd62ea1a 260 /** @defgroup FMPI2C_ADDRESSING_MODE FMPI2C Addressing Mode
NYX 0:85b3fd62ea1a 261 * @{
NYX 0:85b3fd62ea1a 262 */
NYX 0:85b3fd62ea1a 263 #define FMPI2C_ADDRESSINGMODE_7BIT 0x00000001U
NYX 0:85b3fd62ea1a 264 #define FMPI2C_ADDRESSINGMODE_10BIT 0x00000002U
NYX 0:85b3fd62ea1a 265 /**
NYX 0:85b3fd62ea1a 266 * @}
NYX 0:85b3fd62ea1a 267 */
NYX 0:85b3fd62ea1a 268
NYX 0:85b3fd62ea1a 269 /** @defgroup FMPI2C_DUAL_ADDRESSING_MODE FMPI2C Dual Addressing Mode
NYX 0:85b3fd62ea1a 270 * @{
NYX 0:85b3fd62ea1a 271 */
NYX 0:85b3fd62ea1a 272 #define FMPI2C_DUALADDRESS_DISABLE 0x00000000U
NYX 0:85b3fd62ea1a 273 #define FMPI2C_DUALADDRESS_ENABLE FMPI2C_OAR2_OA2EN
NYX 0:85b3fd62ea1a 274 /**
NYX 0:85b3fd62ea1a 275 * @}
NYX 0:85b3fd62ea1a 276 */
NYX 0:85b3fd62ea1a 277
NYX 0:85b3fd62ea1a 278 /** @defgroup FMPI2C_OWN_ADDRESS2_MASKS FMPI2C Own Address2 Masks
NYX 0:85b3fd62ea1a 279 * @{
NYX 0:85b3fd62ea1a 280 */
NYX 0:85b3fd62ea1a 281
NYX 0:85b3fd62ea1a 282 #define FMPI2C_OA2_NOMASK ((uint8_t)0x00)
NYX 0:85b3fd62ea1a 283 #define FMPI2C_OA2_MASK01 ((uint8_t)0x01)
NYX 0:85b3fd62ea1a 284 #define FMPI2C_OA2_MASK02 ((uint8_t)0x02)
NYX 0:85b3fd62ea1a 285 #define FMPI2C_OA2_MASK03 ((uint8_t)0x03)
NYX 0:85b3fd62ea1a 286 #define FMPI2C_OA2_MASK04 ((uint8_t)0x04)
NYX 0:85b3fd62ea1a 287 #define FMPI2C_OA2_MASK05 ((uint8_t)0x05)
NYX 0:85b3fd62ea1a 288 #define FMPI2C_OA2_MASK06 ((uint8_t)0x06)
NYX 0:85b3fd62ea1a 289 #define FMPI2C_OA2_MASK07 ((uint8_t)0x07)
NYX 0:85b3fd62ea1a 290
NYX 0:85b3fd62ea1a 291 /**
NYX 0:85b3fd62ea1a 292 * @}
NYX 0:85b3fd62ea1a 293 */
NYX 0:85b3fd62ea1a 294
NYX 0:85b3fd62ea1a 295 /** @defgroup FMPI2C_GENERAL_CALL_ADDRESSING_MODE FMPI2C General Call Addressing Mode
NYX 0:85b3fd62ea1a 296 * @{
NYX 0:85b3fd62ea1a 297 */
NYX 0:85b3fd62ea1a 298 #define FMPI2C_GENERALCALL_DISABLE 0x00000000U
NYX 0:85b3fd62ea1a 299 #define FMPI2C_GENERALCALL_ENABLE FMPI2C_CR1_GCEN
NYX 0:85b3fd62ea1a 300 /**
NYX 0:85b3fd62ea1a 301 * @}
NYX 0:85b3fd62ea1a 302 */
NYX 0:85b3fd62ea1a 303
NYX 0:85b3fd62ea1a 304 /** @defgroup FMPI2C_NOSTRETCH_MODE FMPI2C No-Stretch Mode
NYX 0:85b3fd62ea1a 305 * @{
NYX 0:85b3fd62ea1a 306 */
NYX 0:85b3fd62ea1a 307 #define FMPI2C_NOSTRETCH_DISABLE 0x00000000U
NYX 0:85b3fd62ea1a 308 #define FMPI2C_NOSTRETCH_ENABLE FMPI2C_CR1_NOSTRETCH
NYX 0:85b3fd62ea1a 309 /**
NYX 0:85b3fd62ea1a 310 * @}
NYX 0:85b3fd62ea1a 311 */
NYX 0:85b3fd62ea1a 312
NYX 0:85b3fd62ea1a 313 /** @defgroup FMPI2C_MEMORY_ADDRESS_SIZE FMPI2C Memory Address Size
NYX 0:85b3fd62ea1a 314 * @{
NYX 0:85b3fd62ea1a 315 */
NYX 0:85b3fd62ea1a 316 #define FMPI2C_MEMADD_SIZE_8BIT 0x00000001U
NYX 0:85b3fd62ea1a 317 #define FMPI2C_MEMADD_SIZE_16BIT 0x00000002U
NYX 0:85b3fd62ea1a 318
NYX 0:85b3fd62ea1a 319 /**
NYX 0:85b3fd62ea1a 320 * @}
NYX 0:85b3fd62ea1a 321 */
NYX 0:85b3fd62ea1a 322
NYX 0:85b3fd62ea1a 323 /** @defgroup FMPI2C_XferDirection FMPI2C Transfer Direction
NYX 0:85b3fd62ea1a 324 * @{
NYX 0:85b3fd62ea1a 325 */
NYX 0:85b3fd62ea1a 326 #define FMPI2C_DIRECTION_RECEIVE 0x00000000U
NYX 0:85b3fd62ea1a 327 #define FMPI2C_DIRECTION_TRANSMIT 0x00000001U
NYX 0:85b3fd62ea1a 328
NYX 0:85b3fd62ea1a 329 /**
NYX 0:85b3fd62ea1a 330 * @}
NYX 0:85b3fd62ea1a 331 */
NYX 0:85b3fd62ea1a 332
NYX 0:85b3fd62ea1a 333 /** @defgroup FMPI2C_RELOAD_END_MODE FMPI2C Reload End Mode
NYX 0:85b3fd62ea1a 334 * @{
NYX 0:85b3fd62ea1a 335 */
NYX 0:85b3fd62ea1a 336 #define FMPI2C_RELOAD_MODE FMPI2C_CR2_RELOAD
NYX 0:85b3fd62ea1a 337 #define FMPI2C_AUTOEND_MODE FMPI2C_CR2_AUTOEND
NYX 0:85b3fd62ea1a 338 #define FMPI2C_SOFTEND_MODE 0x00000000U
NYX 0:85b3fd62ea1a 339
NYX 0:85b3fd62ea1a 340 /**
NYX 0:85b3fd62ea1a 341 * @}
NYX 0:85b3fd62ea1a 342 */
NYX 0:85b3fd62ea1a 343
NYX 0:85b3fd62ea1a 344 /** @defgroup FMPI2C_START_STOP_MODE FMPI2C Start or Stop Mode
NYX 0:85b3fd62ea1a 345 * @{
NYX 0:85b3fd62ea1a 346 */
NYX 0:85b3fd62ea1a 347
NYX 0:85b3fd62ea1a 348 #define FMPI2C_NO_STARTSTOP 0x00000000U
NYX 0:85b3fd62ea1a 349 #define FMPI2C_GENERATE_STOP FMPI2C_CR2_STOP
NYX 0:85b3fd62ea1a 350 #define FMPI2C_GENERATE_START_READ (uint32_t)(FMPI2C_CR2_START | FMPI2C_CR2_RD_WRN)
NYX 0:85b3fd62ea1a 351 #define FMPI2C_GENERATE_START_WRITE FMPI2C_CR2_START
NYX 0:85b3fd62ea1a 352
NYX 0:85b3fd62ea1a 353 /**
NYX 0:85b3fd62ea1a 354 * @}
NYX 0:85b3fd62ea1a 355 */
NYX 0:85b3fd62ea1a 356
NYX 0:85b3fd62ea1a 357 /** @defgroup FMPI2C_Interrupt_configuration_definition FMPI2C Interrupt configuration definition
NYX 0:85b3fd62ea1a 358 * @brief FMPI2C Interrupt definition
NYX 0:85b3fd62ea1a 359 * Elements values convention: 0xXXXXXXXX
NYX 0:85b3fd62ea1a 360 * - XXXXXXXX : Interrupt control mask
NYX 0:85b3fd62ea1a 361 * @{
NYX 0:85b3fd62ea1a 362 */
NYX 0:85b3fd62ea1a 363 #define FMPI2C_IT_ERRI FMPI2C_CR1_ERRIE
NYX 0:85b3fd62ea1a 364 #define FMPI2C_IT_TCI FMPI2C_CR1_TCIE
NYX 0:85b3fd62ea1a 365 #define FMPI2C_IT_STOPI FMPI2C_CR1_STOPIE
NYX 0:85b3fd62ea1a 366 #define FMPI2C_IT_NACKI FMPI2C_CR1_NACKIE
NYX 0:85b3fd62ea1a 367 #define FMPI2C_IT_ADDRI FMPI2C_CR1_ADDRIE
NYX 0:85b3fd62ea1a 368 #define FMPI2C_IT_RXI FMPI2C_CR1_RXIE
NYX 0:85b3fd62ea1a 369 #define FMPI2C_IT_TXI FMPI2C_CR1_TXIE
NYX 0:85b3fd62ea1a 370 /**
NYX 0:85b3fd62ea1a 371 * @}
NYX 0:85b3fd62ea1a 372 */
NYX 0:85b3fd62ea1a 373
NYX 0:85b3fd62ea1a 374 /** @defgroup FMPI2C_Flag_definition FMPI2C Flag definition
NYX 0:85b3fd62ea1a 375 * @{
NYX 0:85b3fd62ea1a 376 */
NYX 0:85b3fd62ea1a 377 #define FMPI2C_FLAG_TXE FMPI2C_ISR_TXE
NYX 0:85b3fd62ea1a 378 #define FMPI2C_FLAG_TXIS FMPI2C_ISR_TXIS
NYX 0:85b3fd62ea1a 379 #define FMPI2C_FLAG_RXNE FMPI2C_ISR_RXNE
NYX 0:85b3fd62ea1a 380 #define FMPI2C_FLAG_ADDR FMPI2C_ISR_ADDR
NYX 0:85b3fd62ea1a 381 #define FMPI2C_FLAG_AF FMPI2C_ISR_NACKF
NYX 0:85b3fd62ea1a 382 #define FMPI2C_FLAG_STOPF FMPI2C_ISR_STOPF
NYX 0:85b3fd62ea1a 383 #define FMPI2C_FLAG_TC FMPI2C_ISR_TC
NYX 0:85b3fd62ea1a 384 #define FMPI2C_FLAG_TCR FMPI2C_ISR_TCR
NYX 0:85b3fd62ea1a 385 #define FMPI2C_FLAG_BERR FMPI2C_ISR_BERR
NYX 0:85b3fd62ea1a 386 #define FMPI2C_FLAG_ARLO FMPI2C_ISR_ARLO
NYX 0:85b3fd62ea1a 387 #define FMPI2C_FLAG_OVR FMPI2C_ISR_OVR
NYX 0:85b3fd62ea1a 388 #define FMPI2C_FLAG_PECERR FMPI2C_ISR_PECERR
NYX 0:85b3fd62ea1a 389 #define FMPI2C_FLAG_TIMEOUT FMPI2C_ISR_TIMEOUT
NYX 0:85b3fd62ea1a 390 #define FMPI2C_FLAG_ALERT FMPI2C_ISR_ALERT
NYX 0:85b3fd62ea1a 391 #define FMPI2C_FLAG_BUSY FMPI2C_ISR_BUSY
NYX 0:85b3fd62ea1a 392 #define FMPI2C_FLAG_DIR FMPI2C_ISR_DIR
NYX 0:85b3fd62ea1a 393 /**
NYX 0:85b3fd62ea1a 394 * @}
NYX 0:85b3fd62ea1a 395 */
NYX 0:85b3fd62ea1a 396
NYX 0:85b3fd62ea1a 397 /**
NYX 0:85b3fd62ea1a 398 * @}
NYX 0:85b3fd62ea1a 399 */
NYX 0:85b3fd62ea1a 400
NYX 0:85b3fd62ea1a 401 /* Exported macros -----------------------------------------------------------*/
NYX 0:85b3fd62ea1a 402
NYX 0:85b3fd62ea1a 403 /** @defgroup FMPI2C_Exported_Macros FMPI2C Exported Macros
NYX 0:85b3fd62ea1a 404 * @{
NYX 0:85b3fd62ea1a 405 */
NYX 0:85b3fd62ea1a 406
NYX 0:85b3fd62ea1a 407 /** @brief Reset FMPI2C handle state.
NYX 0:85b3fd62ea1a 408 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 409 * @retval None
NYX 0:85b3fd62ea1a 410 */
NYX 0:85b3fd62ea1a 411 #define __HAL_FMPI2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_FMPI2C_STATE_RESET)
NYX 0:85b3fd62ea1a 412
NYX 0:85b3fd62ea1a 413 /** @brief Enable the specified FMPI2C interrupt.
NYX 0:85b3fd62ea1a 414 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 415 * @param __INTERRUPT__ specifies the interrupt source to enable.
NYX 0:85b3fd62ea1a 416 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 417 * @arg @ref FMPI2C_IT_ERRI Errors interrupt enable
NYX 0:85b3fd62ea1a 418 * @arg @ref FMPI2C_IT_TCI Transfer complete interrupt enable
NYX 0:85b3fd62ea1a 419 * @arg @ref FMPI2C_IT_STOPI STOP detection interrupt enable
NYX 0:85b3fd62ea1a 420 * @arg @ref FMPI2C_IT_NACKI NACK received interrupt enable
NYX 0:85b3fd62ea1a 421 * @arg @ref FMPI2C_IT_ADDRI Address match interrupt enable
NYX 0:85b3fd62ea1a 422 * @arg @ref FMPI2C_IT_RXI RX interrupt enable
NYX 0:85b3fd62ea1a 423 * @arg @ref FMPI2C_IT_TXI TX interrupt enable
NYX 0:85b3fd62ea1a 424 *
NYX 0:85b3fd62ea1a 425 * @retval None
NYX 0:85b3fd62ea1a 426 */
NYX 0:85b3fd62ea1a 427 #define __HAL_FMPI2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
NYX 0:85b3fd62ea1a 428
NYX 0:85b3fd62ea1a 429 /** @brief Disable the specified FMPI2C interrupt.
NYX 0:85b3fd62ea1a 430 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 431 * @param __INTERRUPT__ specifies the interrupt source to disable.
NYX 0:85b3fd62ea1a 432 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 433 * @arg @ref FMPI2C_IT_ERRI Errors interrupt enable
NYX 0:85b3fd62ea1a 434 * @arg @ref FMPI2C_IT_TCI Transfer complete interrupt enable
NYX 0:85b3fd62ea1a 435 * @arg @ref FMPI2C_IT_STOPI STOP detection interrupt enable
NYX 0:85b3fd62ea1a 436 * @arg @ref FMPI2C_IT_NACKI NACK received interrupt enable
NYX 0:85b3fd62ea1a 437 * @arg @ref FMPI2C_IT_ADDRI Address match interrupt enable
NYX 0:85b3fd62ea1a 438 * @arg @ref FMPI2C_IT_RXI RX interrupt enable
NYX 0:85b3fd62ea1a 439 * @arg @ref FMPI2C_IT_TXI TX interrupt enable
NYX 0:85b3fd62ea1a 440 *
NYX 0:85b3fd62ea1a 441 * @retval None
NYX 0:85b3fd62ea1a 442 */
NYX 0:85b3fd62ea1a 443 #define __HAL_FMPI2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
NYX 0:85b3fd62ea1a 444
NYX 0:85b3fd62ea1a 445 /** @brief Check whether the specified FMPI2C interrupt source is enabled or not.
NYX 0:85b3fd62ea1a 446 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 447 * @param __INTERRUPT__ specifies the FMPI2C interrupt source to check.
NYX 0:85b3fd62ea1a 448 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 449 * @arg @ref FMPI2C_IT_ERRI Errors interrupt enable
NYX 0:85b3fd62ea1a 450 * @arg @ref FMPI2C_IT_TCI Transfer complete interrupt enable
NYX 0:85b3fd62ea1a 451 * @arg @ref FMPI2C_IT_STOPI STOP detection interrupt enable
NYX 0:85b3fd62ea1a 452 * @arg @ref FMPI2C_IT_NACKI NACK received interrupt enable
NYX 0:85b3fd62ea1a 453 * @arg @ref FMPI2C_IT_ADDRI Address match interrupt enable
NYX 0:85b3fd62ea1a 454 * @arg @ref FMPI2C_IT_RXI RX interrupt enable
NYX 0:85b3fd62ea1a 455 * @arg @ref FMPI2C_IT_TXI TX interrupt enable
NYX 0:85b3fd62ea1a 456 *
NYX 0:85b3fd62ea1a 457 * @retval The new state of __INTERRUPT__ (SET or RESET).
NYX 0:85b3fd62ea1a 458 */
NYX 0:85b3fd62ea1a 459 #define __HAL_FMPI2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
NYX 0:85b3fd62ea1a 460
NYX 0:85b3fd62ea1a 461 /** @brief Check whether the specified FMPI2C flag is set or not.
NYX 0:85b3fd62ea1a 462 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 463 * @param __FLAG__ specifies the flag to check.
NYX 0:85b3fd62ea1a 464 * This parameter can be one of the following values:
NYX 0:85b3fd62ea1a 465 * @arg @ref FMPI2C_FLAG_TXE Transmit data register empty
NYX 0:85b3fd62ea1a 466 * @arg @ref FMPI2C_FLAG_TXIS Transmit interrupt status
NYX 0:85b3fd62ea1a 467 * @arg @ref FMPI2C_FLAG_RXNE Receive data register not empty
NYX 0:85b3fd62ea1a 468 * @arg @ref FMPI2C_FLAG_ADDR Address matched (slave mode)
NYX 0:85b3fd62ea1a 469 * @arg @ref FMPI2C_FLAG_AF Acknowledge failure received flag
NYX 0:85b3fd62ea1a 470 * @arg @ref FMPI2C_FLAG_STOPF STOP detection flag
NYX 0:85b3fd62ea1a 471 * @arg @ref FMPI2C_FLAG_TC Transfer complete (master mode)
NYX 0:85b3fd62ea1a 472 * @arg @ref FMPI2C_FLAG_TCR Transfer complete reload
NYX 0:85b3fd62ea1a 473 * @arg @ref FMPI2C_FLAG_BERR Bus error
NYX 0:85b3fd62ea1a 474 * @arg @ref FMPI2C_FLAG_ARLO Arbitration lost
NYX 0:85b3fd62ea1a 475 * @arg @ref FMPI2C_FLAG_OVR Overrun/Underrun
NYX 0:85b3fd62ea1a 476 * @arg @ref FMPI2C_FLAG_PECERR PEC error in reception
NYX 0:85b3fd62ea1a 477 * @arg @ref FMPI2C_FLAG_TIMEOUT Timeout or Tlow detection flag
NYX 0:85b3fd62ea1a 478 * @arg @ref FMPI2C_FLAG_ALERT SMBus alert
NYX 0:85b3fd62ea1a 479 * @arg @ref FMPI2C_FLAG_BUSY Bus busy
NYX 0:85b3fd62ea1a 480 * @arg @ref FMPI2C_FLAG_DIR Transfer direction (slave mode)
NYX 0:85b3fd62ea1a 481 *
NYX 0:85b3fd62ea1a 482 * @retval The new state of __FLAG__ (SET or RESET).
NYX 0:85b3fd62ea1a 483 */
NYX 0:85b3fd62ea1a 484 #define __HAL_FMPI2C_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
NYX 0:85b3fd62ea1a 485
NYX 0:85b3fd62ea1a 486 /** @brief Clear the FMPI2C pending flags which are cleared by writing 1 in a specific bit.
NYX 0:85b3fd62ea1a 487 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 488 * @param __FLAG__ specifies the flag to clear.
NYX 0:85b3fd62ea1a 489 * This parameter can be any combination of the following values:
NYX 0:85b3fd62ea1a 490 * @arg @ref FMPI2C_FLAG_TXE Transmit data register empty
NYX 0:85b3fd62ea1a 491 * @arg @ref FMPI2C_FLAG_ADDR Address matched (slave mode)
NYX 0:85b3fd62ea1a 492 * @arg @ref FMPI2C_FLAG_AF Acknowledge failure received flag
NYX 0:85b3fd62ea1a 493 * @arg @ref FMPI2C_FLAG_STOPF STOP detection flag
NYX 0:85b3fd62ea1a 494 * @arg @ref FMPI2C_FLAG_BERR Bus error
NYX 0:85b3fd62ea1a 495 * @arg @ref FMPI2C_FLAG_ARLO Arbitration lost
NYX 0:85b3fd62ea1a 496 * @arg @ref FMPI2C_FLAG_OVR Overrun/Underrun
NYX 0:85b3fd62ea1a 497 * @arg @ref FMPI2C_FLAG_PECERR PEC error in reception
NYX 0:85b3fd62ea1a 498 * @arg @ref FMPI2C_FLAG_TIMEOUT Timeout or Tlow detection flag
NYX 0:85b3fd62ea1a 499 * @arg @ref FMPI2C_FLAG_ALERT SMBus alert
NYX 0:85b3fd62ea1a 500 *
NYX 0:85b3fd62ea1a 501 * @retval None
NYX 0:85b3fd62ea1a 502 */
NYX 0:85b3fd62ea1a 503 #define __HAL_FMPI2C_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__FLAG__) == FMPI2C_FLAG_TXE) ? ((__HANDLE__)->Instance->ISR |= (__FLAG__)) \
NYX 0:85b3fd62ea1a 504 : ((__HANDLE__)->Instance->ICR = (__FLAG__)))
NYX 0:85b3fd62ea1a 505
NYX 0:85b3fd62ea1a 506 /** @brief Enable the specified FMPI2C peripheral.
NYX 0:85b3fd62ea1a 507 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 508 * @retval None
NYX 0:85b3fd62ea1a 509 */
NYX 0:85b3fd62ea1a 510 #define __HAL_FMPI2C_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, FMPI2C_CR1_PE))
NYX 0:85b3fd62ea1a 511
NYX 0:85b3fd62ea1a 512 /** @brief Disable the specified FMPI2C peripheral.
NYX 0:85b3fd62ea1a 513 * @param __HANDLE__ specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 514 * @retval None
NYX 0:85b3fd62ea1a 515 */
NYX 0:85b3fd62ea1a 516 #define __HAL_FMPI2C_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, FMPI2C_CR1_PE))
NYX 0:85b3fd62ea1a 517
NYX 0:85b3fd62ea1a 518 /** @brief Generate a Non-Acknowledge FMPI2C peripheral in Slave mode.
NYX 0:85b3fd62ea1a 519 * @param __HANDLE__: specifies the FMPI2C Handle.
NYX 0:85b3fd62ea1a 520 * @retval None
NYX 0:85b3fd62ea1a 521 */
NYX 0:85b3fd62ea1a 522 #define __HAL_FMPI2C_GENERATE_NACK(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR2, FMPI2C_CR2_NACK))
NYX 0:85b3fd62ea1a 523 /**
NYX 0:85b3fd62ea1a 524 * @}
NYX 0:85b3fd62ea1a 525 */
NYX 0:85b3fd62ea1a 526
NYX 0:85b3fd62ea1a 527 /* Include FMPI2C HAL Extended module */
NYX 0:85b3fd62ea1a 528 #include "stm32f4xx_hal_fmpi2c_ex.h"
NYX 0:85b3fd62ea1a 529
NYX 0:85b3fd62ea1a 530 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 531 /** @addtogroup FMPI2C_Exported_Functions
NYX 0:85b3fd62ea1a 532 * @{
NYX 0:85b3fd62ea1a 533 */
NYX 0:85b3fd62ea1a 534
NYX 0:85b3fd62ea1a 535 /** @addtogroup FMPI2C_Exported_Functions_Group1 Initialization and de-initialization functions
NYX 0:85b3fd62ea1a 536 * @{
NYX 0:85b3fd62ea1a 537 */
NYX 0:85b3fd62ea1a 538 /* Initialization and de-initialization functions******************************/
NYX 0:85b3fd62ea1a 539 HAL_StatusTypeDef HAL_FMPI2C_Init(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 540 HAL_StatusTypeDef HAL_FMPI2C_DeInit (FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 541 void HAL_FMPI2C_MspInit(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 542 void HAL_FMPI2C_MspDeInit(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 543 /**
NYX 0:85b3fd62ea1a 544 * @}
NYX 0:85b3fd62ea1a 545 */
NYX 0:85b3fd62ea1a 546
NYX 0:85b3fd62ea1a 547 /** @addtogroup FMPI2C_Exported_Functions_Group2 Input and Output operation functions
NYX 0:85b3fd62ea1a 548 * @{
NYX 0:85b3fd62ea1a 549 */
NYX 0:85b3fd62ea1a 550 /* IO operation functions ****************************************************/
NYX 0:85b3fd62ea1a 551 /******* Blocking mode: Polling */
NYX 0:85b3fd62ea1a 552 HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 553 HAL_StatusTypeDef HAL_FMPI2C_Master_Receive(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 554 HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 555 HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 556 HAL_StatusTypeDef HAL_FMPI2C_Mem_Write(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 557 HAL_StatusTypeDef HAL_FMPI2C_Mem_Read(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
NYX 0:85b3fd62ea1a 558 HAL_StatusTypeDef HAL_FMPI2C_IsDeviceReady(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
NYX 0:85b3fd62ea1a 559
NYX 0:85b3fd62ea1a 560 /******* Non-Blocking mode: Interrupt */
NYX 0:85b3fd62ea1a 561 HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 562 HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 563 HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 564 HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 565 HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 566 HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 567
NYX 0:85b3fd62ea1a 568 HAL_StatusTypeDef HAL_FMPI2C_Master_Sequential_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
NYX 0:85b3fd62ea1a 569 HAL_StatusTypeDef HAL_FMPI2C_Master_Sequential_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
NYX 0:85b3fd62ea1a 570 HAL_StatusTypeDef HAL_FMPI2C_Slave_Sequential_Transmit_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
NYX 0:85b3fd62ea1a 571 HAL_StatusTypeDef HAL_FMPI2C_Slave_Sequential_Receive_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
NYX 0:85b3fd62ea1a 572 HAL_StatusTypeDef HAL_FMPI2C_EnableListen_IT(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 573 HAL_StatusTypeDef HAL_FMPI2C_DisableListen_IT(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 574 HAL_StatusTypeDef HAL_FMPI2C_Master_Abort_IT(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress);
NYX 0:85b3fd62ea1a 575
NYX 0:85b3fd62ea1a 576 /******* Non-Blocking mode: DMA */
NYX 0:85b3fd62ea1a 577 HAL_StatusTypeDef HAL_FMPI2C_Master_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 578 HAL_StatusTypeDef HAL_FMPI2C_Master_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 579 HAL_StatusTypeDef HAL_FMPI2C_Slave_Transmit_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 580 HAL_StatusTypeDef HAL_FMPI2C_Slave_Receive_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 581 HAL_StatusTypeDef HAL_FMPI2C_Mem_Write_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 582 HAL_StatusTypeDef HAL_FMPI2C_Mem_Read_DMA(FMPI2C_HandleTypeDef *hfmpi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
NYX 0:85b3fd62ea1a 583 /**
NYX 0:85b3fd62ea1a 584 * @}
NYX 0:85b3fd62ea1a 585 */
NYX 0:85b3fd62ea1a 586
NYX 0:85b3fd62ea1a 587 /** @addtogroup FMPI2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
NYX 0:85b3fd62ea1a 588 * @{
NYX 0:85b3fd62ea1a 589 */
NYX 0:85b3fd62ea1a 590 /******* FMPI2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
NYX 0:85b3fd62ea1a 591 void HAL_FMPI2C_EV_IRQHandler(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 592 void HAL_FMPI2C_ER_IRQHandler(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 593 void HAL_FMPI2C_MasterTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 594 void HAL_FMPI2C_MasterRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 595 void HAL_FMPI2C_SlaveTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 596 void HAL_FMPI2C_SlaveRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 597 void HAL_FMPI2C_AddrCallback(FMPI2C_HandleTypeDef *hfmpi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
NYX 0:85b3fd62ea1a 598 void HAL_FMPI2C_ListenCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 599 void HAL_FMPI2C_MemTxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 600 void HAL_FMPI2C_MemRxCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 601 void HAL_FMPI2C_ErrorCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 602 void HAL_FMPI2C_AbortCpltCallback(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 603 /**
NYX 0:85b3fd62ea1a 604 * @}
NYX 0:85b3fd62ea1a 605 */
NYX 0:85b3fd62ea1a 606
NYX 0:85b3fd62ea1a 607 /** @addtogroup FMPI2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
NYX 0:85b3fd62ea1a 608 * @{
NYX 0:85b3fd62ea1a 609 */
NYX 0:85b3fd62ea1a 610 /* Peripheral State, Mode and Error functions *********************************/
NYX 0:85b3fd62ea1a 611 HAL_FMPI2C_StateTypeDef HAL_FMPI2C_GetState(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 612 HAL_FMPI2C_ModeTypeDef HAL_FMPI2C_GetMode(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 613 uint32_t HAL_FMPI2C_GetError(FMPI2C_HandleTypeDef *hfmpi2c);
NYX 0:85b3fd62ea1a 614
NYX 0:85b3fd62ea1a 615 /**
NYX 0:85b3fd62ea1a 616 * @}
NYX 0:85b3fd62ea1a 617 */
NYX 0:85b3fd62ea1a 618
NYX 0:85b3fd62ea1a 619 /**
NYX 0:85b3fd62ea1a 620 * @}
NYX 0:85b3fd62ea1a 621 */
NYX 0:85b3fd62ea1a 622
NYX 0:85b3fd62ea1a 623 /* Private constants ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 624 /** @defgroup FMPI2C_Private_Constants FMPI2C Private Constants
NYX 0:85b3fd62ea1a 625 * @{
NYX 0:85b3fd62ea1a 626 */
NYX 0:85b3fd62ea1a 627
NYX 0:85b3fd62ea1a 628 /**
NYX 0:85b3fd62ea1a 629 * @}
NYX 0:85b3fd62ea1a 630 */
NYX 0:85b3fd62ea1a 631
NYX 0:85b3fd62ea1a 632 /* Private macros ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 633 /** @defgroup FMPI2C_Private_Macro FMPI2C Private Macros
NYX 0:85b3fd62ea1a 634 * @{
NYX 0:85b3fd62ea1a 635 */
NYX 0:85b3fd62ea1a 636
NYX 0:85b3fd62ea1a 637 #define IS_FMPI2C_ADDRESSING_MODE(MODE) (((MODE) == FMPI2C_ADDRESSINGMODE_7BIT) || \
NYX 0:85b3fd62ea1a 638 ((MODE) == FMPI2C_ADDRESSINGMODE_10BIT))
NYX 0:85b3fd62ea1a 639
NYX 0:85b3fd62ea1a 640 #define IS_FMPI2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == FMPI2C_DUALADDRESS_DISABLE) || \
NYX 0:85b3fd62ea1a 641 ((ADDRESS) == FMPI2C_DUALADDRESS_ENABLE))
NYX 0:85b3fd62ea1a 642
NYX 0:85b3fd62ea1a 643 #define IS_FMPI2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == FMPI2C_OA2_NOMASK) || \
NYX 0:85b3fd62ea1a 644 ((MASK) == FMPI2C_OA2_MASK01) || \
NYX 0:85b3fd62ea1a 645 ((MASK) == FMPI2C_OA2_MASK02) || \
NYX 0:85b3fd62ea1a 646 ((MASK) == FMPI2C_OA2_MASK03) || \
NYX 0:85b3fd62ea1a 647 ((MASK) == FMPI2C_OA2_MASK04) || \
NYX 0:85b3fd62ea1a 648 ((MASK) == FMPI2C_OA2_MASK05) || \
NYX 0:85b3fd62ea1a 649 ((MASK) == FMPI2C_OA2_MASK06) || \
NYX 0:85b3fd62ea1a 650 ((MASK) == FMPI2C_OA2_MASK07))
NYX 0:85b3fd62ea1a 651
NYX 0:85b3fd62ea1a 652 #define IS_FMPI2C_GENERAL_CALL(CALL) (((CALL) == FMPI2C_GENERALCALL_DISABLE) || \
NYX 0:85b3fd62ea1a 653 ((CALL) == FMPI2C_GENERALCALL_ENABLE))
NYX 0:85b3fd62ea1a 654
NYX 0:85b3fd62ea1a 655 #define IS_FMPI2C_NO_STRETCH(STRETCH) (((STRETCH) == FMPI2C_NOSTRETCH_DISABLE) || \
NYX 0:85b3fd62ea1a 656 ((STRETCH) == FMPI2C_NOSTRETCH_ENABLE))
NYX 0:85b3fd62ea1a 657
NYX 0:85b3fd62ea1a 658 #define IS_FMPI2C_MEMADD_SIZE(SIZE) (((SIZE) == FMPI2C_MEMADD_SIZE_8BIT) || \
NYX 0:85b3fd62ea1a 659 ((SIZE) == FMPI2C_MEMADD_SIZE_16BIT))
NYX 0:85b3fd62ea1a 660
NYX 0:85b3fd62ea1a 661 #define IS_TRANSFER_MODE(MODE) (((MODE) == FMPI2C_RELOAD_MODE) || \
NYX 0:85b3fd62ea1a 662 ((MODE) == FMPI2C_AUTOEND_MODE) || \
NYX 0:85b3fd62ea1a 663 ((MODE) == FMPI2C_SOFTEND_MODE))
NYX 0:85b3fd62ea1a 664
NYX 0:85b3fd62ea1a 665 #define IS_TRANSFER_REQUEST(REQUEST) (((REQUEST) == FMPI2C_GENERATE_STOP) || \
NYX 0:85b3fd62ea1a 666 ((REQUEST) == FMPI2C_GENERATE_START_READ) || \
NYX 0:85b3fd62ea1a 667 ((REQUEST) == FMPI2C_GENERATE_START_WRITE) || \
NYX 0:85b3fd62ea1a 668 ((REQUEST) == FMPI2C_NO_STARTSTOP))
NYX 0:85b3fd62ea1a 669
NYX 0:85b3fd62ea1a 670 #define IS_FMPI2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == FMPI2C_FIRST_FRAME) || \
NYX 0:85b3fd62ea1a 671 ((REQUEST) == FMPI2C_FIRST_AND_NEXT_FRAME) || \
NYX 0:85b3fd62ea1a 672 ((REQUEST) == FMPI2C_NEXT_FRAME) || \
NYX 0:85b3fd62ea1a 673 ((REQUEST) == FMPI2C_FIRST_AND_LAST_FRAME) || \
NYX 0:85b3fd62ea1a 674 ((REQUEST) == FMPI2C_LAST_FRAME))
NYX 0:85b3fd62ea1a 675
NYX 0:85b3fd62ea1a 676 #define FMPI2C_RESET_CR2(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(FMPI2C_CR2_SADD | FMPI2C_CR2_HEAD10R | FMPI2C_CR2_NBYTES | FMPI2C_CR2_RELOAD | FMPI2C_CR2_RD_WRN)))
NYX 0:85b3fd62ea1a 677
NYX 0:85b3fd62ea1a 678 #define FMPI2C_GET_ADDR_MATCH(__HANDLE__) (((__HANDLE__)->Instance->ISR & FMPI2C_ISR_ADDCODE) >> 16)
NYX 0:85b3fd62ea1a 679 #define FMPI2C_GET_DIR(__HANDLE__) (((__HANDLE__)->Instance->ISR & FMPI2C_ISR_DIR) >> 16)
NYX 0:85b3fd62ea1a 680 #define FMPI2C_GET_STOP_MODE(__HANDLE__) ((__HANDLE__)->Instance->CR2 & FMPI2C_CR2_AUTOEND)
NYX 0:85b3fd62ea1a 681 #define FMPI2C_GET_OWN_ADDRESS1(__HANDLE__) ((__HANDLE__)->Instance->OAR1 & FMPI2C_OAR1_OA1)
NYX 0:85b3fd62ea1a 682 #define FMPI2C_GET_OWN_ADDRESS2(__HANDLE__) ((__HANDLE__)->Instance->OAR2 & FMPI2C_OAR2_OA2)
NYX 0:85b3fd62ea1a 683
NYX 0:85b3fd62ea1a 684 #define IS_FMPI2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= 0x000003FFU)
NYX 0:85b3fd62ea1a 685 #define IS_FMPI2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF)
NYX 0:85b3fd62ea1a 686
NYX 0:85b3fd62ea1a 687 #define FMPI2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8U)))
NYX 0:85b3fd62ea1a 688 #define FMPI2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
NYX 0:85b3fd62ea1a 689
NYX 0:85b3fd62ea1a 690 #define FMPI2C_GENERATE_START(__ADDMODE__,__ADDRESS__) (((__ADDMODE__) == FMPI2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (FMPI2C_CR2_SADD)) | (FMPI2C_CR2_START) | (FMPI2C_CR2_AUTOEND)) & (~FMPI2C_CR2_RD_WRN)) : \
NYX 0:85b3fd62ea1a 691 (uint32_t)((((uint32_t)(__ADDRESS__) & (FMPI2C_CR2_SADD)) | (FMPI2C_CR2_ADD10) | (FMPI2C_CR2_START)) & (~FMPI2C_CR2_RD_WRN)))
NYX 0:85b3fd62ea1a 692 /**
NYX 0:85b3fd62ea1a 693 * @}
NYX 0:85b3fd62ea1a 694 */
NYX 0:85b3fd62ea1a 695
NYX 0:85b3fd62ea1a 696 /* Private Functions ---------------------------------------------------------*/
NYX 0:85b3fd62ea1a 697 /** @defgroup FMPI2C_Private_Functions FMPI2C Private Functions
NYX 0:85b3fd62ea1a 698 * @{
NYX 0:85b3fd62ea1a 699 */
NYX 0:85b3fd62ea1a 700 /* Private functions are defined in stm32f4xx_hal_fmpi2c.c file */
NYX 0:85b3fd62ea1a 701 /**
NYX 0:85b3fd62ea1a 702 * @}
NYX 0:85b3fd62ea1a 703 */
NYX 0:85b3fd62ea1a 704
NYX 0:85b3fd62ea1a 705 /**
NYX 0:85b3fd62ea1a 706 * @}
NYX 0:85b3fd62ea1a 707 */
NYX 0:85b3fd62ea1a 708
NYX 0:85b3fd62ea1a 709 /**
NYX 0:85b3fd62ea1a 710 * @}
NYX 0:85b3fd62ea1a 711 */
NYX 0:85b3fd62ea1a 712 #endif /* STM32F410xx || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
NYX 0:85b3fd62ea1a 713 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 714 }
NYX 0:85b3fd62ea1a 715 #endif
NYX 0:85b3fd62ea1a 716
NYX 0:85b3fd62ea1a 717
NYX 0:85b3fd62ea1a 718 #endif /* __STM32F4xx_HAL_FMPI2C_H */
NYX 0:85b3fd62ea1a 719
NYX 0:85b3fd62ea1a 720 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/