Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Thu Nov 12 20:49:49 2015 +0000
Revision:
1:271ce2251692
Parent:
0:80ee8f3b695e
commit

Who changed what in which revision?

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