STM32F439xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_fmpi2c_ex.c 00004 * @author MCD Application Team 00005 * @brief FMPI2C Extended HAL module driver. 00006 * This file provides firmware functions to manage the following 00007 * functionalities of FMPI2C Extended peripheral: 00008 * + Extended features functions 00009 * 00010 @verbatim 00011 ============================================================================== 00012 ##### FMPI2C peripheral Extended features ##### 00013 ============================================================================== 00014 00015 [..] Comparing to other previous devices, the FMPI2C interface for STM32F4xx 00016 devices contains the following additional features 00017 00018 (+) Possibility to disable or enable Analog Noise Filter 00019 (+) Use of a configured Digital Noise Filter 00020 (+) Disable or enable Fast Mode Plus 00021 00022 ##### How to use this driver ##### 00023 ============================================================================== 00024 [..] This driver provides functions to configure Noise Filter and Wake Up Feature 00025 (#) Configure FMPI2C Analog noise filter using the function HAL_FMPI2CEx_ConfigAnalogFilter() 00026 (#) Configure FMPI2C Digital noise filter using the function HAL_FMPI2CEx_ConfigDigitalFilter() 00027 (#) Configure the enable or disable of fast mode plus driving capability using the functions : 00028 (++) HAL_FMPI2CEx_EnableFastModePlus() 00029 (++) HAL_FMPI2CEx_DisableFastModePlus() 00030 @endverbatim 00031 ****************************************************************************** 00032 * @attention 00033 * 00034 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00035 * 00036 * Redistribution and use in source and binary forms, with or without modification, 00037 * are permitted provided that the following conditions are met: 00038 * 1. Redistributions of source code must retain the above copyright notice, 00039 * this list of conditions and the following disclaimer. 00040 * 2. Redistributions in binary form must reproduce the above copyright notice, 00041 * this list of conditions and the following disclaimer in the documentation 00042 * and/or other materials provided with the distribution. 00043 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00044 * may be used to endorse or promote products derived from this software 00045 * without specific prior written permission. 00046 * 00047 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00048 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00049 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00050 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00051 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00052 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00053 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00054 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00055 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00056 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00057 * 00058 ****************************************************************************** 00059 */ 00060 00061 /* Includes ------------------------------------------------------------------*/ 00062 #include "stm32f4xx_hal.h" 00063 00064 /** @addtogroup STM32F4xx_HAL_Driver 00065 * @{ 00066 */ 00067 00068 /** @defgroup FMPI2CEx FMPI2CEx 00069 * @brief FMPI2C Extended HAL module driver 00070 * @{ 00071 */ 00072 00073 #ifdef HAL_FMPI2C_MODULE_ENABLED 00074 00075 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 00076 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 00077 00078 /* Private typedef -----------------------------------------------------------*/ 00079 /* Private define ------------------------------------------------------------*/ 00080 /* Private macro -------------------------------------------------------------*/ 00081 /* Private variables ---------------------------------------------------------*/ 00082 /* Private function prototypes -----------------------------------------------*/ 00083 /* Private functions ---------------------------------------------------------*/ 00084 00085 /** @defgroup FMPI2CEx_Exported_Functions FMPI2C Extended Exported Functions 00086 * @{ 00087 */ 00088 00089 /** @defgroup FMPI2CEx_Exported_Functions_Group1 Extended features functions 00090 * @brief Extended features functions 00091 * 00092 @verbatim 00093 =============================================================================== 00094 ##### Extended features functions ##### 00095 =============================================================================== 00096 [..] This section provides functions allowing to: 00097 (+) Configure Noise Filters 00098 (+) Configure Fast Mode Plus 00099 00100 @endverbatim 00101 * @{ 00102 */ 00103 00104 /** 00105 * @brief Configure FMPI2C Analog noise filter. 00106 * @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains 00107 * the configuration information for the specified FMPI2Cx peripheral. 00108 * @param AnalogFilter New state of the Analog filter. 00109 * @retval HAL status 00110 */ 00111 HAL_StatusTypeDef HAL_FMPI2CEx_ConfigAnalogFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t AnalogFilter) 00112 { 00113 /* Check the parameters */ 00114 assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance)); 00115 assert_param(IS_FMPI2C_ANALOG_FILTER(AnalogFilter)); 00116 00117 if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) 00118 { 00119 /* Process Locked */ 00120 __HAL_LOCK(hfmpi2c); 00121 00122 hfmpi2c->State = HAL_FMPI2C_STATE_BUSY; 00123 00124 /* Disable the selected FMPI2C peripheral */ 00125 __HAL_FMPI2C_DISABLE(hfmpi2c); 00126 00127 /* Reset FMPI2Cx ANOFF bit */ 00128 hfmpi2c->Instance->CR1 &= ~(FMPI2C_CR1_ANFOFF); 00129 00130 /* Set analog filter bit*/ 00131 hfmpi2c->Instance->CR1 |= AnalogFilter; 00132 00133 __HAL_FMPI2C_ENABLE(hfmpi2c); 00134 00135 hfmpi2c->State = HAL_FMPI2C_STATE_READY; 00136 00137 /* Process Unlocked */ 00138 __HAL_UNLOCK(hfmpi2c); 00139 00140 return HAL_OK; 00141 } 00142 else 00143 { 00144 return HAL_BUSY; 00145 } 00146 } 00147 00148 /** 00149 * @brief Configure FMPI2C Digital noise filter. 00150 * @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains 00151 * the configuration information for the specified FMPI2Cx peripheral. 00152 * @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F. 00153 * @retval HAL status 00154 */ 00155 HAL_StatusTypeDef HAL_FMPI2CEx_ConfigDigitalFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t DigitalFilter) 00156 { 00157 uint32_t tmpreg = 0U; 00158 00159 /* Check the parameters */ 00160 assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance)); 00161 assert_param(IS_FMPI2C_DIGITAL_FILTER(DigitalFilter)); 00162 00163 if (hfmpi2c->State == HAL_FMPI2C_STATE_READY) 00164 { 00165 /* Process Locked */ 00166 __HAL_LOCK(hfmpi2c); 00167 00168 hfmpi2c->State = HAL_FMPI2C_STATE_BUSY; 00169 00170 /* Disable the selected FMPI2C peripheral */ 00171 __HAL_FMPI2C_DISABLE(hfmpi2c); 00172 00173 /* Get the old register value */ 00174 tmpreg = hfmpi2c->Instance->CR1; 00175 00176 /* Reset FMPI2Cx DNF bits [11:8] */ 00177 tmpreg &= ~(FMPI2C_CR1_DFN); 00178 00179 /* Set FMPI2Cx DNF coefficient */ 00180 tmpreg |= DigitalFilter << 8U; 00181 00182 /* Store the new register value */ 00183 hfmpi2c->Instance->CR1 = tmpreg; 00184 00185 __HAL_FMPI2C_ENABLE(hfmpi2c); 00186 00187 hfmpi2c->State = HAL_FMPI2C_STATE_READY; 00188 00189 /* Process Unlocked */ 00190 __HAL_UNLOCK(hfmpi2c); 00191 00192 return HAL_OK; 00193 } 00194 else 00195 { 00196 return HAL_BUSY; 00197 } 00198 } 00199 00200 /** 00201 * @brief Enable the FMPI2C fast mode plus driving capability. 00202 * @param ConfigFastModePlus Selects the pin. 00203 * This parameter can be one of the @ref FMPI2CEx_FastModePlus values 00204 * @retval None 00205 */ 00206 void HAL_FMPI2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus) 00207 { 00208 /* Check the parameter */ 00209 assert_param(IS_FMPI2C_FASTMODEPLUS(ConfigFastModePlus)); 00210 00211 /* Enable SYSCFG clock */ 00212 __HAL_RCC_SYSCFG_CLK_ENABLE(); 00213 00214 /* Enable fast mode plus driving capability for selected pin */ 00215 SET_BIT(SYSCFG->CFGR, (uint32_t)ConfigFastModePlus); 00216 } 00217 00218 /** 00219 * @brief Disable the FMPI2C fast mode plus driving capability. 00220 * @param ConfigFastModePlus Selects the pin. 00221 * This parameter can be one of the @ref FMPI2CEx_FastModePlus values 00222 * @retval None 00223 */ 00224 void HAL_FMPI2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus) 00225 { 00226 /* Check the parameter */ 00227 assert_param(IS_FMPI2C_FASTMODEPLUS(ConfigFastModePlus)); 00228 00229 /* Enable SYSCFG clock */ 00230 __HAL_RCC_SYSCFG_CLK_ENABLE(); 00231 00232 /* Disable fast mode plus driving capability for selected pin */ 00233 CLEAR_BIT(SYSCFG->CFGR, (uint32_t)ConfigFastModePlus); 00234 } 00235 00236 /** 00237 * @} 00238 */ 00239 00240 /** 00241 * @} 00242 */ 00243 #endif /* STM32F410xx || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||\ 00244 STM32F413xx || STM32F423xx */ 00245 #endif /* HAL_FMPI2C_MODULE_ENABLED */ 00246 /** 00247 * @} 00248 */ 00249 00250 /** 00251 * @} 00252 */ 00253 00254 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/