STM32L4xx_HAL_Driver  1.14.0
Initialization/de-initialization functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_LPTIM_Init (LPTIM_HandleTypeDef *hlptim)
 Initialize the LPTIM according to the specified parameters in the LPTIM_InitTypeDef and initialize the associated handle. More...
 
HAL_StatusTypeDef HAL_LPTIM_DeInit (LPTIM_HandleTypeDef *hlptim)
 DeInitialize the LPTIM peripheral. More...
 
__weak void HAL_LPTIM_MspInit (LPTIM_HandleTypeDef *hlptim)
 Initialize the LPTIM MSP. More...
 
__weak void HAL_LPTIM_MspDeInit (LPTIM_HandleTypeDef *hlptim)
 DeInitialize LPTIM MSP. More...
 

Detailed Description

Initialization and Configuration functions.

  ==============================================================================
              ##### Initialization and de-initialization functions #####
  ==============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize the LPTIM according to the specified parameters in the
          LPTIM_InitTypeDef and initialize the associated handle.
      (+) DeInitialize the LPTIM peripheral.
      (+) Initialize the LPTIM MSP.
      (+) DeInitialize the LPTIM MSP.

Function Documentation

◆ HAL_LPTIM_DeInit()

HAL_StatusTypeDef HAL_LPTIM_DeInit ( LPTIM_HandleTypeDef hlptim)

DeInitialize the LPTIM peripheral.

Parameters
hlptimLPTIM handle
Return values
HALstatus

Definition at line 345 of file stm32l4xx_hal_lptim.c.

346 {
347  /* Check the LPTIM handle allocation */
348  if (hlptim == NULL)
349  {
350  return HAL_ERROR;
351  }
352 
353  /* Change the LPTIM state */
354  hlptim->State = HAL_LPTIM_STATE_BUSY;
355 
356  /* Disable the LPTIM Peripheral Clock */
357  __HAL_LPTIM_DISABLE(hlptim);
358 
359 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
360  if (hlptim->MspDeInitCallback == NULL)
361  {
362  hlptim->MspDeInitCallback = HAL_LPTIM_MspDeInit;
363  }
364 
365  /* DeInit the low level hardware: CLOCK, NVIC.*/
366  hlptim->MspDeInitCallback(hlptim);
367 #else
368  /* DeInit the low level hardware: CLOCK, NVIC.*/
369  HAL_LPTIM_MspDeInit(hlptim);
370 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
371 
372  /* Change the LPTIM state */
373  hlptim->State = HAL_LPTIM_STATE_RESET;
374 
375  /* Release Lock */
376  __HAL_UNLOCK(hlptim);
377 
378  /* Return function status */
379  return HAL_OK;
380 }
__HAL_UNLOCK(hrtc)
return HAL_OK
__weak void HAL_LPTIM_MspDeInit(LPTIM_HandleTypeDef *hlptim)
DeInitialize LPTIM MSP.

◆ HAL_LPTIM_Init()

HAL_StatusTypeDef HAL_LPTIM_Init ( LPTIM_HandleTypeDef hlptim)

Initialize the LPTIM according to the specified parameters in the LPTIM_InitTypeDef and initialize the associated handle.

Parameters
hlptimLPTIM handle
Return values
HALstatus

Definition at line 215 of file stm32l4xx_hal_lptim.c.

