stm32h747/stm32h747i-disco/CM7/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c
Go to the documentation of this file.
1 
49 /* Includes ------------------------------------------------------------------*/
50 #include "stm32h7xx_hal.h"
51 
61 #ifdef HAL_I2C_MODULE_ENABLED
62 
63 /* Private typedef -----------------------------------------------------------*/
64 /* Private define ------------------------------------------------------------*/
65 /* Private macro -------------------------------------------------------------*/
66 /* Private variables ---------------------------------------------------------*/
67 /* Private function prototypes -----------------------------------------------*/
68 /* Private functions ---------------------------------------------------------*/
69 
98 {
99  /* Check the parameters */
101  assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
102 
103  if (hi2c->State == HAL_I2C_STATE_READY)
104  {
105  /* Process Locked */
106  __HAL_LOCK(hi2c);
107 
108  hi2c->State = HAL_I2C_STATE_BUSY;
109 
110  /* Disable the selected I2C peripheral */
111  __HAL_I2C_DISABLE(hi2c);
112 
113  /* Reset I2Cx ANOFF bit */
114  hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
115 
116  /* Set analog filter bit*/
117  hi2c->Instance->CR1 |= AnalogFilter;
118 
119  __HAL_I2C_ENABLE(hi2c);
120 
121  hi2c->State = HAL_I2C_STATE_READY;
122 
123  /* Process Unlocked */
124  __HAL_UNLOCK(hi2c);
125 
126  return HAL_OK;
127  }
128  else
129  {
130  return HAL_BUSY;
131  }
132 }
133 
142 {
143  uint32_t tmpreg;
144 
145  /* Check the parameters */
147  assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
148 
149  if (hi2c->State == HAL_I2C_STATE_READY)
150  {
151  /* Process Locked */
152  __HAL_LOCK(hi2c);
153 
154  hi2c->State = HAL_I2C_STATE_BUSY;
155 
156  /* Disable the selected I2C peripheral */
157  __HAL_I2C_DISABLE(hi2c);
158 
159  /* Get the old register value */
160  tmpreg = hi2c->Instance->CR1;
161 
162  /* Reset I2Cx DNF bits [11:8] */
163  tmpreg &= ~(I2C_CR1_DNF);
164 
165  /* Set I2Cx DNF coefficient */
166  tmpreg |= DigitalFilter << 8U;
167 
168  /* Store the new register value */
169  hi2c->Instance->CR1 = tmpreg;
170 
171  __HAL_I2C_ENABLE(hi2c);
172 
173  hi2c->State = HAL_I2C_STATE_READY;
174 
175  /* Process Unlocked */
176  __HAL_UNLOCK(hi2c);
177 
178  return HAL_OK;
179  }
180  else
181  {
182  return HAL_BUSY;
183  }
184 }
185 
193 {
194  /* Check the parameters */
196 
197  if (hi2c->State == HAL_I2C_STATE_READY)
198  {
199  /* Process Locked */
200  __HAL_LOCK(hi2c);
201 
202  hi2c->State = HAL_I2C_STATE_BUSY;
203 
204  /* Disable the selected I2C peripheral */
205  __HAL_I2C_DISABLE(hi2c);
206 
207  /* Enable wakeup from stop mode */
208  hi2c->Instance->CR1 |= I2C_CR1_WUPEN;
209 
210  __HAL_I2C_ENABLE(hi2c);
211 
212  hi2c->State = HAL_I2C_STATE_READY;
213 
214  /* Process Unlocked */
215  __HAL_UNLOCK(hi2c);
216 
217  return HAL_OK;
218  }
219  else
220  {
221  return HAL_BUSY;
222  }
223 }
224 
232 {
233  /* Check the parameters */
235 
236  if (hi2c->State == HAL_I2C_STATE_READY)
237  {
238  /* Process Locked */
239  __HAL_LOCK(hi2c);
240 
241  hi2c->State = HAL_I2C_STATE_BUSY;
242 
243  /* Disable the selected I2C peripheral */
244  __HAL_I2C_DISABLE(hi2c);
245 
246  /* Enable wakeup from stop mode */
247  hi2c->Instance->CR1 &= ~(I2C_CR1_WUPEN);
248 
249  __HAL_I2C_ENABLE(hi2c);
250 
251  hi2c->State = HAL_I2C_STATE_READY;
252 
253  /* Process Unlocked */
254  __HAL_UNLOCK(hi2c);
255 
256  return HAL_OK;
257  }
258  else
259  {
260  return HAL_BUSY;
261  }
262 }
263 
283 void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
284 {
285  /* Check the parameter */
286  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
287 
288  /* Enable SYSCFG clock */
290 
291  /* Enable fast mode plus driving capability for selected pin */
292  SET_BIT(SYSCFG->PMCR, (uint32_t)ConfigFastModePlus);
293 }
294 
314 void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
315 {
316  /* Check the parameter */
317  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
318 
319  /* Enable SYSCFG clock */
321 
322  /* Disable fast mode plus driving capability for selected pin */
323  CLEAR_BIT(SYSCFG->PMCR, (uint32_t)ConfigFastModePlus);
324 }
325 
334 #endif /* HAL_I2C_MODULE_ENABLED */
335 
343 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
IS_I2C_WAKEUP_FROMSTOP_INSTANCE
#define IS_I2C_WAKEUP_FROMSTOP_INSTANCE(INSTANCE)
Definition: stm32h735xx.h:24018
IS_I2C_ALL_INSTANCE
#define IS_I2C_ALL_INSTANCE(INSTANCE)
Definition: stm32f407xx.h:15129
HAL_I2CEx_DisableWakeUp
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp(I2C_HandleTypeDef *hi2c)
IS_I2C_ANALOG_FILTER
#define IS_I2C_ANALOG_FILTER(FILTER)
Definition: stm32f7xx_hal_i2c_ex.h:134
CLEAR_BIT
#define CLEAR_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:214
HAL_I2CEx_ConfigDigitalFilter
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
HAL_I2CEx_EnableWakeUp
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp(I2C_HandleTypeDef *hi2c)
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
HAL_I2C_STATE_BUSY
@ HAL_I2C_STATE_BUSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:111
HAL_I2CEx_EnableFastModePlus
void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
I2C_CR1_DNF
#define I2C_CR1_DNF
Definition: stm32f769xx.h:9857
HAL_I2C_STATE_READY
@ HAL_I2C_STATE_READY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:110
__HAL_LOCK
#define __HAL_LOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:93
__HAL_RCC_SYSCFG_CLK_ENABLE
#define __HAL_RCC_SYSCFG_CLK_ENABLE()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:599
I2C_CR1_ANFOFF
#define I2C_CR1_ANFOFF
Definition: stm32f769xx.h:9860
HAL_BUSY
@ HAL_BUSY
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:44
SYSCFG
#define SYSCFG
Definition: stm32f407xx.h:1098
__HAL_UNLOCK
#define __HAL_UNLOCK(__HANDLE__)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:105
__HAL_I2C_DISABLE
#define __HAL_I2C_DISABLE(__HANDLE__)
Disable the specified I2C peripheral.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:527
I2C_HandleTypeDef
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:188
I2C_CR1_WUPEN
#define I2C_CR1_WUPEN
Definition: stm32h735xx.h:13307
IS_I2C_DIGITAL_FILTER
#define IS_I2C_DIGITAL_FILTER(FILTER)
Definition: stm32f7xx_hal_i2c_ex.h:137
HAL_I2CEx_ConfigAnalogFilter
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
__HAL_I2C_ENABLE
#define __HAL_I2C_ENABLE(__HANDLE__)
Enable the specified I2C peripheral.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:521
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
I2C_HandleTypeDef::Instance
I2C_TypeDef * Instance
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:191
I2C_HandleTypeDef::State
__IO HAL_I2C_StateTypeDef State
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h:212
HAL_I2CEx_DisableFastModePlus
void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
I2C_TypeDef::CR1
__IO uint32_t CR1
Definition: stm32f407xx.h:559


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:54