STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_i2c_ex.c
Go to the documentation of this file.
1 
64 /* Includes ------------------------------------------------------------------*/
65 #include "stm32f7xx_hal.h"
66 
76 #ifdef HAL_I2C_MODULE_ENABLED
77 
78 /* Private typedef -----------------------------------------------------------*/
79 /* Private define ------------------------------------------------------------*/
80 /* Private macro -------------------------------------------------------------*/
81 /* Private variables ---------------------------------------------------------*/
82 /* Private function prototypes -----------------------------------------------*/
83 /* Private functions ---------------------------------------------------------*/
84 
112 {
113  /* Check the parameters */
115  assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
116 
117  if(hi2c->State == HAL_I2C_STATE_READY)
118  {
119  /* Process Locked */
120  __HAL_LOCK(hi2c);
121 
122  hi2c->State = HAL_I2C_STATE_BUSY;
123 
124  /* Disable the selected I2C peripheral */
125  __HAL_I2C_DISABLE(hi2c);
126 
127  /* Reset I2Cx ANOFF bit */
128  hi2c->Instance->CR1 &= ~(I2C_CR1_ANFOFF);
129 
130  /* Set analog filter bit*/
131  hi2c->Instance->CR1 |= AnalogFilter;
132 
133  __HAL_I2C_ENABLE(hi2c);
134 
135  hi2c->State = HAL_I2C_STATE_READY;
136 
137  /* Process Unlocked */
138  __HAL_UNLOCK(hi2c);
139 
140  return HAL_OK;
141  }
142  else
143  {
144  return HAL_BUSY;
145  }
146 }
147 
156 {
157  uint32_t tmpreg = 0;
158 
159  /* Check the parameters */
161  assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
162 
163  if(hi2c->State == HAL_I2C_STATE_READY)
164  {
165  /* Process Locked */
166  __HAL_LOCK(hi2c);
167 
168  hi2c->State = HAL_I2C_STATE_BUSY;
169 
170  /* Disable the selected I2C peripheral */
171  __HAL_I2C_DISABLE(hi2c);
172 
173  /* Get the old register value */
174  tmpreg = hi2c->Instance->CR1;
175 
176  /* Reset I2Cx DNF bits [11:8] */
177  tmpreg &= ~(I2C_CR1_DNF);
178 
179  /* Set I2Cx DNF coefficient */
180  tmpreg |= DigitalFilter << 8;
181 
182  /* Store the new register value */
183  hi2c->Instance->CR1 = tmpreg;
184 
185  __HAL_I2C_ENABLE(hi2c);
186 
187  hi2c->State = HAL_I2C_STATE_READY;
188 
189  /* Process Unlocked */
190  __HAL_UNLOCK(hi2c);
191 
192  return HAL_OK;
193  }
194  else
195  {
196  return HAL_BUSY;
197  }
198 }
199 
200 #if defined (STM32F765xx) || defined (STM32F767xx) || defined (STM32F769xx) || defined (STM32F777xx) || defined (STM32F779xx)
201 
207 void HAL_I2CEx_EnableFastModePlus(uint32_t ConfigFastModePlus)
208 {
209  /* Check the parameter */
210  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
211 
212  /* Enable SYSCFG clock */
214 
215  /* Enable fast mode plus driving capability for selected pin */
216  SET_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
217 }
218 
225 void HAL_I2CEx_DisableFastModePlus(uint32_t ConfigFastModePlus)
226 {
227  /* Check the parameter */
228  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
229 
230  /* Enable SYSCFG clock */
232 
233  /* Disable fast mode plus driving capability for selected pin */
234  CLEAR_BIT(SYSCFG->PMC, (uint32_t)ConfigFastModePlus);
235 }
236 #endif /* STM32F767xx || STM32F769xx || STM32F777xx || STM32F779xx */
237 
246 #endif /* HAL_I2C_MODULE_ENABLED */
247 
255 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define CLEAR_BIT(REG, BIT)
Definition: stm32f7xx.h:180
#define IS_I2C_DIGITAL_FILTER(FILTER)
#define assert_param(expr)
Include module&#39;s header file.
#define __HAL_UNLOCK(__HANDLE__)
HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
#define __HAL_LOCK(__HANDLE__)
#define __HAL_I2C_DISABLE(__HANDLE__)
Disable the specified I2C peripheral.
#define IS_I2C_ALL_INSTANCE(__INSTANCE__)
Definition: stm32f745xx.h:8853
This file contains all the functions prototypes for the HAL module driver.
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
#define __HAL_RCC_SYSCFG_CLK_ENABLE()
#define IS_I2C_ANALOG_FILTER(FILTER)
#define SET_BIT(REG, BIT)
Definition: stm32f7xx.h:178
__IO HAL_I2C_StateTypeDef State
#define I2C_CR1_ANFOFF
Definition: stm32f745xx.h:4830
#define I2C_CR1_DNF
Definition: stm32f745xx.h:4829
__IO uint32_t CR1
Definition: stm32f745xx.h:628
HAL_StatusTypeDef
HAL Status structures definition.
#define __HAL_I2C_ENABLE(__HANDLE__)
Enable the specified I2C peripheral.
#define SYSCFG
Definition: stm32f745xx.h:1300