216 {
217  uint32_t tmpcfgr;
218 
219  /* Check the LPTIM handle allocation */
220  if (hlptim == NULL)
221  {
222  return HAL_ERROR;
223  }
224 
225  /* Check the parameters */
226  assert_param(IS_LPTIM_INSTANCE(hlptim->Instance));
227 
228  assert_param(IS_LPTIM_CLOCK_SOURCE(hlptim->Init.Clock.Source));
229  assert_param(IS_LPTIM_CLOCK_PRESCALER(hlptim->Init.Clock.Prescaler));
230  if ((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM)
231  {
232  assert_param(IS_LPTIM_CLOCK_POLARITY(hlptim->Init.UltraLowPowerClock.Polarity));
233  assert_param(IS_LPTIM_CLOCK_SAMPLE_TIME(hlptim->Init.UltraLowPowerClock.SampleTime));
234  }
235  assert_param(IS_LPTIM_TRG_SOURCE(hlptim->Init.Trigger.Source));
236  if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
237  {
238  assert_param(IS_LPTIM_TRIG_SAMPLE_TIME(hlptim->Init.Trigger.SampleTime));
239  assert_param(IS_LPTIM_EXT_TRG_POLARITY(hlptim->Init.Trigger.ActiveEdge));
240  }
241  assert_param(IS_LPTIM_OUTPUT_POLARITY(hlptim->Init.OutputPolarity));
242  assert_param(IS_LPTIM_UPDATE_MODE(hlptim->Init.UpdateMode));
243  assert_param(IS_LPTIM_COUNTER_SOURCE(hlptim->Init.CounterSource));
244 
245 #if defined(LPTIM_RCR_REP)
246  assert_param(IS_LPTIM_REPETITION(hlptim->Init.RepetitionCounter));
247 #endif
248 
249  if (hlptim->State == HAL_LPTIM_STATE_RESET)
250  {
251  /* Allocate lock resource and initialize it */
252  hlptim->Lock = HAL_UNLOCKED;
253 
254 #if (USE_HAL_LPTIM_REGISTER_CALLBACKS == 1)
255  /* Reset interrupt callbacks to legacy weak callbacks */
256  LPTIM_ResetCallback(hlptim);
257 
258  if (hlptim->MspInitCallback == NULL)
259  {
260  hlptim->MspInitCallback = HAL_LPTIM_MspInit;
261  }
262 
263  /* Init the low level hardware : GPIO, CLOCK, NVIC */
264  hlptim->MspInitCallback(hlptim);
265 #else
266  /* Init the low level hardware : GPIO, CLOCK, NVIC */
267  HAL_LPTIM_MspInit(hlptim);
268 #endif /* USE_HAL_LPTIM_REGISTER_CALLBACKS */
269  }
270 
271  /* Change the LPTIM state */
272  hlptim->State = HAL_LPTIM_STATE_BUSY;
273 
274  /* Get the LPTIMx CFGR value */
275  tmpcfgr = hlptim->Instance->CFGR;
276 
277  if (((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM) || ((hlptim->Init.CounterSource) == LPTIM_COUNTERSOURCE_EXTERNAL))
278  {
279  tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKPOL | LPTIM_CFGR_CKFLT));
280  }
281  if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
282  {
283  tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_TRGFLT | LPTIM_CFGR_TRIGSEL));
284  }
285 
286  /* Clear CKSEL, CKPOL, PRESC, TRIGEN, TRGFLT, WAVPOL, PRELOAD & COUNTMODE bits */
287  tmpcfgr &= (uint32_t)(~(LPTIM_CFGR_CKSEL | LPTIM_CFGR_CKPOL | LPTIM_CFGR_TRIGEN | LPTIM_CFGR_PRELOAD |
288  LPTIM_CFGR_WAVPOL | LPTIM_CFGR_PRESC | LPTIM_CFGR_COUNTMODE));
289 
290  /* Set initialization parameters */
291  tmpcfgr |= (hlptim->Init.Clock.Source |
292  hlptim->Init.Clock.Prescaler |
293  hlptim->Init.OutputPolarity |
294  hlptim->Init.UpdateMode |
295  hlptim->Init.CounterSource);
296 
297  if (((hlptim->Init.Clock.Source) == LPTIM_CLOCKSOURCE_ULPTIM) || ((hlptim->Init.CounterSource) == LPTIM_COUNTERSOURCE_EXTERNAL))
298  {
299  tmpcfgr |= (hlptim->Init.UltraLowPowerClock.Polarity |
300  hlptim->Init.UltraLowPowerClock.SampleTime);
301  }
302 
303  if ((hlptim->Init.Trigger.Source) != LPTIM_TRIGSOURCE_SOFTWARE)
304  {
305  /* Enable External trigger and set the trigger source */
306  tmpcfgr |= (hlptim->Init.Trigger.Source |
307  hlptim->Init.Trigger.ActiveEdge |
308  hlptim->Init.Trigger.SampleTime);
309  }
310 
311  /* Write to LPTIMx CFGR */
312  hlptim->Instance->CFGR = tmpcfgr;
313 
314  /* Configure LPTIM input sources */
315  if (hlptim->Instance == LPTIM1)
316  {
317  /* Check LPTIM Input1 and Input2 sources */
318  assert_param(IS_LPTIM_INPUT1_SOURCE(hlptim->Instance, hlptim->Init.Input1Source));
319  assert_param(IS_LPTIM_INPUT2_SOURCE(hlptim->Instance, hlptim->Init.Input2Source));
320 
321  /* Configure LPTIM Input1 and Input2 sources */
322  hlptim->Instance->OR = (hlptim->Init.Input1Source | hlptim->Init.Input2Source);
323  }
324  else
325  {
326  /* Check LPTIM2 Input1 source */
327  assert_param(IS_LPTIM_INPUT1_SOURCE(hlptim->Instance, hlptim->Init.Input1Source));
328 
329  /* Configure LPTIM2 Input1 source */
330  hlptim->Instance->OR = hlptim->Init.Input1Source;
331  }
332 
333  /* Change the LPTIM state */
334  hlptim->State = HAL_LPTIM_STATE_READY;
335 
336  /* Return function status */
337  return HAL_OK;
338 }
return HAL_OK
__weak void HAL_LPTIM_MspInit(LPTIM_HandleTypeDef *hlptim)
Initialize the LPTIM MSP.
static void LPTIM_ResetCallback(LPTIM_HandleTypeDef *lptim)
Reset interrupt callbacks to the legacy weak callbacks.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_LPTIM_MspDeInit()

__weak void HAL_LPTIM_MspDeInit ( LPTIM_HandleTypeDef hlptim)

DeInitialize LPTIM MSP.

Parameters
hlptimLPTIM handle
Return values
None

Definition at line 402 of file stm32l4xx_hal_lptim.c.

403 {
404  /* Prevent unused argument(s) compilation warning */
405  UNUSED(hlptim);
406 
407  /* NOTE : This function should not be modified, when the callback is needed,
408  the HAL_LPTIM_MspDeInit could be implemented in the user file
409  */
410 }

◆ HAL_LPTIM_MspInit()

__weak void HAL_LPTIM_MspInit ( LPTIM_HandleTypeDef hlptim)

Initialize the LPTIM MSP.

Parameters
hlptimLPTIM handle
Return values
None

Definition at line 387 of file stm32l4xx_hal_lptim.c.

388 {
389  /* Prevent unused argument(s) compilation warning */
390  UNUSED(hlptim);
391 
392  /* NOTE : This function should not be modified, when the callback is needed,
393  the HAL_LPTIM_MspInit could be implemented in the user file
394  */
395 }