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