/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc/fsl_adc_hal.h substitute line 894 extern } by }
Fork of mbed by
TARGET_NUCLEO_L152RE/stm32l1xx_hal_i2c.h@90:cb3d968589d8, 2014-10-28 (annotated)
- Committer:
- Kojto
- Date:
- Tue Oct 28 16:40:41 2014 +0000
- Revision:
- 90:cb3d968589d8
Release 90 of the mbed library
Changes:
- Freescale KSDK update (v1.0)
- K22 - new target addition
- KL43Z - new target addition
- Nucleo F091RC - new target addition
- Nucleo L152RE - STM32Cube driver
- Nordic - Softdevice v7.1.0
- Nvic files - BSD License
- LPC824 - various HAL fixes
- Nucleo F411RE - CMSIS - IAR files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kojto | 90:cb3d968589d8 | 1 | /** |
Kojto | 90:cb3d968589d8 | 2 | ****************************************************************************** |
Kojto | 90:cb3d968589d8 | 3 | * @file stm32l1xx_hal_i2c.h |
Kojto | 90:cb3d968589d8 | 4 | * @author MCD Application Team |
Kojto | 90:cb3d968589d8 | 5 | * @version V1.0.0 |
Kojto | 90:cb3d968589d8 | 6 | * @date 5-September-2014 |
Kojto | 90:cb3d968589d8 | 7 | * @brief Header file of I2C HAL module. |
Kojto | 90:cb3d968589d8 | 8 | ****************************************************************************** |
Kojto | 90:cb3d968589d8 | 9 | * @attention |
Kojto | 90:cb3d968589d8 | 10 | * |
Kojto | 90:cb3d968589d8 | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
Kojto | 90:cb3d968589d8 | 12 | * |
Kojto | 90:cb3d968589d8 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
Kojto | 90:cb3d968589d8 | 14 | * are permitted provided that the following conditions are met: |
Kojto | 90:cb3d968589d8 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
Kojto | 90:cb3d968589d8 | 16 | * this list of conditions and the following disclaimer. |
Kojto | 90:cb3d968589d8 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Kojto | 90:cb3d968589d8 | 18 | * this list of conditions and the following disclaimer in the documentation |
Kojto | 90:cb3d968589d8 | 19 | * and/or other materials provided with the distribution. |
Kojto | 90:cb3d968589d8 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Kojto | 90:cb3d968589d8 | 21 | * may be used to endorse or promote products derived from this software |
Kojto | 90:cb3d968589d8 | 22 | * without specific prior written permission. |
Kojto | 90:cb3d968589d8 | 23 | * |
Kojto | 90:cb3d968589d8 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Kojto | 90:cb3d968589d8 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Kojto | 90:cb3d968589d8 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Kojto | 90:cb3d968589d8 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Kojto | 90:cb3d968589d8 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Kojto | 90:cb3d968589d8 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Kojto | 90:cb3d968589d8 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Kojto | 90:cb3d968589d8 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Kojto | 90:cb3d968589d8 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Kojto | 90:cb3d968589d8 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Kojto | 90:cb3d968589d8 | 34 | * |
Kojto | 90:cb3d968589d8 | 35 | ****************************************************************************** |
Kojto | 90:cb3d968589d8 | 36 | */ |
Kojto | 90:cb3d968589d8 | 37 | |
Kojto | 90:cb3d968589d8 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 39 | #ifndef __STM32L1xx_HAL_I2C_H |
Kojto | 90:cb3d968589d8 | 40 | #define __STM32L1xx_HAL_I2C_H |
Kojto | 90:cb3d968589d8 | 41 | |
Kojto | 90:cb3d968589d8 | 42 | #ifdef __cplusplus |
Kojto | 90:cb3d968589d8 | 43 | extern "C" { |
Kojto | 90:cb3d968589d8 | 44 | #endif |
Kojto | 90:cb3d968589d8 | 45 | |
Kojto | 90:cb3d968589d8 | 46 | /* Includes ------------------------------------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 47 | #include "stm32l1xx_hal_def.h" |
Kojto | 90:cb3d968589d8 | 48 | |
Kojto | 90:cb3d968589d8 | 49 | /** @addtogroup STM32L1xx_HAL_Driver |
Kojto | 90:cb3d968589d8 | 50 | * @{ |
Kojto | 90:cb3d968589d8 | 51 | */ |
Kojto | 90:cb3d968589d8 | 52 | |
Kojto | 90:cb3d968589d8 | 53 | /** @addtogroup I2C |
Kojto | 90:cb3d968589d8 | 54 | * @{ |
Kojto | 90:cb3d968589d8 | 55 | */ |
Kojto | 90:cb3d968589d8 | 56 | |
Kojto | 90:cb3d968589d8 | 57 | /* Exported types ------------------------------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 58 | /** @defgroup I2C_Exported_Types I2C Exported Types |
Kojto | 90:cb3d968589d8 | 59 | * @{ |
Kojto | 90:cb3d968589d8 | 60 | */ |
Kojto | 90:cb3d968589d8 | 61 | |
Kojto | 90:cb3d968589d8 | 62 | /** |
Kojto | 90:cb3d968589d8 | 63 | * @brief I2C Configuration Structure definition |
Kojto | 90:cb3d968589d8 | 64 | */ |
Kojto | 90:cb3d968589d8 | 65 | typedef struct |
Kojto | 90:cb3d968589d8 | 66 | { |
Kojto | 90:cb3d968589d8 | 67 | uint32_t ClockSpeed; /*!< Specifies the clock frequency. |
Kojto | 90:cb3d968589d8 | 68 | This parameter must be set to a value lower than 400kHz */ |
Kojto | 90:cb3d968589d8 | 69 | |
Kojto | 90:cb3d968589d8 | 70 | uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle. |
Kojto | 90:cb3d968589d8 | 71 | This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */ |
Kojto | 90:cb3d968589d8 | 72 | |
Kojto | 90:cb3d968589d8 | 73 | uint32_t OwnAddress1; /*!< Specifies the first device own address. |
Kojto | 90:cb3d968589d8 | 74 | This parameter can be a 7-bit or 10-bit address. */ |
Kojto | 90:cb3d968589d8 | 75 | |
Kojto | 90:cb3d968589d8 | 76 | uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected. |
Kojto | 90:cb3d968589d8 | 77 | This parameter can be a value of @ref I2C_addressing_mode */ |
Kojto | 90:cb3d968589d8 | 78 | |
Kojto | 90:cb3d968589d8 | 79 | uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected. |
Kojto | 90:cb3d968589d8 | 80 | This parameter can be a value of @ref I2C_dual_addressing_mode */ |
Kojto | 90:cb3d968589d8 | 81 | |
Kojto | 90:cb3d968589d8 | 82 | uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected |
Kojto | 90:cb3d968589d8 | 83 | This parameter can be a 7-bit address. */ |
Kojto | 90:cb3d968589d8 | 84 | |
Kojto | 90:cb3d968589d8 | 85 | uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected. |
Kojto | 90:cb3d968589d8 | 86 | This parameter can be a value of @ref I2C_general_call_addressing_mode */ |
Kojto | 90:cb3d968589d8 | 87 | |
Kojto | 90:cb3d968589d8 | 88 | uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected. |
Kojto | 90:cb3d968589d8 | 89 | This parameter can be a value of @ref I2C_nostretch_mode */ |
Kojto | 90:cb3d968589d8 | 90 | |
Kojto | 90:cb3d968589d8 | 91 | }I2C_InitTypeDef; |
Kojto | 90:cb3d968589d8 | 92 | |
Kojto | 90:cb3d968589d8 | 93 | /** |
Kojto | 90:cb3d968589d8 | 94 | * @brief HAL State structures definition |
Kojto | 90:cb3d968589d8 | 95 | */ |
Kojto | 90:cb3d968589d8 | 96 | typedef enum |
Kojto | 90:cb3d968589d8 | 97 | { |
Kojto | 90:cb3d968589d8 | 98 | HAL_I2C_STATE_RESET = 0x00, /*!< I2C not yet initialized or disabled */ |
Kojto | 90:cb3d968589d8 | 99 | HAL_I2C_STATE_READY = 0x01, /*!< I2C initialized and ready for use */ |
Kojto | 90:cb3d968589d8 | 100 | HAL_I2C_STATE_BUSY = 0x02, /*!< I2C internal process is ongoing */ |
Kojto | 90:cb3d968589d8 | 101 | HAL_I2C_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */ |
Kojto | 90:cb3d968589d8 | 102 | HAL_I2C_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */ |
Kojto | 90:cb3d968589d8 | 103 | HAL_I2C_STATE_MEM_BUSY_TX = 0x32, /*!< Memory Data Transmission process is ongoing */ |
Kojto | 90:cb3d968589d8 | 104 | HAL_I2C_STATE_MEM_BUSY_RX = 0x42, /*!< Memory Data Reception process is ongoing */ |
Kojto | 90:cb3d968589d8 | 105 | HAL_I2C_STATE_TIMEOUT = 0x03, /*!< I2C timeout state */ |
Kojto | 90:cb3d968589d8 | 106 | HAL_I2C_STATE_ERROR = 0x04 /*!< I2C error state */ |
Kojto | 90:cb3d968589d8 | 107 | |
Kojto | 90:cb3d968589d8 | 108 | }HAL_I2C_StateTypeDef; |
Kojto | 90:cb3d968589d8 | 109 | |
Kojto | 90:cb3d968589d8 | 110 | /** |
Kojto | 90:cb3d968589d8 | 111 | * @brief HAL I2C Error Code structure definition |
Kojto | 90:cb3d968589d8 | 112 | */ |
Kojto | 90:cb3d968589d8 | 113 | typedef enum |
Kojto | 90:cb3d968589d8 | 114 | { |
Kojto | 90:cb3d968589d8 | 115 | HAL_I2C_ERROR_NONE = 0x00, /*!< No error */ |
Kojto | 90:cb3d968589d8 | 116 | HAL_I2C_ERROR_BERR = 0x01, /*!< BERR error */ |
Kojto | 90:cb3d968589d8 | 117 | HAL_I2C_ERROR_ARLO = 0x02, /*!< ARLO error */ |
Kojto | 90:cb3d968589d8 | 118 | HAL_I2C_ERROR_AF = 0x04, /*!< AF error */ |
Kojto | 90:cb3d968589d8 | 119 | HAL_I2C_ERROR_OVR = 0x08, /*!< OVR error */ |
Kojto | 90:cb3d968589d8 | 120 | HAL_I2C_ERROR_DMA = 0x10, /*!< DMA transfer error */ |
Kojto | 90:cb3d968589d8 | 121 | HAL_I2C_ERROR_TIMEOUT = 0x20 /*!< Timeout error */ |
Kojto | 90:cb3d968589d8 | 122 | |
Kojto | 90:cb3d968589d8 | 123 | }HAL_I2C_ErrorTypeDef; |
Kojto | 90:cb3d968589d8 | 124 | |
Kojto | 90:cb3d968589d8 | 125 | /** |
Kojto | 90:cb3d968589d8 | 126 | * @brief I2C handle Structure definition |
Kojto | 90:cb3d968589d8 | 127 | */ |
Kojto | 90:cb3d968589d8 | 128 | typedef struct |
Kojto | 90:cb3d968589d8 | 129 | { |
Kojto | 90:cb3d968589d8 | 130 | I2C_TypeDef *Instance; /*!< I2C registers base address */ |
Kojto | 90:cb3d968589d8 | 131 | |
Kojto | 90:cb3d968589d8 | 132 | I2C_InitTypeDef Init; /*!< I2C communication parameters */ |
Kojto | 90:cb3d968589d8 | 133 | |
Kojto | 90:cb3d968589d8 | 134 | uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */ |
Kojto | 90:cb3d968589d8 | 135 | |
Kojto | 90:cb3d968589d8 | 136 | uint16_t XferSize; /*!< I2C transfer size */ |
Kojto | 90:cb3d968589d8 | 137 | |
Kojto | 90:cb3d968589d8 | 138 | __IO uint16_t XferCount; /*!< I2C transfer counter */ |
Kojto | 90:cb3d968589d8 | 139 | |
Kojto | 90:cb3d968589d8 | 140 | DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */ |
Kojto | 90:cb3d968589d8 | 141 | |
Kojto | 90:cb3d968589d8 | 142 | DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */ |
Kojto | 90:cb3d968589d8 | 143 | |
Kojto | 90:cb3d968589d8 | 144 | HAL_LockTypeDef Lock; /*!< I2C locking object */ |
Kojto | 90:cb3d968589d8 | 145 | |
Kojto | 90:cb3d968589d8 | 146 | __IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */ |
Kojto | 90:cb3d968589d8 | 147 | |
Kojto | 90:cb3d968589d8 | 148 | __IO HAL_I2C_ErrorTypeDef ErrorCode; /* I2C Error code */ |
Kojto | 90:cb3d968589d8 | 149 | |
Kojto | 90:cb3d968589d8 | 150 | }I2C_HandleTypeDef; |
Kojto | 90:cb3d968589d8 | 151 | /** |
Kojto | 90:cb3d968589d8 | 152 | * @} |
Kojto | 90:cb3d968589d8 | 153 | */ |
Kojto | 90:cb3d968589d8 | 154 | |
Kojto | 90:cb3d968589d8 | 155 | |
Kojto | 90:cb3d968589d8 | 156 | /* Exported constants --------------------------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 157 | |
Kojto | 90:cb3d968589d8 | 158 | /** @defgroup I2C_Exported_Constants I2C Exported Constants |
Kojto | 90:cb3d968589d8 | 159 | * @{ |
Kojto | 90:cb3d968589d8 | 160 | */ |
Kojto | 90:cb3d968589d8 | 161 | |
Kojto | 90:cb3d968589d8 | 162 | /** @defgroup I2C_duty_cycle_in_fast_mode I2C_duty_cycle_in_fast_mode |
Kojto | 90:cb3d968589d8 | 163 | * @{ |
Kojto | 90:cb3d968589d8 | 164 | */ |
Kojto | 90:cb3d968589d8 | 165 | #define I2C_DUTYCYCLE_2 ((uint32_t)0x00000000) |
Kojto | 90:cb3d968589d8 | 166 | #define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY |
Kojto | 90:cb3d968589d8 | 167 | |
Kojto | 90:cb3d968589d8 | 168 | #define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \ |
Kojto | 90:cb3d968589d8 | 169 | ((CYCLE) == I2C_DUTYCYCLE_16_9)) |
Kojto | 90:cb3d968589d8 | 170 | /** |
Kojto | 90:cb3d968589d8 | 171 | * @} |
Kojto | 90:cb3d968589d8 | 172 | */ |
Kojto | 90:cb3d968589d8 | 173 | |
Kojto | 90:cb3d968589d8 | 174 | /** @defgroup I2C_addressing_mode I2C_addressing_mode |
Kojto | 90:cb3d968589d8 | 175 | * @{ |
Kojto | 90:cb3d968589d8 | 176 | */ |
Kojto | 90:cb3d968589d8 | 177 | #define I2C_ADDRESSINGMODE_7BIT ((uint32_t)0x00004000) |
Kojto | 90:cb3d968589d8 | 178 | #define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | ((uint32_t)0x00004000)) |
Kojto | 90:cb3d968589d8 | 179 | |
Kojto | 90:cb3d968589d8 | 180 | #define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \ |
Kojto | 90:cb3d968589d8 | 181 | ((ADDRESS) == I2C_ADDRESSINGMODE_10BIT)) |
Kojto | 90:cb3d968589d8 | 182 | /** |
Kojto | 90:cb3d968589d8 | 183 | * @} |
Kojto | 90:cb3d968589d8 | 184 | */ |
Kojto | 90:cb3d968589d8 | 185 | |
Kojto | 90:cb3d968589d8 | 186 | /** @defgroup I2C_dual_addressing_mode I2C_dual_addressing_mode |
Kojto | 90:cb3d968589d8 | 187 | * @{ |
Kojto | 90:cb3d968589d8 | 188 | */ |
Kojto | 90:cb3d968589d8 | 189 | #define I2C_DUALADDRESS_DISABLED ((uint32_t)0x00000000) |
Kojto | 90:cb3d968589d8 | 190 | #define I2C_DUALADDRESS_ENABLED I2C_OAR2_ENDUAL |
Kojto | 90:cb3d968589d8 | 191 | |
Kojto | 90:cb3d968589d8 | 192 | #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLED) || \ |
Kojto | 90:cb3d968589d8 | 193 | ((ADDRESS) == I2C_DUALADDRESS_ENABLED)) |
Kojto | 90:cb3d968589d8 | 194 | /** |
Kojto | 90:cb3d968589d8 | 195 | * @} |
Kojto | 90:cb3d968589d8 | 196 | */ |
Kojto | 90:cb3d968589d8 | 197 | |
Kojto | 90:cb3d968589d8 | 198 | /** @defgroup I2C_general_call_addressing_mode I2C_general_call_addressing_mode |
Kojto | 90:cb3d968589d8 | 199 | * @{ |
Kojto | 90:cb3d968589d8 | 200 | */ |
Kojto | 90:cb3d968589d8 | 201 | #define I2C_GENERALCALL_DISABLED ((uint32_t)0x00000000) |
Kojto | 90:cb3d968589d8 | 202 | #define I2C_GENERALCALL_ENABLED I2C_CR1_ENGC |
Kojto | 90:cb3d968589d8 | 203 | |
Kojto | 90:cb3d968589d8 | 204 | #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLED) || \ |
Kojto | 90:cb3d968589d8 | 205 | ((CALL) == I2C_GENERALCALL_ENABLED)) |
Kojto | 90:cb3d968589d8 | 206 | /** |
Kojto | 90:cb3d968589d8 | 207 | * @} |
Kojto | 90:cb3d968589d8 | 208 | */ |
Kojto | 90:cb3d968589d8 | 209 | |
Kojto | 90:cb3d968589d8 | 210 | /** @defgroup I2C_nostretch_mode I2C_nostretch_mode |
Kojto | 90:cb3d968589d8 | 211 | * @{ |
Kojto | 90:cb3d968589d8 | 212 | */ |
Kojto | 90:cb3d968589d8 | 213 | #define I2C_NOSTRETCH_DISABLED ((uint32_t)0x00000000) |
Kojto | 90:cb3d968589d8 | 214 | #define I2C_NOSTRETCH_ENABLED I2C_CR1_NOSTRETCH |
Kojto | 90:cb3d968589d8 | 215 | |
Kojto | 90:cb3d968589d8 | 216 | #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLED) || \ |
Kojto | 90:cb3d968589d8 | 217 | ((STRETCH) == I2C_NOSTRETCH_ENABLED)) |
Kojto | 90:cb3d968589d8 | 218 | /** |
Kojto | 90:cb3d968589d8 | 219 | * @} |
Kojto | 90:cb3d968589d8 | 220 | */ |
Kojto | 90:cb3d968589d8 | 221 | |
Kojto | 90:cb3d968589d8 | 222 | /** @defgroup I2C_Memory_Address_Size I2C_Memory_Address_Size |
Kojto | 90:cb3d968589d8 | 223 | * @{ |
Kojto | 90:cb3d968589d8 | 224 | */ |
Kojto | 90:cb3d968589d8 | 225 | #define I2C_MEMADD_SIZE_8BIT ((uint32_t)0x00000001) |
Kojto | 90:cb3d968589d8 | 226 | #define I2C_MEMADD_SIZE_16BIT ((uint32_t)0x00000010) |
Kojto | 90:cb3d968589d8 | 227 | |
Kojto | 90:cb3d968589d8 | 228 | #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \ |
Kojto | 90:cb3d968589d8 | 229 | ((SIZE) == I2C_MEMADD_SIZE_16BIT)) |
Kojto | 90:cb3d968589d8 | 230 | /** |
Kojto | 90:cb3d968589d8 | 231 | * @} |
Kojto | 90:cb3d968589d8 | 232 | */ |
Kojto | 90:cb3d968589d8 | 233 | |
Kojto | 90:cb3d968589d8 | 234 | /** @defgroup I2C_Interrupt_configuration_definition I2C_Interrupt_configuration_definition |
Kojto | 90:cb3d968589d8 | 235 | * @{ |
Kojto | 90:cb3d968589d8 | 236 | */ |
Kojto | 90:cb3d968589d8 | 237 | #define I2C_IT_BUF I2C_CR2_ITBUFEN |
Kojto | 90:cb3d968589d8 | 238 | #define I2C_IT_EVT I2C_CR2_ITEVTEN |
Kojto | 90:cb3d968589d8 | 239 | #define I2C_IT_ERR I2C_CR2_ITERREN |
Kojto | 90:cb3d968589d8 | 240 | /** |
Kojto | 90:cb3d968589d8 | 241 | * @} |
Kojto | 90:cb3d968589d8 | 242 | */ |
Kojto | 90:cb3d968589d8 | 243 | |
Kojto | 90:cb3d968589d8 | 244 | /** @defgroup I2C_Flag_definition I2C_Flag_definition |
Kojto | 90:cb3d968589d8 | 245 | * @{ |
Kojto | 90:cb3d968589d8 | 246 | */ |
Kojto | 90:cb3d968589d8 | 247 | #define I2C_FLAG_OVR ((uint32_t)(1 << 16 | I2C_SR1_OVR)) |
Kojto | 90:cb3d968589d8 | 248 | #define I2C_FLAG_AF ((uint32_t)(1 << 16 | I2C_SR1_AF)) |
Kojto | 90:cb3d968589d8 | 249 | #define I2C_FLAG_ARLO ((uint32_t)(1 << 16 | I2C_SR1_ARLO)) |
Kojto | 90:cb3d968589d8 | 250 | #define I2C_FLAG_BERR ((uint32_t)(1 << 16 | I2C_SR1_BERR)) |
Kojto | 90:cb3d968589d8 | 251 | #define I2C_FLAG_TXE ((uint32_t)(1 << 16 | I2C_SR1_TXE)) |
Kojto | 90:cb3d968589d8 | 252 | #define I2C_FLAG_RXNE ((uint32_t)(1 << 16 | I2C_SR1_RXNE)) |
Kojto | 90:cb3d968589d8 | 253 | #define I2C_FLAG_STOPF ((uint32_t)(1 << 16 | I2C_SR1_STOPF)) |
Kojto | 90:cb3d968589d8 | 254 | #define I2C_FLAG_ADD10 ((uint32_t)(1 << 16 | I2C_SR1_ADD10)) |
Kojto | 90:cb3d968589d8 | 255 | #define I2C_FLAG_BTF ((uint32_t)(1 << 16 | I2C_SR1_BTF)) |
Kojto | 90:cb3d968589d8 | 256 | #define I2C_FLAG_ADDR ((uint32_t)(1 << 16 | I2C_SR1_ADDR)) |
Kojto | 90:cb3d968589d8 | 257 | #define I2C_FLAG_SB ((uint32_t)(1 << 16 | I2C_SR1_SB)) |
Kojto | 90:cb3d968589d8 | 258 | #define I2C_FLAG_DUALF ((uint32_t)(2 << 16 | I2C_SR2_DUALF)) |
Kojto | 90:cb3d968589d8 | 259 | #define I2C_FLAG_GENCALL ((uint32_t)(2 << 16 | I2C_SR2_GENCALL)) |
Kojto | 90:cb3d968589d8 | 260 | #define I2C_FLAG_TRA ((uint32_t)(2 << 16 | I2C_SR2_TRA)) |
Kojto | 90:cb3d968589d8 | 261 | #define I2C_FLAG_BUSY ((uint32_t)(2 << 16 | I2C_SR2_BUSY)) |
Kojto | 90:cb3d968589d8 | 262 | #define I2C_FLAG_MSL ((uint32_t)(2 << 16 | I2C_SR2_MSL)) |
Kojto | 90:cb3d968589d8 | 263 | |
Kojto | 90:cb3d968589d8 | 264 | |
Kojto | 90:cb3d968589d8 | 265 | #define I2C_FLAG_MASK ((uint32_t)0x0000FFFF) |
Kojto | 90:cb3d968589d8 | 266 | |
Kojto | 90:cb3d968589d8 | 267 | /** |
Kojto | 90:cb3d968589d8 | 268 | * @} |
Kojto | 90:cb3d968589d8 | 269 | */ |
Kojto | 90:cb3d968589d8 | 270 | |
Kojto | 90:cb3d968589d8 | 271 | /** @defgroup I2C_Clock_Speed_definition I2C_Clock_Speed_definition |
Kojto | 90:cb3d968589d8 | 272 | * @{ |
Kojto | 90:cb3d968589d8 | 273 | */ |
Kojto | 90:cb3d968589d8 | 274 | #define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0) && ((SPEED) <= 400000)) |
Kojto | 90:cb3d968589d8 | 275 | /** |
Kojto | 90:cb3d968589d8 | 276 | * @} |
Kojto | 90:cb3d968589d8 | 277 | */ |
Kojto | 90:cb3d968589d8 | 278 | |
Kojto | 90:cb3d968589d8 | 279 | /** @defgroup I2C_Own_Address1_definition I2C_Own_Address1_definition |
Kojto | 90:cb3d968589d8 | 280 | * @{ |
Kojto | 90:cb3d968589d8 | 281 | */ |
Kojto | 90:cb3d968589d8 | 282 | #define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & (uint32_t)(0xFFFFFC00)) == 0) |
Kojto | 90:cb3d968589d8 | 283 | /** |
Kojto | 90:cb3d968589d8 | 284 | * @} |
Kojto | 90:cb3d968589d8 | 285 | */ |
Kojto | 90:cb3d968589d8 | 286 | |
Kojto | 90:cb3d968589d8 | 287 | /** @defgroup I2C_Own_Address2_definition I2C_Own_Address2_definition |
Kojto | 90:cb3d968589d8 | 288 | * @{ |
Kojto | 90:cb3d968589d8 | 289 | */ |
Kojto | 90:cb3d968589d8 | 290 | #define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & (uint32_t)(0xFFFFFF01)) == 0) |
Kojto | 90:cb3d968589d8 | 291 | /** |
Kojto | 90:cb3d968589d8 | 292 | * @} |
Kojto | 90:cb3d968589d8 | 293 | */ |
Kojto | 90:cb3d968589d8 | 294 | |
Kojto | 90:cb3d968589d8 | 295 | |
Kojto | 90:cb3d968589d8 | 296 | /** |
Kojto | 90:cb3d968589d8 | 297 | * @} |
Kojto | 90:cb3d968589d8 | 298 | */ |
Kojto | 90:cb3d968589d8 | 299 | |
Kojto | 90:cb3d968589d8 | 300 | /* Exported macro ------------------------------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 301 | /** @defgroup I2C_Exported_Macros I2C Exported Macros |
Kojto | 90:cb3d968589d8 | 302 | * @{ |
Kojto | 90:cb3d968589d8 | 303 | */ |
Kojto | 90:cb3d968589d8 | 304 | |
Kojto | 90:cb3d968589d8 | 305 | /** @brief Reset I2C handle state |
Kojto | 90:cb3d968589d8 | 306 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 307 | * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 308 | * @retval None |
Kojto | 90:cb3d968589d8 | 309 | */ |
Kojto | 90:cb3d968589d8 | 310 | #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET) |
Kojto | 90:cb3d968589d8 | 311 | |
Kojto | 90:cb3d968589d8 | 312 | /** @brief Enable or disable the specified I2C interrupts. |
Kojto | 90:cb3d968589d8 | 313 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 314 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 315 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
Kojto | 90:cb3d968589d8 | 316 | * This parameter can be one of the following values: |
Kojto | 90:cb3d968589d8 | 317 | * @arg I2C_IT_BUF: Buffer interrupt enable |
Kojto | 90:cb3d968589d8 | 318 | * @arg I2C_IT_EVT: Event interrupt enable |
Kojto | 90:cb3d968589d8 | 319 | * @arg I2C_IT_ERR: Error interrupt enable |
Kojto | 90:cb3d968589d8 | 320 | * @retval None |
Kojto | 90:cb3d968589d8 | 321 | */ |
Kojto | 90:cb3d968589d8 | 322 | |
Kojto | 90:cb3d968589d8 | 323 | #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__)) |
Kojto | 90:cb3d968589d8 | 324 | #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR2, (__INTERRUPT__)) |
Kojto | 90:cb3d968589d8 | 325 | |
Kojto | 90:cb3d968589d8 | 326 | /** @brief Checks if the specified I2C interrupt source is enabled or disabled. |
Kojto | 90:cb3d968589d8 | 327 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 328 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 329 | * @param __INTERRUPT__: specifies the I2C interrupt source to check. |
Kojto | 90:cb3d968589d8 | 330 | * This parameter can be one of the following values: |
Kojto | 90:cb3d968589d8 | 331 | * @arg I2C_IT_BUF: Buffer interrupt enable |
Kojto | 90:cb3d968589d8 | 332 | * @arg I2C_IT_EVT: Event interrupt enable |
Kojto | 90:cb3d968589d8 | 333 | * @arg I2C_IT_ERR: Error interrupt enable |
Kojto | 90:cb3d968589d8 | 334 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
Kojto | 90:cb3d968589d8 | 335 | */ |
Kojto | 90:cb3d968589d8 | 336 | #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
Kojto | 90:cb3d968589d8 | 337 | |
Kojto | 90:cb3d968589d8 | 338 | /** @brief Checks whether the specified I2C flag is set or not. |
Kojto | 90:cb3d968589d8 | 339 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 340 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 341 | * @param __FLAG__: specifies the flag to check. |
Kojto | 90:cb3d968589d8 | 342 | * This parameter can be one of the following values: |
Kojto | 90:cb3d968589d8 | 343 | * @arg I2C_FLAG_OVR: Overrun/Underrun flag |
Kojto | 90:cb3d968589d8 | 344 | * @arg I2C_FLAG_AF: Acknowledge failure flag |
Kojto | 90:cb3d968589d8 | 345 | * @arg I2C_FLAG_ARLO: Arbitration lost flag |
Kojto | 90:cb3d968589d8 | 346 | * @arg I2C_FLAG_BERR: Bus error flag |
Kojto | 90:cb3d968589d8 | 347 | * @arg I2C_FLAG_TXE: Data register empty flag |
Kojto | 90:cb3d968589d8 | 348 | * @arg I2C_FLAG_RXNE: Data register not empty flag |
Kojto | 90:cb3d968589d8 | 349 | * @arg I2C_FLAG_STOPF: Stop detection flag |
Kojto | 90:cb3d968589d8 | 350 | * @arg I2C_FLAG_ADD10: 10-bit header sent flag |
Kojto | 90:cb3d968589d8 | 351 | * @arg I2C_FLAG_BTF: Byte transfer finished flag |
Kojto | 90:cb3d968589d8 | 352 | * @arg I2C_FLAG_ADDR: Address sent flag |
Kojto | 90:cb3d968589d8 | 353 | * Address matched flag |
Kojto | 90:cb3d968589d8 | 354 | * @arg I2C_FLAG_SB: Start bit flag |
Kojto | 90:cb3d968589d8 | 355 | * @arg I2C_FLAG_DUALF: Dual flag |
Kojto | 90:cb3d968589d8 | 356 | * @arg I2C_FLAG_GENCALL: General call header flag |
Kojto | 90:cb3d968589d8 | 357 | * @arg I2C_FLAG_TRA: Transmitter/Receiver flag |
Kojto | 90:cb3d968589d8 | 358 | * @arg I2C_FLAG_BUSY: Bus busy flag |
Kojto | 90:cb3d968589d8 | 359 | * @arg I2C_FLAG_MSL: Master/Slave flag |
Kojto | 90:cb3d968589d8 | 360 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
Kojto | 90:cb3d968589d8 | 361 | */ |
Kojto | 90:cb3d968589d8 | 362 | #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16)) == 0x01)?((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)): \ |
Kojto | 90:cb3d968589d8 | 363 | ((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK))) |
Kojto | 90:cb3d968589d8 | 364 | |
Kojto | 90:cb3d968589d8 | 365 | /** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit. |
Kojto | 90:cb3d968589d8 | 366 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 367 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 368 | * @param __FLAG__: specifies the flag to clear. |
Kojto | 90:cb3d968589d8 | 369 | * This parameter can be any combination of the following values: |
Kojto | 90:cb3d968589d8 | 370 | * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) |
Kojto | 90:cb3d968589d8 | 371 | * @arg I2C_FLAG_AF: Acknowledge failure flag |
Kojto | 90:cb3d968589d8 | 372 | * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) |
Kojto | 90:cb3d968589d8 | 373 | * @arg I2C_FLAG_BERR: Bus error flag |
Kojto | 90:cb3d968589d8 | 374 | * @retval None |
Kojto | 90:cb3d968589d8 | 375 | */ |
Kojto | 90:cb3d968589d8 | 376 | #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK)) |
Kojto | 90:cb3d968589d8 | 377 | |
Kojto | 90:cb3d968589d8 | 378 | /** @brief Clears the I2C ADDR pending flag. |
Kojto | 90:cb3d968589d8 | 379 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 380 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 381 | * @retval None |
Kojto | 90:cb3d968589d8 | 382 | */ |
Kojto | 90:cb3d968589d8 | 383 | |
Kojto | 90:cb3d968589d8 | 384 | #define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR1;\ |
Kojto | 90:cb3d968589d8 | 385 | (__HANDLE__)->Instance->SR2;}while(0) |
Kojto | 90:cb3d968589d8 | 386 | |
Kojto | 90:cb3d968589d8 | 387 | /** @brief Clears the I2C STOPF pending flag. |
Kojto | 90:cb3d968589d8 | 388 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 389 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 390 | * @retval None |
Kojto | 90:cb3d968589d8 | 391 | */ |
Kojto | 90:cb3d968589d8 | 392 | #define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) do{(__HANDLE__)->Instance->SR1;\ |
Kojto | 90:cb3d968589d8 | 393 | SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE);}while(0) |
Kojto | 90:cb3d968589d8 | 394 | |
Kojto | 90:cb3d968589d8 | 395 | /** @brief Enable the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 396 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 397 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 398 | * @retval None |
Kojto | 90:cb3d968589d8 | 399 | */ |
Kojto | 90:cb3d968589d8 | 400 | #define __HAL_I2C_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE) |
Kojto | 90:cb3d968589d8 | 401 | |
Kojto | 90:cb3d968589d8 | 402 | /** @brief Disable the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 403 | * @param __HANDLE__: specifies the I2C Handle. |
Kojto | 90:cb3d968589d8 | 404 | * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral. |
Kojto | 90:cb3d968589d8 | 405 | * @retval None |
Kojto | 90:cb3d968589d8 | 406 | */ |
Kojto | 90:cb3d968589d8 | 407 | #define __HAL_I2C_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR1, I2C_CR1_PE) |
Kojto | 90:cb3d968589d8 | 408 | |
Kojto | 90:cb3d968589d8 | 409 | /** |
Kojto | 90:cb3d968589d8 | 410 | * @} |
Kojto | 90:cb3d968589d8 | 411 | */ |
Kojto | 90:cb3d968589d8 | 412 | |
Kojto | 90:cb3d968589d8 | 413 | /** @defgroup I2C_Private_Macros I2C Private Macros |
Kojto | 90:cb3d968589d8 | 414 | * @{ |
Kojto | 90:cb3d968589d8 | 415 | */ |
Kojto | 90:cb3d968589d8 | 416 | |
Kojto | 90:cb3d968589d8 | 417 | #define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000) |
Kojto | 90:cb3d968589d8 | 418 | #define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000) ? ((__FREQRANGE__) + 1) : ((((__FREQRANGE__) * 300) / 1000) + 1)) |
Kojto | 90:cb3d968589d8 | 419 | #define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) (((((__PCLK__)/((__SPEED__) << 1)) & I2C_CCR_CCR) < 4)? 4:((__PCLK__) / ((__SPEED__) << 1))) |
Kojto | 90:cb3d968589d8 | 420 | #define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? ((__PCLK__) / ((__SPEED__) * 3)) : (((__PCLK__) / ((__SPEED__) * 25)) | I2C_DUTYCYCLE_16_9)) |
Kojto | 90:cb3d968589d8 | 421 | #define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \ |
Kojto | 90:cb3d968589d8 | 422 | ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0)? 1 : \ |
Kojto | 90:cb3d968589d8 | 423 | ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS)) |
Kojto | 90:cb3d968589d8 | 424 | |
Kojto | 90:cb3d968589d8 | 425 | #define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (~I2C_OAR1_ADD0))) |
Kojto | 90:cb3d968589d8 | 426 | #define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0)) |
Kojto | 90:cb3d968589d8 | 427 | |
Kojto | 90:cb3d968589d8 | 428 | #define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF)))) |
Kojto | 90:cb3d968589d8 | 429 | #define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF0)))) |
Kojto | 90:cb3d968589d8 | 430 | #define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0x0300))) >> 7) | (uint16_t)(0xF1)))) |
Kojto | 90:cb3d968589d8 | 431 | |
Kojto | 90:cb3d968589d8 | 432 | #define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8))) |
Kojto | 90:cb3d968589d8 | 433 | #define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF)))) |
Kojto | 90:cb3d968589d8 | 434 | |
Kojto | 90:cb3d968589d8 | 435 | /** |
Kojto | 90:cb3d968589d8 | 436 | * @} |
Kojto | 90:cb3d968589d8 | 437 | */ |
Kojto | 90:cb3d968589d8 | 438 | |
Kojto | 90:cb3d968589d8 | 439 | |
Kojto | 90:cb3d968589d8 | 440 | /* Exported functions --------------------------------------------------------*/ |
Kojto | 90:cb3d968589d8 | 441 | /** @addtogroup I2C_Exported_Functions |
Kojto | 90:cb3d968589d8 | 442 | * @{ |
Kojto | 90:cb3d968589d8 | 443 | */ |
Kojto | 90:cb3d968589d8 | 444 | |
Kojto | 90:cb3d968589d8 | 445 | /* Initialization/de-initialization functions **********************************/ |
Kojto | 90:cb3d968589d8 | 446 | /** @addtogroup I2C_Exported_Functions_Group1 |
Kojto | 90:cb3d968589d8 | 447 | * @{ |
Kojto | 90:cb3d968589d8 | 448 | */ |
Kojto | 90:cb3d968589d8 | 449 | |
Kojto | 90:cb3d968589d8 | 450 | HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 451 | HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 452 | void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 453 | void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 454 | |
Kojto | 90:cb3d968589d8 | 455 | /** |
Kojto | 90:cb3d968589d8 | 456 | * @} |
Kojto | 90:cb3d968589d8 | 457 | */ |
Kojto | 90:cb3d968589d8 | 458 | |
Kojto | 90:cb3d968589d8 | 459 | |
Kojto | 90:cb3d968589d8 | 460 | /* I/O operation functions *****************************************************/ |
Kojto | 90:cb3d968589d8 | 461 | /** @addtogroup I2C_Exported_Functions_Group2 |
Kojto | 90:cb3d968589d8 | 462 | * @{ |
Kojto | 90:cb3d968589d8 | 463 | */ |
Kojto | 90:cb3d968589d8 | 464 | |
Kojto | 90:cb3d968589d8 | 465 | /******* Blocking mode: Polling */ |
Kojto | 90:cb3d968589d8 | 466 | HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
Kojto | 90:cb3d968589d8 | 467 | HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
Kojto | 90:cb3d968589d8 | 468 | HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
Kojto | 90:cb3d968589d8 | 469 | HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
Kojto | 90:cb3d968589d8 | 470 | 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 | 90:cb3d968589d8 | 471 | 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 | 90:cb3d968589d8 | 472 | HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout); |
Kojto | 90:cb3d968589d8 | 473 | |
Kojto | 90:cb3d968589d8 | 474 | /******* Non-Blocking mode: Interrupt */ |
Kojto | 90:cb3d968589d8 | 475 | HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 476 | HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 477 | HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 478 | HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 479 | 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 | 90:cb3d968589d8 | 480 | 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 | 90:cb3d968589d8 | 481 | |
Kojto | 90:cb3d968589d8 | 482 | /******* Non-Blocking mode: DMA */ |
Kojto | 90:cb3d968589d8 | 483 | HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 484 | HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 485 | HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 486 | HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size); |
Kojto | 90:cb3d968589d8 | 487 | 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 | 90:cb3d968589d8 | 488 | 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 | 90:cb3d968589d8 | 489 | |
Kojto | 90:cb3d968589d8 | 490 | /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ |
Kojto | 90:cb3d968589d8 | 491 | void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 492 | void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 493 | void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 494 | void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 495 | void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 496 | void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 497 | void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 498 | void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 499 | void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 500 | |
Kojto | 90:cb3d968589d8 | 501 | /** |
Kojto | 90:cb3d968589d8 | 502 | * @} |
Kojto | 90:cb3d968589d8 | 503 | */ |
Kojto | 90:cb3d968589d8 | 504 | |
Kojto | 90:cb3d968589d8 | 505 | |
Kojto | 90:cb3d968589d8 | 506 | /* Peripheral Control and State functions **************************************/ |
Kojto | 90:cb3d968589d8 | 507 | /** @addtogroup I2C_Exported_Functions_Group3 |
Kojto | 90:cb3d968589d8 | 508 | * @{ |
Kojto | 90:cb3d968589d8 | 509 | */ |
Kojto | 90:cb3d968589d8 | 510 | |
Kojto | 90:cb3d968589d8 | 511 | HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 512 | uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c); |
Kojto | 90:cb3d968589d8 | 513 | /** |
Kojto | 90:cb3d968589d8 | 514 | * @} |
Kojto | 90:cb3d968589d8 | 515 | */ |
Kojto | 90:cb3d968589d8 | 516 | |
Kojto | 90:cb3d968589d8 | 517 | /** |
Kojto | 90:cb3d968589d8 | 518 | * @} |
Kojto | 90:cb3d968589d8 | 519 | */ |
Kojto | 90:cb3d968589d8 | 520 | |
Kojto | 90:cb3d968589d8 | 521 | |
Kojto | 90:cb3d968589d8 | 522 | |
Kojto | 90:cb3d968589d8 | 523 | /** |
Kojto | 90:cb3d968589d8 | 524 | * @} |
Kojto | 90:cb3d968589d8 | 525 | */ |
Kojto | 90:cb3d968589d8 | 526 | |
Kojto | 90:cb3d968589d8 | 527 | /** |
Kojto | 90:cb3d968589d8 | 528 | * @} |
Kojto | 90:cb3d968589d8 | 529 | */ |
Kojto | 90:cb3d968589d8 | 530 | |
Kojto | 90:cb3d968589d8 | 531 | #ifdef __cplusplus |
Kojto | 90:cb3d968589d8 | 532 | } |
Kojto | 90:cb3d968589d8 | 533 | #endif |
Kojto | 90:cb3d968589d8 | 534 | |
Kojto | 90:cb3d968589d8 | 535 | |
Kojto | 90:cb3d968589d8 | 536 | #endif /* __STM32L1xx_HAL_I2C_H */ |
Kojto | 90:cb3d968589d8 | 537 | |
Kojto | 90:cb3d968589d8 | 538 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |