L4 HAL Drivers

Committer:
EricLew
Date:
Mon Nov 02 19:37:23 2015 +0000
Revision:
0:80ee8f3b695e
Errors are with definitions of LCD and QSPI functions. I believe all .h and .c files are  uploaded, but there may need to be certain functions called.

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 0:80ee8f3b695e 73 /** @defgroup I2CEx I2CEx
EricLew 0:80ee8f3b695e 74 * @brief I2C Extended HAL module driver
EricLew 0:80ee8f3b695e 75 * @{
EricLew 0:80ee8f3b695e 76 */
EricLew 0:80ee8f3b695e 77
EricLew 0:80ee8f3b695e 78 #ifdef HAL_I2C_MODULE_ENABLED
EricLew 0:80ee8f3b695e 79
EricLew 0:80ee8f3b695e 80 /* Private typedef -----------------------------------------------------------*/
EricLew 0:80ee8f3b695e 81 /* Private define ------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 82 /* Private macro -------------------------------------------------------------*/
EricLew 0:80ee8f3b695e 83 /* Private variables ---------------------------------------------------------*/
EricLew 0:80ee8f3b695e 84 /* Private function prototypes -----------------------------------------------*/
EricLew 0:80ee8f3b695e 85 /* Private functions ---------------------------------------------------------*/
EricLew 0:80ee8f3b695e 86
EricLew 0:80ee8f3b695e 87 /** @defgroup I2CEx_Exported_Functions I2C Extended Exported Functions
EricLew 0:80ee8f3b695e 88 * @{
EricLew 0:80ee8f3b695e 89 */
EricLew 0:80ee8f3b695e 90
EricLew 0:80ee8f3b695e 91 /** @defgroup I2CEx_Exported_Functions_Group1 Extended features functions
EricLew 0:80ee8f3b695e 92 * @brief Extended features functions
EricLew 0:80ee8f3b695e 93 *
EricLew 0:80ee8f3b695e 94 @verbatim
EricLew 0:80ee8f3b695e 95 ===============================================================================
EricLew 0:80ee8f3b695e 96 ##### Extended features functions #####
EricLew 0:80ee8f3b695e 97 ===============================================================================
EricLew 0:80ee8f3b695e 98 [..] This section provides functions allowing to:
EricLew 0:80ee8f3b695e 99 (+) Configure Noise Filters
EricLew 0:80ee8f3b695e 100
EricLew 0:80ee8f3b695e 101 @endverbatim
EricLew 0:80ee8f3b695e 102 * @{
EricLew 0:80ee8f3b695e 103 */
EricLew 0:80ee8f3b695e 104
EricLew 0:80ee8f3b695e 105 /**
EricLew 0:80ee8f3b695e 106 * @brief Configures I2C Analog noise filter.
EricLew 0:80ee8f3b695e 107 * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains
EricLew 0:80ee8f3b695e 108 * the configuration information for the specified I2Cx peripheral.
EricLew 0:80ee8f3b695e 109 * @param AnalogFilter : new state of the Analog filter.
EricLew 0:80ee8f3b695e 110 * @retval HAL status
EricLew 0:80ee8f3b695e 111 */
EricLew 0:80ee8f3b695e 112 HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
EricLew 0:80ee8f3b695e 113 {
EricLew 0:80ee8f3b695e 114 /* Check the parameters */
EricLew 0:80ee8f3b695e 115 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
EricLew 0:80ee8f3b695e 116 assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
EricLew 0:80ee8f3b695e 117
EricLew 0:80ee8f3b695e 118 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 119 || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
EricLew 0:80ee8f3b695e 120 {
EricLew 0:80ee8f3b695e 121 return HAL_BUSY;
EricLew 0:80ee8f3b695e 122 }
EricLew 0:80ee8f3b695e 123
EricLew 0:80ee8f3b695e 124 /* Process Locked */
EricLew 0:80ee8f3b695e 125 __HAL_LOCK(hi2c);
EricLew 0:80ee8f3b695e 126
EricLew 0:80ee8f3b695e 127 hi2c->State = HAL_I2C_STATE_BUSY;
EricLew 0:80ee8f3b695e 128
EricLew 0:80ee8f3b695e 129 /* Disable the selected I2C peripheral */
EricLew 0:80ee8f3b695e 130 __HAL_I2C_DISABLE(hi2c);
EricLew 0:80ee8f3b695e 131
EricLew 0:80ee8f3b695e 132 /* Reset I2Cx ANOFF bit */
EricLew 0:80ee8f3b695e 133 hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
EricLew 0:80ee8f3b695e 134
EricLew 0:80ee8f3b695e 135 /* Set analog filter bit*/
EricLew 0:80ee8f3b695e 136 hi2c->Instance->CR1 |= AnalogFilter;
EricLew 0:80ee8f3b695e 137
EricLew 0:80ee8f3b695e 138 __HAL_I2C_ENABLE(hi2c);
EricLew 0:80ee8f3b695e 139
EricLew 0:80ee8f3b695e 140 hi2c->State = HAL_I2C_STATE_READY;
EricLew 0:80ee8f3b695e 141
EricLew 0:80ee8f3b695e 142 /* Process Unlocked */
EricLew 0:80ee8f3b695e 143 __HAL_UNLOCK(hi2c);
EricLew 0:80ee8f3b695e 144
EricLew 0:80ee8f3b695e 145 return HAL_OK;
EricLew 0:80ee8f3b695e 146 }
EricLew 0:80ee8f3b695e 147
EricLew 0:80ee8f3b695e 148 /**
EricLew 0:80ee8f3b695e 149 * @brief Configures I2C Digital noise filter.
EricLew 0:80ee8f3b695e 150 * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains
EricLew 0:80ee8f3b695e 151 * the configuration information for the specified I2Cx peripheral.
EricLew 0:80ee8f3b695e 152 * @param DigitalFilter : Coefficient of digital noise filter between 0x00 and 0x0F.
EricLew 0:80ee8f3b695e 153 * @retval HAL status
EricLew 0:80ee8f3b695e 154 */
EricLew 0:80ee8f3b695e 155 HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
EricLew 0:80ee8f3b695e 156 {
EricLew 0:80ee8f3b695e 157 uint32_t tmpreg = 0;
EricLew 0:80ee8f3b695e 158
EricLew 0:80ee8f3b695e 159 /* Check the parameters */
EricLew 0:80ee8f3b695e 160 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
EricLew 0:80ee8f3b695e 161 assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
EricLew 0:80ee8f3b695e 162
EricLew 0:80ee8f3b695e 163 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 164 || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
EricLew 0:80ee8f3b695e 165 {
EricLew 0:80ee8f3b695e 166 return HAL_BUSY;
EricLew 0:80ee8f3b695e 167 }
EricLew 0:80ee8f3b695e 168
EricLew 0:80ee8f3b695e 169 /* Process Locked */
EricLew 0:80ee8f3b695e 170 __HAL_LOCK(hi2c);
EricLew 0:80ee8f3b695e 171
EricLew 0:80ee8f3b695e 172 hi2c->State = HAL_I2C_STATE_BUSY;
EricLew 0:80ee8f3b695e 173
EricLew 0:80ee8f3b695e 174 /* Disable the selected I2C peripheral */
EricLew 0:80ee8f3b695e 175 __HAL_I2C_DISABLE(hi2c);
EricLew 0:80ee8f3b695e 176
EricLew 0:80ee8f3b695e 177 /* Get the old register value */
EricLew 0:80ee8f3b695e 178 tmpreg = hi2c->Instance->CR1;
EricLew 0:80ee8f3b695e 179
EricLew 0:80ee8f3b695e 180 /* Reset I2Cx DNF bits [11:8] */
EricLew 0:80ee8f3b695e 181 tmpreg &= ~(I2C_CR1_DNF);
EricLew 0:80ee8f3b695e 182
EricLew 0:80ee8f3b695e 183 /* Set I2Cx DNF coefficient */
EricLew 0:80ee8f3b695e 184 tmpreg |= DigitalFilter << 8;
EricLew 0:80ee8f3b695e 185
EricLew 0:80ee8f3b695e 186 /* Store the new register value */
EricLew 0:80ee8f3b695e 187 hi2c->Instance->CR1 = tmpreg;
EricLew 0:80ee8f3b695e 188
EricLew 0:80ee8f3b695e 189 __HAL_I2C_ENABLE(hi2c);
EricLew 0:80ee8f3b695e 190
EricLew 0:80ee8f3b695e 191 hi2c->State = HAL_I2C_STATE_READY;
EricLew 0:80ee8f3b695e 192
EricLew 0:80ee8f3b695e 193 /* Process Unlocked */
EricLew 0:80ee8f3b695e 194 __HAL_UNLOCK(hi2c);
EricLew 0:80ee8f3b695e 195
EricLew 0:80ee8f3b695e 196 return HAL_OK;
EricLew 0:80ee8f3b695e 197 }
EricLew 0:80ee8f3b695e 198
EricLew 0:80ee8f3b695e 199 /**
EricLew 0:80ee8f3b695e 200 * @brief Enables I2C wakeup from stop mode.
EricLew 0:80ee8f3b695e 201 * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains
EricLew 0:80ee8f3b695e 202 * the configuration information for the specified I2Cx peripheral.
EricLew 0:80ee8f3b695e 203 * @retval HAL status
EricLew 0:80ee8f3b695e 204 */
EricLew 0:80ee8f3b695e 205 HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp (I2C_HandleTypeDef *hi2c)
EricLew 0:80ee8f3b695e 206 {
EricLew 0:80ee8f3b695e 207 /* Check the parameters */
EricLew 0:80ee8f3b695e 208 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
EricLew 0:80ee8f3b695e 209
EricLew 0:80ee8f3b695e 210 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 211 || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
EricLew 0:80ee8f3b695e 212 {
EricLew 0:80ee8f3b695e 213 return HAL_BUSY;
EricLew 0:80ee8f3b695e 214 }
EricLew 0:80ee8f3b695e 215
EricLew 0:80ee8f3b695e 216 /* Process Locked */
EricLew 0:80ee8f3b695e 217 __HAL_LOCK(hi2c);
EricLew 0:80ee8f3b695e 218
EricLew 0:80ee8f3b695e 219 hi2c->State = HAL_I2C_STATE_BUSY;
EricLew 0:80ee8f3b695e 220
EricLew 0:80ee8f3b695e 221 /* Disable the selected I2C peripheral */
EricLew 0:80ee8f3b695e 222 __HAL_I2C_DISABLE(hi2c);
EricLew 0:80ee8f3b695e 223
EricLew 0:80ee8f3b695e 224 /* Enable wakeup from stop mode */
EricLew 0:80ee8f3b695e 225 hi2c->Instance->CR1 |= I2C_CR1_WUPEN;
EricLew 0:80ee8f3b695e 226
EricLew 0:80ee8f3b695e 227 __HAL_I2C_ENABLE(hi2c);
EricLew 0:80ee8f3b695e 228
EricLew 0:80ee8f3b695e 229 hi2c->State = HAL_I2C_STATE_READY;
EricLew 0:80ee8f3b695e 230
EricLew 0:80ee8f3b695e 231 /* Process Unlocked */
EricLew 0:80ee8f3b695e 232 __HAL_UNLOCK(hi2c);
EricLew 0:80ee8f3b695e 233
EricLew 0:80ee8f3b695e 234 return HAL_OK;
EricLew 0:80ee8f3b695e 235 }
EricLew 0:80ee8f3b695e 236
EricLew 0:80ee8f3b695e 237
EricLew 0:80ee8f3b695e 238 /**
EricLew 0:80ee8f3b695e 239 * @brief Disables I2C wakeup from stop mode.
EricLew 0:80ee8f3b695e 240 * @param hi2c : pointer to a I2C_HandleTypeDef structure that contains
EricLew 0:80ee8f3b695e 241 * the configuration information for the specified I2Cx peripheral.
EricLew 0:80ee8f3b695e 242 * @retval HAL status
EricLew 0:80ee8f3b695e 243 */
EricLew 0:80ee8f3b695e 244 HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (I2C_HandleTypeDef *hi2c)
EricLew 0:80ee8f3b695e 245 {
EricLew 0:80ee8f3b695e 246 /* Check the parameters */
EricLew 0:80ee8f3b695e 247 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
EricLew 0:80ee8f3b695e 248
EricLew 0:80ee8f3b695e 249 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 250 || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_TX) || (hi2c->State == HAL_I2C_STATE_SLAVE_BUSY_RX))
EricLew 0:80ee8f3b695e 251 {
EricLew 0:80ee8f3b695e 252 return HAL_BUSY;
EricLew 0:80ee8f3b695e 253 }
EricLew 0:80ee8f3b695e 254
EricLew 0:80ee8f3b695e 255 /* Process Locked */
EricLew 0:80ee8f3b695e 256 __HAL_LOCK(hi2c);
EricLew 0:80ee8f3b695e 257
EricLew 0:80ee8f3b695e 258 hi2c->State = HAL_I2C_STATE_BUSY;
EricLew 0:80ee8f3b695e 259
EricLew 0:80ee8f3b695e 260 /* Disable the selected I2C peripheral */
EricLew 0:80ee8f3b695e 261 __HAL_I2C_DISABLE(hi2c);
EricLew 0:80ee8f3b695e 262
EricLew 0:80ee8f3b695e 263 /* Enable wakeup from stop mode */
EricLew 0:80ee8f3b695e 264 hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN);
EricLew 0:80ee8f3b695e 265
EricLew 0:80ee8f3b695e 266 __HAL_I2C_ENABLE(hi2c);
EricLew 0:80ee8f3b695e 267
EricLew 0:80ee8f3b695e 268 hi2c->State = HAL_I2C_STATE_READY;
EricLew 0:80ee8f3b695e 269
EricLew 0:80ee8f3b695e 270 /* Process Unlocked */
EricLew 0:80ee8f3b695e 271 __HAL_UNLOCK(hi2c);
EricLew 0:80ee8f3b695e 272
EricLew 0:80ee8f3b695e 273 return HAL_OK;
EricLew 0:80ee8f3b695e 274 }
EricLew 0:80ee8f3b695e 275
EricLew 0:80ee8f3b695e 276 /**
EricLew 0:80ee8f3b695e 277 * @brief Enable the I2C fast mode plus driving capability.
EricLew 0:80ee8f3b695e 278 * @param ConfigFastModePlus: selects the pin.
EricLew 0:80ee8f3b695e 279 * This parameter can be one of the @ref I2CEx_FastModePlus values
EricLew 0:80ee8f3b695e 280 * @note For I2C1, fast mode plus driving capability can be enabled on all selected
EricLew 0:80ee8f3b695e 281 * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
EricLew 0:80ee8f3b695e 282 * on each one of the following pins PB6, PB7, PB8 and PB9.
EricLew 0:80ee8f3b695e 283 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
EricLew 0:80ee8f3b695e 284 * can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
EricLew 0:80ee8f3b695e 285 * @note For all I2C2 pins fast mode plus driving capability can be enabled
EricLew 0:80ee8f3b695e 286 * only by using I2C_FASTMODEPLUS_I2C2 parameter.
EricLew 0:80ee8f3b695e 287 * @note For all I2C3 pins fast mode plus driving capability can be enabled
EricLew 0:80ee8f3b695e 288 * only by using I2C_FASTMODEPLUS_I2C3 parameter.
EricLew 0:80ee8f3b695e 289 * @retval None
EricLew 0:80ee8f3b695e 290 */
EricLew 0:80ee8f3b695e 291 void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
EricLew 0:80ee8f3b695e 292 {
EricLew 0:80ee8f3b695e 293 /* Check the parameter */
EricLew 0:80ee8f3b695e 294 assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
EricLew 0:80ee8f3b695e 295
EricLew 0:80ee8f3b695e 296 /* Enable SYSCFG clock */
EricLew 0:80ee8f3b695e 297 __HAL_RCC_SYSCFG_CLK_ENABLE();
EricLew 0:80ee8f3b695e 298
EricLew 0:80ee8f3b695e 299 /* Enable fast mode plus driving capability for selected pin */
EricLew 0:80ee8f3b695e 300 SET_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
EricLew 0:80ee8f3b695e 301 }
EricLew 0:80ee8f3b695e 302
EricLew 0:80ee8f3b695e 303 /**
EricLew 0:80ee8f3b695e 304 * @brief Disable the I2C fast mode plus driving capability.
EricLew 0:80ee8f3b695e 305 * @param ConfigFastModePlus: selects the pin.
EricLew 0:80ee8f3b695e 306 * This parameter can be one of the @ref I2CEx_FastModePlus values
EricLew 0:80ee8f3b695e 307 * @note For I2C1, fast mode plus driving capability can be disabled on all selected
EricLew 0:80ee8f3b695e 308 * I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently
EricLew 0:80ee8f3b695e 309 * on each one of the following pins PB6, PB7, PB8 and PB9.
EricLew 0:80ee8f3b695e 310 * @note For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability
EricLew 0:80ee8f3b695e 311 * can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
EricLew 0:80ee8f3b695e 312 * @note For all I2C2 pins fast mode plus driving capability can be disabled
EricLew 0:80ee8f3b695e 313 * only by using I2C_FASTMODEPLUS_I2C2 parameter.
EricLew 0:80ee8f3b695e 314 * @note For all I2C3 pins fast mode plus driving capability can be disabled
EricLew 0:80ee8f3b695e 315 * only by using I2C_FASTMODEPLUS_I2C3 parameter.
EricLew 0:80ee8f3b695e 316 * @retval None
EricLew 0:80ee8f3b695e 317 */
EricLew 0:80ee8f3b695e 318 void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
EricLew 0:80ee8f3b695e 319 {
EricLew 0:80ee8f3b695e 320 /* Check the parameter */
EricLew 0:80ee8f3b695e 321 assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
EricLew 0:80ee8f3b695e 322
EricLew 0:80ee8f3b695e 323 /* Enable SYSCFG clock */
EricLew 0:80ee8f3b695e 324 __HAL_RCC_SYSCFG_CLK_ENABLE();
EricLew 0:80ee8f3b695e 325
EricLew 0:80ee8f3b695e 326 /* Disable fast mode plus driving capability for selected pin */
EricLew 0:80ee8f3b695e 327 CLEAR_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
EricLew 0:80ee8f3b695e 328 }
EricLew 0:80ee8f3b695e 329
EricLew 0:80ee8f3b695e 330 /**
EricLew 0:80ee8f3b695e 331 * @}
EricLew 0:80ee8f3b695e 332 */
EricLew 0:80ee8f3b695e 333
EricLew 0:80ee8f3b695e 334 /**
EricLew 0:80ee8f3b695e 335 * @}
EricLew 0:80ee8f3b695e 336 */
EricLew 0:80ee8f3b695e 337
EricLew 0:80ee8f3b695e 338 #endif /* HAL_I2C_MODULE_ENABLED */
EricLew 0:80ee8f3b695e 339 /**
EricLew 0:80ee8f3b695e 340 * @}
EricLew 0:80ee8f3b695e 341 */
EricLew 0:80ee8f3b695e 342
EricLew 0:80ee8f3b695e 343 /**
EricLew 0:80ee8f3b695e 344 * @}
EricLew 0:80ee8f3b695e 345 */
EricLew 0:80ee8f3b695e 346
EricLew 0:80ee8f3b695e 347 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
EricLew 0:80ee8f3b695e 348