mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_i2c_ex.c@180:96ed750bd169, 2018-01-17 (annotated)
- Committer:
- Anna Bridge
- Date:
- Wed Jan 17 15:23:54 2018 +0000
- Revision:
- 180:96ed750bd169
- Parent:
- 156:95d6b41a828b
mbed-dev libray. Release version 158
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f0xx_hal_i2c_ex.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 144:ef7eb2e8f9f7 | 5 | * @brief I2C Extended HAL module driver. |
Anna Bridge |
180:96ed750bd169 | 6 | * This file provides firmware functions to manage the following |
<> | 144:ef7eb2e8f9f7 | 7 | * functionalities of I2C Extended peripheral: |
<> | 144:ef7eb2e8f9f7 | 8 | * + Extended features functions |
<> | 156:95d6b41a828b | 9 | * |
<> | 144:ef7eb2e8f9f7 | 10 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 11 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 12 | ##### I2C peripheral Extended features ##### |
<> | 144:ef7eb2e8f9f7 | 13 | ============================================================================== |
<> | 156:95d6b41a828b | 14 | |
<> | 144:ef7eb2e8f9f7 | 15 | [..] Comparing to other previous devices, the I2C interface for STM32F0xx |
<> | 144:ef7eb2e8f9f7 | 16 | devices contains the following additional features |
<> | 156:95d6b41a828b | 17 | |
<> | 144:ef7eb2e8f9f7 | 18 | (+) Possibility to disable or enable Analog Noise Filter |
<> | 144:ef7eb2e8f9f7 | 19 | (+) Use of a configured Digital Noise Filter |
<> | 144:ef7eb2e8f9f7 | 20 | (+) Disable or enable wakeup from Stop mode |
<> | 156:95d6b41a828b | 21 | |
<> | 144:ef7eb2e8f9f7 | 22 | ##### How to use this driver ##### |
<> | 144:ef7eb2e8f9f7 | 23 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 24 | [..] This driver provides functions to configure Noise Filter and Wake Up Feature |
<> | 144:ef7eb2e8f9f7 | 25 | (#) Configure I2C Analog noise filter using the function HAL_I2CEx_ConfigAnalogFilter() |
<> | 144:ef7eb2e8f9f7 | 26 | (#) Configure I2C Digital noise filter using the function HAL_I2CEx_ConfigDigitalFilter() |
<> | 144:ef7eb2e8f9f7 | 27 | (#) Configure the enable or disable of I2C Wake Up Mode using the functions : |
<> | 144:ef7eb2e8f9f7 | 28 | (++) HAL_I2CEx_EnableWakeUp() |
<> | 144:ef7eb2e8f9f7 | 29 | (++) HAL_I2CEx_DisableWakeUp() |
<> | 144:ef7eb2e8f9f7 | 30 | (#) Configure the enable or disable of fast mode plus driving capability using the functions : |
<> | 144:ef7eb2e8f9f7 | 31 | (++) HAL_I2CEx_EnableFastModePlus() |
<> | 156:95d6b41a828b | 32 | (++) HAL_I2CEx_DisableFastModePlus() |
<> | 144:ef7eb2e8f9f7 | 33 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 34 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 35 | * @attention |
<> | 144:ef7eb2e8f9f7 | 36 | * |
<> | 144:ef7eb2e8f9f7 | 37 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 38 | * |
<> | 144:ef7eb2e8f9f7 | 39 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 40 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 41 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 42 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 43 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 44 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 45 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 46 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 47 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 48 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 49 | * |
<> | 144:ef7eb2e8f9f7 | 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 51 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 52 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 53 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 54 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 55 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 56 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 57 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 58 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 59 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 60 | * |
<> | 156:95d6b41a828b | 61 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 62 | */ |
<> | 144:ef7eb2e8f9f7 | 63 | |
<> | 144:ef7eb2e8f9f7 | 64 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 65 | #include "stm32f0xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 66 | |
<> | 144:ef7eb2e8f9f7 | 67 | /** @addtogroup STM32F0xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 68 | * @{ |
<> | 144:ef7eb2e8f9f7 | 69 | */ |
<> | 144:ef7eb2e8f9f7 | 70 | |
<> | 144:ef7eb2e8f9f7 | 71 | /** @defgroup I2CEx I2CEx |
<> | 144:ef7eb2e8f9f7 | 72 | * @brief I2C Extended HAL module driver |
<> | 144:ef7eb2e8f9f7 | 73 | * @{ |
<> | 144:ef7eb2e8f9f7 | 74 | */ |
<> | 144:ef7eb2e8f9f7 | 75 | |
<> | 144:ef7eb2e8f9f7 | 76 | #ifdef HAL_I2C_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 77 | |
<> | 144:ef7eb2e8f9f7 | 78 | /* Private typedef -----------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 79 | /* Private define ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 80 | /* Private macro -------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 81 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 82 | /* Private function prototypes -----------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 83 | /* Private functions ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 84 | |
<> | 144:ef7eb2e8f9f7 | 85 | /** @defgroup I2CEx_Exported_Functions I2C Extended Exported Functions |
<> | 144:ef7eb2e8f9f7 | 86 | * @{ |
<> | 144:ef7eb2e8f9f7 | 87 | */ |
<> | 144:ef7eb2e8f9f7 | 88 | |
<> | 144:ef7eb2e8f9f7 | 89 | /** @defgroup I2CEx_Exported_Functions_Group1 Extended features functions |
<> | 144:ef7eb2e8f9f7 | 90 | * @brief Extended features functions |
<> | 156:95d6b41a828b | 91 | * |
<> | 156:95d6b41a828b | 92 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 93 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 94 | ##### Extended features functions ##### |
<> | 156:95d6b41a828b | 95 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 96 | [..] This section provides functions allowing to: |
Anna Bridge |
180:96ed750bd169 | 97 | (+) Configure Noise Filters |
<> | 144:ef7eb2e8f9f7 | 98 | (+) Configure Wake Up Feature |
<> | 144:ef7eb2e8f9f7 | 99 | |
<> | 144:ef7eb2e8f9f7 | 100 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 101 | * @{ |
<> | 144:ef7eb2e8f9f7 | 102 | */ |
<> | 156:95d6b41a828b | 103 | |
<> | 144:ef7eb2e8f9f7 | 104 | /** |
<> | 156:95d6b41a828b | 105 | * @brief Configure I2C Analog noise filter. |
<> | 144:ef7eb2e8f9f7 | 106 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 107 | * the configuration information for the specified I2Cx peripheral. |
<> | 144:ef7eb2e8f9f7 | 108 | * @param AnalogFilter New state of the Analog filter. |
<> | 144:ef7eb2e8f9f7 | 109 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 110 | */ |
<> | 144:ef7eb2e8f9f7 | 111 | HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter) |
<> | 144:ef7eb2e8f9f7 | 112 | { |
<> | 144:ef7eb2e8f9f7 | 113 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 114 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); |
<> | 144:ef7eb2e8f9f7 | 115 | assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter)); |
<> | 156:95d6b41a828b | 116 | |
Anna Bridge |
180:96ed750bd169 | 117 | if (hi2c->State == HAL_I2C_STATE_READY) |
<> | 156:95d6b41a828b | 118 | { |
<> | 144:ef7eb2e8f9f7 | 119 | /* Process Locked */ |
<> | 144:ef7eb2e8f9f7 | 120 | __HAL_LOCK(hi2c); |
<> | 156:95d6b41a828b | 121 | |
<> | 144:ef7eb2e8f9f7 | 122 | hi2c->State = HAL_I2C_STATE_BUSY; |
<> | 156:95d6b41a828b | 123 | |
<> | 144:ef7eb2e8f9f7 | 124 | /* Disable the selected I2C peripheral */ |
<> | 156:95d6b41a828b | 125 | __HAL_I2C_DISABLE(hi2c); |
<> | 156:95d6b41a828b | 126 | |
<> | 144:ef7eb2e8f9f7 | 127 | /* Reset I2Cx ANOFF bit */ |
<> | 156:95d6b41a828b | 128 | hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF); |
<> | 156:95d6b41a828b | 129 | |
<> | 144:ef7eb2e8f9f7 | 130 | /* Set analog filter bit*/ |
<> | 144:ef7eb2e8f9f7 | 131 | hi2c->Instance->CR1 |= AnalogFilter; |
<> | 156:95d6b41a828b | 132 | |
<> | 156:95d6b41a828b | 133 | __HAL_I2C_ENABLE(hi2c); |
<> | 156:95d6b41a828b | 134 | |
<> | 144:ef7eb2e8f9f7 | 135 | hi2c->State = HAL_I2C_STATE_READY; |
<> | 156:95d6b41a828b | 136 | |
<> | 144:ef7eb2e8f9f7 | 137 | /* Process Unlocked */ |
<> | 144:ef7eb2e8f9f7 | 138 | __HAL_UNLOCK(hi2c); |
<> | 156:95d6b41a828b | 139 | |
<> | 156:95d6b41a828b | 140 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 141 | } |
<> | 144:ef7eb2e8f9f7 | 142 | else |
<> | 144:ef7eb2e8f9f7 | 143 | { |
<> | 144:ef7eb2e8f9f7 | 144 | return HAL_BUSY; |
<> | 144:ef7eb2e8f9f7 | 145 | } |
<> | 144:ef7eb2e8f9f7 | 146 | } |
<> | 144:ef7eb2e8f9f7 | 147 | |
<> | 144:ef7eb2e8f9f7 | 148 | /** |
<> | 156:95d6b41a828b | 149 | * @brief Configure I2C Digital noise filter. |
<> | 144:ef7eb2e8f9f7 | 150 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 151 | * the configuration information for the specified I2Cx peripheral. |
<> | 156:95d6b41a828b | 152 | * @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F. |
<> | 144:ef7eb2e8f9f7 | 153 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 154 | */ |
<> | 144:ef7eb2e8f9f7 | 155 | HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter) |
<> | 144:ef7eb2e8f9f7 | 156 | { |
<> | 144:ef7eb2e8f9f7 | 157 | uint32_t tmpreg = 0U; |
<> | 156:95d6b41a828b | 158 | |
<> | 144:ef7eb2e8f9f7 | 159 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 160 | assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance)); |
<> | 144:ef7eb2e8f9f7 | 161 | assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter)); |
<> | 156:95d6b41a828b | 162 | |
Anna Bridge |
180:96ed750bd169 | 163 | if (hi2c->State == HAL_I2C_STATE_READY) |
<> | 156:95d6b41a828b | 164 | { |
<> | 144:ef7eb2e8f9f7 | 165 | /* Process Locked */ |
<> | 144:ef7eb2e8f9f7 | 166 | __HAL_LOCK(hi2c); |
<> | 156:95d6b41a828b | 167 | |
<> | 144:ef7eb2e8f9f7 | 168 | hi2c->State = HAL_I2C_STATE_BUSY; |
<> | 156:95d6b41a828b | 169 | |
<> | 144:ef7eb2e8f9f7 | 170 | /* Disable the selected I2C peripheral */ |
<> | 156:95d6b41a828b | 171 | __HAL_I2C_DISABLE(hi2c); |
<> | 156:95d6b41a828b | 172 | |
<> | 144:ef7eb2e8f9f7 | 173 | /* Get the old register value */ |
<> | 144:ef7eb2e8f9f7 | 174 | tmpreg = hi2c->Instance->CR1; |
<> | 156:95d6b41a828b | 175 | |
<> | 144:ef7eb2e8f9f7 | 176 | /* Reset I2Cx DNF bits [11:8] */ |
<> | 144:ef7eb2e8f9f7 | 177 | tmpreg &= ~(I2C_CR1_DNF); |
<> | 156:95d6b41a828b | 178 | |
<> | 144:ef7eb2e8f9f7 | 179 | /* Set I2Cx DNF coefficient */ |
<> | 144:ef7eb2e8f9f7 | 180 | tmpreg |= DigitalFilter << 8U; |
<> | 156:95d6b41a828b | 181 | |
<> | 144:ef7eb2e8f9f7 | 182 | /* Store the new register value */ |
<> | 144:ef7eb2e8f9f7 | 183 | hi2c->Instance->CR1 = tmpreg; |
<> | 156:95d6b41a828b | 184 | |
<> | 156:95d6b41a828b | 185 | __HAL_I2C_ENABLE(hi2c); |
<> | 156:95d6b41a828b | 186 | |
<> | 144:ef7eb2e8f9f7 | 187 | hi2c->State = HAL_I2C_STATE_READY; |
<> | 156:95d6b41a828b | 188 | |
<> | 144:ef7eb2e8f9f7 | 189 | /* Process Unlocked */ |
<> | 144:ef7eb2e8f9f7 | 190 | __HAL_UNLOCK(hi2c); |
<> | 156:95d6b41a828b | 191 | |
<> | 144:ef7eb2e8f9f7 | 192 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 193 | } |
<> | 144:ef7eb2e8f9f7 | 194 | else |
<> | 144:ef7eb2e8f9f7 | 195 | { |
<> | 144:ef7eb2e8f9f7 | 196 | return HAL_BUSY; |
<> | 144:ef7eb2e8f9f7 | 197 | } |
<> | 156:95d6b41a828b | 198 | } |
<> | 156:95d6b41a828b | 199 | #if defined(I2C_CR1_WUPEN) |
<> | 144:ef7eb2e8f9f7 | 200 | |
<> | 144:ef7eb2e8f9f7 | 201 | /** |
<> | 144:ef7eb2e8f9f7 | 202 | * @brief Enable I2C wakeup from stop mode. |
<> | 144:ef7eb2e8f9f7 | 203 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 204 | * the configuration information for the specified I2Cx peripheral. |
<> | 144:ef7eb2e8f9f7 | 205 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 206 | */ |
Anna Bridge |
180:96ed750bd169 | 207 | HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c) |
<> | 144:ef7eb2e8f9f7 | 208 | { |
<> | 144:ef7eb2e8f9f7 | 209 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 210 | assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance)); |
<> | 156:95d6b41a828b | 211 | |
Anna Bridge |
180:96ed750bd169 | 212 | if (hi2c->State == HAL_I2C_STATE_READY) |
<> | 156:95d6b41a828b | 213 | { |
<> | 144:ef7eb2e8f9f7 | 214 | /* Process Locked */ |
<> | 144:ef7eb2e8f9f7 | 215 | __HAL_LOCK(hi2c); |
<> | 156:95d6b41a828b | 216 | |
<> | 144:ef7eb2e8f9f7 | 217 | hi2c->State = HAL_I2C_STATE_BUSY; |
<> | 156:95d6b41a828b | 218 | |
<> | 144:ef7eb2e8f9f7 | 219 | /* Disable the selected I2C peripheral */ |
<> | 156:95d6b41a828b | 220 | __HAL_I2C_DISABLE(hi2c); |
<> | 156:95d6b41a828b | 221 | |
<> | 144:ef7eb2e8f9f7 | 222 | /* Enable wakeup from stop mode */ |
<> | 156:95d6b41a828b | 223 | hi2c->Instance->CR1 |= I2C_CR1_WUPEN; |
<> | 156:95d6b41a828b | 224 | |
<> | 156:95d6b41a828b | 225 | __HAL_I2C_ENABLE(hi2c); |
<> | 156:95d6b41a828b | 226 | |
<> | 144:ef7eb2e8f9f7 | 227 | hi2c->State = HAL_I2C_STATE_READY; |
<> | 156:95d6b41a828b | 228 | |
<> | 144:ef7eb2e8f9f7 | 229 | /* Process Unlocked */ |
<> | 144:ef7eb2e8f9f7 | 230 | __HAL_UNLOCK(hi2c); |
<> | 156:95d6b41a828b | 231 | |
<> | 144:ef7eb2e8f9f7 | 232 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 233 | } |
<> | 144:ef7eb2e8f9f7 | 234 | else |
<> | 144:ef7eb2e8f9f7 | 235 | { |
<> | 144:ef7eb2e8f9f7 | 236 | return HAL_BUSY; |
<> | 144:ef7eb2e8f9f7 | 237 | } |
<> | 156:95d6b41a828b | 238 | } |
<> | 144:ef7eb2e8f9f7 | 239 | |
<> | 144:ef7eb2e8f9f7 | 240 | /** |
<> | 144:ef7eb2e8f9f7 | 241 | * @brief Disable I2C wakeup from stop mode. |
<> | 144:ef7eb2e8f9f7 | 242 | * @param hi2c Pointer to a I2C_HandleTypeDef structure that contains |
<> | 144:ef7eb2e8f9f7 | 243 | * the configuration information for the specified I2Cx peripheral. |
<> | 144:ef7eb2e8f9f7 | 244 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 245 | */ |
Anna Bridge |
180:96ed750bd169 | 246 | HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c) |
<> | 144:ef7eb2e8f9f7 | 247 | { |
<> | 144:ef7eb2e8f9f7 | 248 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 249 | assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance)); |
<> | 156:95d6b41a828b | 250 | |
Anna Bridge |
180:96ed750bd169 | 251 | if (hi2c->State == HAL_I2C_STATE_READY) |
<> | 156:95d6b41a828b | 252 | { |
<> | 144:ef7eb2e8f9f7 | 253 | /* Process Locked */ |
<> | 144:ef7eb2e8f9f7 | 254 | __HAL_LOCK(hi2c); |
<> | 156:95d6b41a828b | 255 | |
<> | 144:ef7eb2e8f9f7 | 256 | hi2c->State = HAL_I2C_STATE_BUSY; |
<> | 156:95d6b41a828b | 257 | |
<> | 144:ef7eb2e8f9f7 | 258 | /* Disable the selected I2C peripheral */ |
<> | 156:95d6b41a828b | 259 | __HAL_I2C_DISABLE(hi2c); |
<> | 156:95d6b41a828b | 260 | |
<> | 144:ef7eb2e8f9f7 | 261 | /* Enable wakeup from stop mode */ |
<> | 156:95d6b41a828b | 262 | hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN); |
<> | 156:95d6b41a828b | 263 | |
Anna Bridge |
180:96ed750bd169 | 264 | __HAL_I2C_ENABLE(hi2c); |
<> | 156:95d6b41a828b | 265 | |
<> | 144:ef7eb2e8f9f7 | 266 | hi2c->State = HAL_I2C_STATE_READY; |
<> | 156:95d6b41a828b | 267 | |
<> | 144:ef7eb2e8f9f7 | 268 | /* Process Unlocked */ |
<> | 144:ef7eb2e8f9f7 | 269 | __HAL_UNLOCK(hi2c); |
<> | 156:95d6b41a828b | 270 | |
<> | 156:95d6b41a828b | 271 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 272 | } |
<> | 144:ef7eb2e8f9f7 | 273 | else |
<> | 144:ef7eb2e8f9f7 | 274 | { |
<> | 144:ef7eb2e8f9f7 | 275 | return HAL_BUSY; |
<> | 144:ef7eb2e8f9f7 | 276 | } |
<> | 156:95d6b41a828b | 277 | } |
<> | 156:95d6b41a828b | 278 | #endif |
<> | 144:ef7eb2e8f9f7 | 279 | |
<> | 144:ef7eb2e8f9f7 | 280 | /** |
<> | 144:ef7eb2e8f9f7 | 281 | * @brief Enable the I2C fast mode plus driving capability. |
<> | 144:ef7eb2e8f9f7 | 282 | * @param ConfigFastModePlus Selects the pin. |
<> | 144:ef7eb2e8f9f7 | 283 | * This parameter can be one of the @ref I2CEx_FastModePlus values |
<> | 156:95d6b41a828b | 284 | * @note For I2C1, fast mode plus driving capability can be enabled on all selected |
<> | 156:95d6b41a828b | 285 | * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently |
<> | 156:95d6b41a828b | 286 | * on each one of the following pins PB6, PB7, PB8 and PB9. |
<> | 156:95d6b41a828b | 287 | * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability |
<> | 156:95d6b41a828b | 288 | * can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter. |
<> | 156:95d6b41a828b | 289 | * @note For all I2C2 pins fast mode plus driving capability can be enabled |
<> | 156:95d6b41a828b | 290 | * only by using I2C_FASTMODEPLUS_I2C2 parameter. |
<> | 144:ef7eb2e8f9f7 | 291 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 292 | */ |
<> | 144:ef7eb2e8f9f7 | 293 | void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus) |
<> | 144:ef7eb2e8f9f7 | 294 | { |
<> | 144:ef7eb2e8f9f7 | 295 | /* Check the parameter */ |
<> | 144:ef7eb2e8f9f7 | 296 | assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus)); |
<> | 156:95d6b41a828b | 297 | |
<> | 144:ef7eb2e8f9f7 | 298 | /* Enable SYSCFG clock */ |
<> | 144:ef7eb2e8f9f7 | 299 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
<> | 156:95d6b41a828b | 300 | |
<> | 144:ef7eb2e8f9f7 | 301 | /* Enable fast mode plus driving capability for selected pin */ |
<> | 144:ef7eb2e8f9f7 | 302 | SET_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus); |
<> | 144:ef7eb2e8f9f7 | 303 | } |
<> | 144:ef7eb2e8f9f7 | 304 | |
<> | 144:ef7eb2e8f9f7 | 305 | /** |
<> | 144:ef7eb2e8f9f7 | 306 | * @brief Disable the I2C fast mode plus driving capability. |
<> | 144:ef7eb2e8f9f7 | 307 | * @param ConfigFastModePlus Selects the pin. |
<> | 144:ef7eb2e8f9f7 | 308 | * This parameter can be one of the @ref I2CEx_FastModePlus values |
<> | 156:95d6b41a828b | 309 | * @note For I2C1, fast mode plus driving capability can be disabled on all selected |
<> | 156:95d6b41a828b | 310 | * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently |
<> | 156:95d6b41a828b | 311 | * on each one of the following pins PB6, PB7, PB8 and PB9. |
<> | 156:95d6b41a828b | 312 | * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability |
<> | 156:95d6b41a828b | 313 | * can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter. |
<> | 156:95d6b41a828b | 314 | * @note For all I2C2 pins fast mode plus driving capability can be disabled |
<> | 156:95d6b41a828b | 315 | * only by using I2C_FASTMODEPLUS_I2C2 parameter. |
<> | 144:ef7eb2e8f9f7 | 316 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 317 | */ |
<> | 144:ef7eb2e8f9f7 | 318 | void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus) |
<> | 144:ef7eb2e8f9f7 | 319 | { |
<> | 144:ef7eb2e8f9f7 | 320 | /* Check the parameter */ |
<> | 144:ef7eb2e8f9f7 | 321 | assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus)); |
<> | 156:95d6b41a828b | 322 | |
<> | 144:ef7eb2e8f9f7 | 323 | /* Enable SYSCFG clock */ |
<> | 144:ef7eb2e8f9f7 | 324 | __HAL_RCC_SYSCFG_CLK_ENABLE(); |
<> | 144:ef7eb2e8f9f7 | 325 | |
<> | 144:ef7eb2e8f9f7 | 326 | /* Disable fast mode plus driving capability for selected pin */ |
<> | 144:ef7eb2e8f9f7 | 327 | CLEAR_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus); |
<> | 144:ef7eb2e8f9f7 | 328 | } |
<> | 144:ef7eb2e8f9f7 | 329 | |
<> | 144:ef7eb2e8f9f7 | 330 | /** |
<> | 144:ef7eb2e8f9f7 | 331 | * @} |
<> | 156:95d6b41a828b | 332 | */ |
<> | 144:ef7eb2e8f9f7 | 333 | |
<> | 144:ef7eb2e8f9f7 | 334 | /** |
<> | 144:ef7eb2e8f9f7 | 335 | * @} |
<> | 144:ef7eb2e8f9f7 | 336 | */ |
<> | 144:ef7eb2e8f9f7 | 337 | |
<> | 144:ef7eb2e8f9f7 | 338 | #endif /* HAL_I2C_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 339 | /** |
<> | 144:ef7eb2e8f9f7 | 340 | * @} |
<> | 144:ef7eb2e8f9f7 | 341 | */ |
<> | 144:ef7eb2e8f9f7 | 342 | |
<> | 144:ef7eb2e8f9f7 | 343 | /** |
<> | 144:ef7eb2e8f9f7 | 344 | * @} |
<> | 144:ef7eb2e8f9f7 | 345 | */ |
<> | 144:ef7eb2e8f9f7 | 346 | |
<> | 144:ef7eb2e8f9f7 | 347 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |