STM32L4xx_HAL_Driver  1.14.0

Extended features functions. More...

Modules

 I2C Extended Private Constants
 
 I2C Extended Private Macros
 
 I2C Extended Private Functions
 

Functions

HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter (I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
 Configure I2C Analog noise filter. More...
 
HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter (I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
 Configure I2C Digital noise filter. More...
 
HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp (I2C_HandleTypeDef *hi2c)
 Enable I2C wakeup from Stop mode(s). More...
 
HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp (I2C_HandleTypeDef *hi2c)
 Disable I2C wakeup from Stop mode(s). More...
 
void HAL_I2CEx_EnableFastModePlus (uint32_t ConfigFastModePlus)
 Enable the I2C fast mode plus driving capability. More...
 
void HAL_I2CEx_DisableFastModePlus (uint32_t ConfigFastModePlus)
 Disable the I2C fast mode plus driving capability. More...
 

Detailed Description

Extended features functions.

 ===============================================================================
                      ##### Extended features functions #####
 ===============================================================================
    [..] This section provides functions allowing to:
      (+) Configure Noise Filters
      (+) Configure Wake Up Feature
      (+) Configure Fast Mode Plus

Function Documentation

◆ HAL_I2CEx_ConfigAnalogFilter()

HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter ( I2C_HandleTypeDef hi2c,
uint32_t  AnalogFilter 
)

Configure I2C Analog noise filter.

Parameters
hi2cPointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral.
AnalogFilterNew state of the Analog filter.
Return values
HALstatus

Definition at line 97 of file stm32l4xx_hal_i2c_ex.c.

98 {
99  /* Check the parameters */
100  assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_I2C_StateTypeDef State
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_I2CEx_ConfigDigitalFilter()

HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter ( I2C_HandleTypeDef hi2c,
uint32_t  DigitalFilter 
)

Configure I2C Digital noise filter.

Parameters
hi2cPointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral.
DigitalFilterCoefficient of digital noise filter between Min_Data=0x00 and Max_Data=0x0F.
Return values
HALstatus

Definition at line 141 of file stm32l4xx_hal_i2c_ex.c.

142 {
143  uint32_t tmpreg;
144 
145  /* Check the parameters */
146  assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_I2C_StateTypeDef State
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_I2CEx_DisableFastModePlus()

void HAL_I2CEx_DisableFastModePlus ( uint32_t  ConfigFastModePlus)

Disable the I2C fast mode plus driving capability.

Parameters
ConfigFastModePlusSelects the pin. This parameter can be one of the I2C Extended Fast Mode Plus values
Note
For I2C1, fast mode plus driving capability can be disabled on all selected I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently on each one of the following pins PB6, PB7, PB8 and PB9.
For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability can be disabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
For all I2C2 pins fast mode plus driving capability can be disabled only by using I2C_FASTMODEPLUS_I2C2 parameter.
For all I2C3 pins fast mode plus driving capability can be disabled only by using I2C_FASTMODEPLUS_I2C3 parameter.
For all I2C4 pins fast mode plus driving capability can be disabled only by using I2C_FASTMODEPLUS_I2C4 parameter.
Return values
None

Definition at line 310 of file stm32l4xx_hal_i2c_ex.c.

311 {
312  /* Check the parameter */
313  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
314 
315  /* Enable SYSCFG clock */
316  __HAL_RCC_SYSCFG_CLK_ENABLE();
317 
318  /* Disable fast mode plus driving capability for selected pin */
319  CLEAR_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
320 }
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_I2CEx_DisableWakeUp()

HAL_StatusTypeDef HAL_I2CEx_DisableWakeUp ( I2C_HandleTypeDef hi2c)

Disable I2C wakeup from Stop mode(s).

Parameters
hi2cPointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral.
Return values
HALstatus

Definition at line 231 of file stm32l4xx_hal_i2c_ex.c.

232 {
233  /* Check the parameters */
234  assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_I2C_StateTypeDef State
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_I2CEx_EnableFastModePlus()

void HAL_I2CEx_EnableFastModePlus ( uint32_t  ConfigFastModePlus)

Enable the I2C fast mode plus driving capability.

Parameters
ConfigFastModePlusSelects the pin. This parameter can be one of the I2C Extended Fast Mode Plus values
Note
For I2C1, fast mode plus driving capability can be enabled on all selected I2C1 pins using I2C_FASTMODEPLUS_I2C1 parameter or independently on each one of the following pins PB6, PB7, PB8 and PB9.
For remaining I2C1 pins (PA14, PA15...) fast mode plus driving capability can be enabled only by using I2C_FASTMODEPLUS_I2C1 parameter.
For all I2C2 pins fast mode plus driving capability can be enabled only by using I2C_FASTMODEPLUS_I2C2 parameter.
For all I2C3 pins fast mode plus driving capability can be enabled only by using I2C_FASTMODEPLUS_I2C3 parameter.
For all I2C4 pins fast mode plus driving capability can be enabled only by using I2C_FASTMODEPLUS_I2C4 parameter.
Return values
None

Definition at line 281 of file stm32l4xx_hal_i2c_ex.c.

282 {
283  /* Check the parameter */
284  assert_param(IS_I2C_FASTMODEPLUS(ConfigFastModePlus));
285 
286  /* Enable SYSCFG clock */
287  __HAL_RCC_SYSCFG_CLK_ENABLE();
288 
289  /* Enable fast mode plus driving capability for selected pin */
290  SET_BIT(SYSCFG->CFGR1, (uint32_t)ConfigFastModePlus);
291 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_I2CEx_EnableWakeUp()

HAL_StatusTypeDef HAL_I2CEx_EnableWakeUp ( I2C_HandleTypeDef hi2c)

Enable I2C wakeup from Stop mode(s).

Parameters
hi2cPointer to a I2C_HandleTypeDef structure that contains the configuration information for the specified I2Cx peripheral.
Return values
HALstatus

Definition at line 192 of file stm32l4xx_hal_i2c_ex.c.

193 {
194  /* Check the parameters */
195  assert_param(IS_I2C_WAKEUP_FROMSTOP_INSTANCE(hi2c->Instance));
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 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
__IO HAL_I2C_StateTypeDef State
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))