stm32f7xx_hal_i2c_ex.c
Go to the documentation of this file.
1 
45 /* Includes ------------------------------------------------------------------*/
46 #include "stm32f7xx_hal.h"
47 
57 #ifdef HAL_I2C_MODULE_ENABLED
58 
59 /* Private typedef -----------------------------------------------------------*/
60 /* Private define ------------------------------------------------------------*/
61 /* Private macro -------------------------------------------------------------*/
62 /* Private variables ---------------------------------------------------------*/
63 /* Private function prototypes -----------------------------------------------*/
64 /* Private functions ---------------------------------------------------------*/
65 
93 {
94  /* Check the parameters */
96  assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
97 
98  if (hi2c->State == HAL_I2C_STATE_READY)
99  {
100  /* Process Locked */
101  __HAL_LOCK(hi2c);
102 
103  hi2c->State = HAL_I2C_STATE_BUSY;
104 
105  /* Disable the selected I2C peripheral */
106  __HAL_I2C_DISABLE(hi2c);
107 
108  /* Reset I2Cx ANOFF bit */
109  hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
110 
111  /* Set analog filter bit*/
112  hi2c->Instance->CR1 |= AnalogFilter;
113 
114  __HAL_I2C_ENABLE(hi2c);
115 
116  hi2c->State = HAL_I2C_STATE_READY;
117 
118  /* Process Unlocked */
119  __HAL_UNLOCK(hi2c);
120 
121  return HAL_OK;
122  }
123  else
124  {
125  return HAL_BUSY;
126  }
127 }
128 
137 {
138  uint32_t tmpreg;
139 
140  /* Check the parameters */
142  assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
143 
144  if (hi2c->State == HAL_I2C_STATE_READY)
145  {
146  /* Process Locked */
147  __HAL_LOCK(hi2c);
148 
149  hi2c->State = HAL_I2C_STATE_BUSY;
150 
151  /* Disable the selected I2C peripheral */
152  __HAL_I2C_DISABLE(hi2c);
153 
154  /* Get the old register value */
155  tmpreg = hi2c->Instance->CR1;
156 
157  /* Reset I2Cx DNF bits [11:8] */
158  tmpreg &= ~(I2C_CR1_DNF);
159 
160  /* Set I2Cx DNF coefficient */
161  tmpreg |= DigitalFilter << 8U;
162 
163  /* Store the new register value */
164  hi2c->Instance->CR1 = tmpreg;
165 
166  __HAL_I2C_ENABLE(hi2c);
167 
168  hi2c->State = HAL_I2C_STATE_READY;
169 
170  /* Process Unlocked */
171  __HAL_UNLOCK(hi2c);
172 
173  return HAL_OK;
174  }
175  else
176  {
177  return HAL_BUSY;
178  }
179 }
180 
181 #if (defined(SYSCFG_PMC_I2C_PB6_FMP) || defined(SYSCFG_PMC_I2C_PB7_FMP)) || (defined(SYSCFG_PMC_I2C_PB8_FMP) || defined(SYSCFG_PMC_I2C_PB9_FMP)) || (defined(SYSCFG_PMC_I2C1_FMP)) || (defined(SYSCFG_PMC_I2C2_FMP)) || defined(SYSCFG_PMC_I2C3_FMP) || defined(SYSCFG_PMC_I2C4_FMP)
182 
199 void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
200 {
201  /* Check the parameter */
202  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
203 
204  /* Enable SYSCFG clock */
206 
207  /* Enable fast mode plus driving capability for selected pin */
208  SET_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
209 }
210 
228 void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
229 {
230  /* Check the parameter */
231  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
232 
233  /* Enable SYSCFG clock */
235 
236  /* Disable fast mode plus driving capability for selected pin */
237  CLEAR_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
238 }
239 
240 #endif
241 
249 #endif /* HAL_I2C_MODULE_ENABLED */
250 
258 /************************ (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_ALL_INSTANCE
#define IS_I2C_ALL_INSTANCE(INSTANCE)
Definition: stm32f407xx.h:15129
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_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
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
stm32f7xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
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:53