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