comparison Common/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_fmpi2c_ex.c @ 128:c78bcbd5deda FlipDisplay

Added current STM32 standandard libraries in version independend folder structure
author Ideenmodellierer
date Sun, 17 Feb 2019 21:12:22 +0100
parents
children
comparison
equal deleted inserted replaced
127:1369f8660eaa 128:c78bcbd5deda
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_fmpi2c_ex.c
4 * @author MCD Application Team
5 * @brief FMPI2C Extended HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of FMPI2C Extended peripheral:
8 * + Extended features functions
9 *
10 @verbatim
11 ==============================================================================
12 ##### FMPI2C peripheral Extended features #####
13 ==============================================================================
14
15 [..] Comparing to other previous devices, the FMPI2C interface for STM32F4xx
16 devices contains the following additional features
17
18 (+) Possibility to disable or enable Analog Noise Filter
19 (+) Use of a configured Digital Noise Filter
20 (+) Disable or enable Fast Mode Plus
21
22 ##### How to use this driver #####
23 ==============================================================================
24 [..] This driver provides functions to configure Noise Filter and Wake Up Feature
25 (#) Configure FMPI2C Analog noise filter using the function HAL_FMPI2CEx_ConfigAnalogFilter()
26 (#) Configure FMPI2C Digital noise filter using the function HAL_FMPI2CEx_ConfigDigitalFilter()
27 (#) Configure the enable or disable of fast mode plus driving capability using the functions :
28 (++) HAL_FMPI2CEx_EnableFastModePlus()
29 (++) HAL_FMPI2CEx_DisableFastModePlus()
30 @endverbatim
31 ******************************************************************************
32 * @attention
33 *
34 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
35 *
36 * Redistribution and use in source and binary forms, with or without modification,
37 * are permitted provided that the following conditions are met:
38 * 1. Redistributions of source code must retain the above copyright notice,
39 * this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright notice,
41 * this list of conditions and the following disclaimer in the documentation
42 * and/or other materials provided with the distribution.
43 * 3. Neither the name of STMicroelectronics nor the names of its contributors
44 * may be used to endorse or promote products derived from this software
45 * without specific prior written permission.
46 *
47 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
48 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
49 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
51 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
52 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
54 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
55 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
56 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 *
58 ******************************************************************************
59 */
60
61 /* Includes ------------------------------------------------------------------*/
62 #include "stm32f4xx_hal.h"
63
64 /** @addtogroup STM32F4xx_HAL_Driver
65 * @{
66 */
67
68 /** @defgroup FMPI2CEx FMPI2CEx
69 * @brief FMPI2C Extended HAL module driver
70 * @{
71 */
72
73 #ifdef HAL_FMPI2C_MODULE_ENABLED
74
75 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
76 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
77
78 /* Private typedef -----------------------------------------------------------*/
79 /* Private define ------------------------------------------------------------*/
80 /* Private macro -------------------------------------------------------------*/
81 /* Private variables ---------------------------------------------------------*/
82 /* Private function prototypes -----------------------------------------------*/
83 /* Private functions ---------------------------------------------------------*/
84
85 /** @defgroup FMPI2CEx_Exported_Functions FMPI2C Extended Exported Functions
86 * @{
87 */
88
89 /** @defgroup FMPI2CEx_Exported_Functions_Group1 Extended features functions
90 * @brief Extended features functions
91 *
92 @verbatim
93 ===============================================================================
94 ##### Extended features functions #####
95 ===============================================================================
96 [..] This section provides functions allowing to:
97 (+) Configure Noise Filters
98 (+) Configure Fast Mode Plus
99
100 @endverbatim
101 * @{
102 */
103
104 /**
105 * @brief Configure FMPI2C Analog noise filter.
106 * @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains
107 * the configuration information for the specified FMPI2Cx peripheral.
108 * @param AnalogFilter New state of the Analog filter.
109 * @retval HAL status
110 */
111 HAL_StatusTypeDef HAL_FMPI2CEx_ConfigAnalogFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t AnalogFilter)
112 {
113 /* Check the parameters */
114 assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance));
115 assert_param(IS_FMPI2C_ANALOG_FILTER(AnalogFilter));
116
117 if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
118 {
119 /* Process Locked */
120 __HAL_LOCK(hfmpi2c);
121
122 hfmpi2c->State = HAL_FMPI2C_STATE_BUSY;
123
124 /* Disable the selected FMPI2C peripheral */
125 __HAL_FMPI2C_DISABLE(hfmpi2c);
126
127 /* Reset FMPI2Cx ANOFF bit */
128 hfmpi2c->Instance->CR1 &= ~(FMPI2C_CR1_ANFOFF);
129
130 /* Set analog filter bit*/
131 hfmpi2c->Instance->CR1 |= AnalogFilter;
132
133 __HAL_FMPI2C_ENABLE(hfmpi2c);
134
135 hfmpi2c->State = HAL_FMPI2C_STATE_READY;
136
137 /* Process Unlocked */
138 __HAL_UNLOCK(hfmpi2c);
139
140 return HAL_OK;
141 }
142 else
143 {
144 return HAL_BUSY;
145 }
146 }
147
148 /**
149 * @brief Configure FMPI2C Digital noise filter.
150 * @param hfmpi2c Pointer to a FMPI2C_HandleTypeDef structure that contains
151 * the configuration information for the specified FMPI2Cx peripheral.
152 * @param DigitalFilter Coefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F.
153 * @retval HAL status
154 */
155 HAL_StatusTypeDef HAL_FMPI2CEx_ConfigDigitalFilter(FMPI2C_HandleTypeDef *hfmpi2c, uint32_t DigitalFilter)
156 {
157 uint32_t tmpreg = 0U;
158
159 /* Check the parameters */
160 assert_param(IS_FMPI2C_ALL_INSTANCE(hfmpi2c->Instance));
161 assert_param(IS_FMPI2C_DIGITAL_FILTER(DigitalFilter));
162
163 if (hfmpi2c->State == HAL_FMPI2C_STATE_READY)
164 {
165 /* Process Locked */
166 __HAL_LOCK(hfmpi2c);
167
168 hfmpi2c->State = HAL_FMPI2C_STATE_BUSY;
169
170 /* Disable the selected FMPI2C peripheral */
171 __HAL_FMPI2C_DISABLE(hfmpi2c);
172
173 /* Get the old register value */
174 tmpreg = hfmpi2c->Instance->CR1;
175
176 /* Reset FMPI2Cx DNF bits [11:8] */
177 tmpreg &= ~(FMPI2C_CR1_DFN);
178
179 /* Set FMPI2Cx DNF coefficient */
180 tmpreg |= DigitalFilter << 8U;
181
182 /* Store the new register value */
183 hfmpi2c->Instance->CR1 = tmpreg;
184
185 __HAL_FMPI2C_ENABLE(hfmpi2c);
186
187 hfmpi2c->State = HAL_FMPI2C_STATE_READY;
188
189 /* Process Unlocked */
190 __HAL_UNLOCK(hfmpi2c);
191
192 return HAL_OK;
193 }
194 else
195 {
196 return HAL_BUSY;
197 }
198 }
199
200 /**
201 * @brief Enable the FMPI2C fast mode plus driving capability.
202 * @param ConfigFastModePlus Selects the pin.
203 * This parameter can be one of the @ref FMPI2CEx_FastModePlus values
204 * @retval None
205 */
206 void HAL_FMPI2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
207 {
208 /* Check the parameter */
209 assert_param(IS_FMPI2C_FASTMODEPLUS(ConfigFastModePlus));
210
211 /* Enable SYSCFG clock */
212 __HAL_RCC_SYSCFG_CLK_ENABLE();
213
214 /* Enable fast mode plus driving capability for selected pin */
215 SET_BIT(SYSCFG->CFGR, (uint32_t)ConfigFastModePlus);
216 }
217
218 /**
219 * @brief Disable the FMPI2C fast mode plus driving capability.
220 * @param ConfigFastModePlus Selects the pin.
221 * This parameter can be one of the @ref FMPI2CEx_FastModePlus values
222 * @retval None
223 */
224 void HAL_FMPI2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
225 {
226 /* Check the parameter */
227 assert_param(IS_FMPI2C_FASTMODEPLUS(ConfigFastModePlus));
228
229 /* Enable SYSCFG clock */
230 __HAL_RCC_SYSCFG_CLK_ENABLE();
231
232 /* Disable fast mode plus driving capability for selected pin */
233 CLEAR_BIT(SYSCFG->CFGR, (uint32_t)ConfigFastModePlus);
234 }
235
236 /**
237 * @}
238 */
239
240 /**
241 * @}
242 */
243 #endif /* STM32F410xx || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||\
244 STM32F413xx || STM32F423xx */
245 #endif /* HAL_FMPI2C_MODULE_ENABLED */
246 /**
247 * @}
248 */
249
250 /**
251 * @}
252 */
253
254 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/