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