STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Initialization and Configuration functions. More...

Functions

HAL_StatusTypeDef HAL_TSC_Init (TSC_HandleTypeDef *htsc)
 Initialize the TSC peripheral according to the specified parameters in the TSC_InitTypeDef structure and initialize the associated handle. More...
 
HAL_StatusTypeDef HAL_TSC_DeInit (TSC_HandleTypeDef *htsc)
 Deinitialize the TSC peripheral registers to their default reset values. More...
 
void HAL_TSC_MspInit (TSC_HandleTypeDef *htsc)
 Initialize the TSC MSP. More...
 
void HAL_TSC_MspDeInit (TSC_HandleTypeDef *htsc)
 DeInitialize the TSC MSP. More...
 
HAL_StatusTypeDef HAL_TSC_RegisterCallback (TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID, pTSC_CallbackTypeDef pCallback)
 Register a User TSC Callback To be used instead of the weak predefined callback. More...
 
HAL_StatusTypeDef HAL_TSC_UnRegisterCallback (TSC_HandleTypeDef *htsc, HAL_TSC_CallbackIDTypeDef CallbackID)
 Unregister an TSC Callback TSC callback is redirected to the weak predefined callback. More...
 

Detailed Description

Initialization and Configuration functions.

 ===============================================================================
              ##### Initialization and de-initialization functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize and configure the TSC.
      (+) De-initialize the TSC.

Function Documentation

◆ HAL_TSC_DeInit()

HAL_StatusTypeDef HAL_TSC_DeInit ( TSC_HandleTypeDef htsc)

Deinitialize the TSC peripheral registers to their default reset values.

Parameters
htscTSC handle
Return values
HALstatus

Definition at line 350 of file stm32l4xx_hal_tsc.c.

351 {
352  /* Check TSC handle allocation */
353  if (htsc == NULL)
354  {
355  return HAL_ERROR;
356  }
357 
358  /* Check the parameters */
359  assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance));
360 
361  /* Change TSC state */
362  htsc->State = HAL_TSC_STATE_BUSY;
363 
364 #if (USE_HAL_TSC_REGISTER_CALLBACKS == 1)
365  if (htsc->MspDeInitCallback == NULL)
366  {
367  htsc->MspDeInitCallback = HAL_TSC_MspDeInit; /* Legacy weak MspDeInit */
368  }
369 
370  /* DeInit the low level hardware: GPIO, CLOCK, NVIC */
371  htsc->MspDeInitCallback(htsc);
372 #else
373  /* DeInit the low level hardware */
374  HAL_TSC_MspDeInit(htsc);
375 #endif /* USE_HAL_TSC_REGISTER_CALLBACKS */
376 
377  /* Change TSC state */
378  htsc->State = HAL_TSC_STATE_RESET;
379 
380  /* Process unlocked */
381  __HAL_UNLOCK(htsc);
382 
383  /* Return function status */
384  return HAL_OK;
385 }
__IO HAL_TSC_StateTypeDef State
__HAL_UNLOCK(hrtc)
return HAL_OK
void HAL_TSC_MspDeInit(TSC_HandleTypeDef *htsc)
DeInitialize the TSC MSP.
void(* MspDeInitCallback)(struct __TSC_HandleTypeDef *htsc)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TSC_Init()

HAL_StatusTypeDef HAL_TSC_Init ( TSC_HandleTypeDef htsc)

Initialize the TSC peripheral according to the specified parameters in the TSC_InitTypeDef structure and initialize the associated handle.

Parameters
htscTSC handle
Return values
HALstatus

Definition at line 245 of file stm32l4xx_hal_tsc.c.

246 {
247  /* Check TSC handle allocation */
248  if (htsc == NULL)
249  {
250  return HAL_ERROR;
251  }
252 
253  /* Check the parameters */
254  assert_param(IS_TSC_ALL_INSTANCE(htsc->Instance));
255  assert_param(IS_TSC_CTPH(htsc->Init.CTPulseHighLength));
256  assert_param(IS_TSC_CTPL(htsc->Init.CTPulseLowLength));
257  assert_param(IS_TSC_SS(htsc->Init.SpreadSpectrum));
258  assert_param(IS_TSC_SSD(htsc->Init.SpreadSpectrumDeviation));
259  assert_param(IS_TSC_SS_PRESC(htsc->Init.SpreadSpectrumPrescaler));
260  assert_param(IS_TSC_PG_PRESC(htsc->Init.PulseGeneratorPrescaler));
261  assert_param(IS_TSC_MCV(htsc->Init.MaxCountValue));
262  assert_param(IS_TSC_IODEF(htsc->Init.IODefaultMode));
263  assert_param(IS_TSC_SYNC_POL(htsc->Init.SynchroPinPolarity));
264  assert_param(IS_TSC_ACQ_MODE(htsc->Init.AcquisitionMode));
265  assert_param(IS_TSC_MCE_IT(htsc->Init.MaxCountInterrupt));
266  assert_param(IS_TSC_GROUP(htsc->Init.ChannelIOs));
267  assert_param(IS_TSC_GROUP(htsc->Init.ShieldIOs));
268  assert_param(IS_TSC_GROUP(htsc->Init.SamplingIOs));
269 
270  if (htsc->State == HAL_TSC_STATE_RESET)
271  {
272  /* Allocate lock resource and initialize it */
273  htsc->Lock = HAL_UNLOCKED;
274 
275 #if (USE_HAL_TSC_REGISTER_CALLBACKS == 1)
276  /* Init the TSC Callback settings */
277  htsc->ConvCpltCallback = HAL_TSC_ConvCpltCallback; /* Legacy weak ConvCpltCallback */
278  htsc->ErrorCallback = HAL_TSC_ErrorCallback; /* Legacy weak ErrorCallback */
279 
280  if (htsc->MspInitCallback == NULL)
281  {
282  htsc->MspInitCallback = HAL_TSC_MspInit; /* Legacy weak MspInit */
283  }
284 
285  /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
286  htsc->MspInitCallback(htsc);
287 #else
288  /* Init the low level hardware : GPIO, CLOCK, CORTEX */
289  HAL_TSC_MspInit(htsc);
290 #endif /* USE_HAL_TSC_REGISTER_CALLBACKS */
291  }
292 
293  /* Initialize the TSC state */
294  htsc->State = HAL_TSC_STATE_BUSY;
295 
296  /*--------------------------------------------------------------------------*/
297  /* Set TSC parameters */
298 
299  /* Enable TSC */
300  htsc->Instance->CR = TSC_CR_TSCE;
301 
302  /* Set all functions */
303  htsc->Instance->CR |= (htsc->Init.CTPulseHighLength |
304  htsc->Init.CTPulseLowLength |
305  (htsc->Init.SpreadSpectrumDeviation << TSC_CR_SSD_Pos) |
308  htsc->Init.MaxCountValue |
309  htsc->Init.SynchroPinPolarity |
310  htsc->Init.AcquisitionMode);
311 
312  /* Spread spectrum */
313  if (htsc->Init.SpreadSpectrum == ENABLE)
314  {
315  htsc->Instance->CR |= TSC_CR_SSE;
316  }
317 
318  /* Disable Schmitt trigger hysteresis on all used TSC IOs */
319  htsc->Instance->IOHCR = (~(htsc->Init.ChannelIOs | htsc->Init.ShieldIOs | htsc->Init.SamplingIOs));
320 
321  /* Set channel and shield IOs */
322  htsc->Instance->IOCCR = (htsc->Init.ChannelIOs | htsc->Init.ShieldIOs);
323 
324  /* Set sampling IOs */
325  htsc->Instance->IOSCR = htsc->Init.SamplingIOs;
326 
327  /* Set the groups to be acquired */
328  htsc->Instance->IOGCSR = TSC_extract_groups(htsc->Init.ChannelIOs);
329 
330  /* Disable interrupts */
331  htsc->Instance->IER &= (~(TSC_IT_EOA | TSC_IT_MCE));
332 
333  /* Clear flags */
334  htsc->Instance->ICR = (TSC_FLAG_EOA | TSC_FLAG_MCE);
335 
336  /*--------------------------------------------------------------------------*/
337 
338  /* Initialize the TSC state */
339  htsc->State = HAL_TSC_STATE_READY;
340 
341  /* Return function status */
342  return HAL_OK;
343 }
TSC_InitTypeDef Init
void HAL_TSC_ErrorCallback(TSC_HandleTypeDef *htsc)
Error callback in non-blocking mode.
__IO HAL_TSC_StateTypeDef State
void HAL_TSC_MspInit(TSC_HandleTypeDef *htsc)
Initialize the TSC MSP.
void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef *htsc)
Acquisition completed callback in non-blocking mode.
uint32_t SynchroPinPolarity
void(* MspInitCallback)(struct __TSC_HandleTypeDef *htsc)
return HAL_OK
uint32_t SpreadSpectrumDeviation
void(* ConvCpltCallback)(struct __TSC_HandleTypeDef *htsc)
FunctionalState MaxCountInterrupt
uint32_t CTPulseLowLength
static uint32_t TSC_extract_groups(uint32_t iomask)
Utility function used to set the acquired groups mask.
uint32_t CTPulseHighLength
FunctionalState SpreadSpectrum
uint32_t AcquisitionMode
uint32_t PulseGeneratorPrescaler
void(* ErrorCallback)(struct __TSC_HandleTypeDef *htsc)
uint32_t SpreadSpectrumPrescaler
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))
HAL_LockTypeDef Lock

◆ HAL_TSC_MspDeInit()

__weak void HAL_TSC_MspDeInit ( TSC_HandleTypeDef htsc)

DeInitialize the TSC MSP.

Parameters
htscPointer to a TSC_HandleTypeDef structure that contains the configuration information for the specified TSC.
Return values
None

Definition at line 409 of file stm32l4xx_hal_tsc.c.

410 {
411  /* Prevent unused argument(s) compilation warning */
412  UNUSED(htsc);
413 
414  /* NOTE : This function should not be modified, when the callback is needed,
415  the HAL_TSC_MspDeInit could be implemented in the user file.
416  */
417 }

◆ HAL_TSC_MspInit()

__weak void HAL_TSC_MspInit ( TSC_HandleTypeDef htsc)

Initialize the TSC MSP.

Parameters
htscPointer to a TSC_HandleTypeDef structure that contains the configuration information for the specified TSC.
Return values
None

Definition at line 393 of file stm32l4xx_hal_tsc.c.

394 {
395  /* Prevent unused argument(s) compilation warning */
396  UNUSED(htsc);
397 
398  /* NOTE : This function should not be modified, when the callback is needed,
399  the HAL_TSC_MspInit could be implemented in the user file.
400  */
401 }

◆ HAL_TSC_RegisterCallback()

HAL_StatusTypeDef HAL_TSC_RegisterCallback ( TSC_HandleTypeDef htsc,
HAL_TSC_CallbackIDTypeDef  CallbackID,
pTSC_CallbackTypeDef  pCallback 
)

Register a User TSC Callback To be used instead of the weak predefined callback.

Parameters
htscPointer to a TSC_HandleTypeDef structure that contains the configuration information for the specified TSC.
CallbackIDID of the callback to be registered This parameter can be one of the following values:
pCallbackpointer to the Callback function
Return values
HALstatus

Definition at line 434 of file stm32l4xx_hal_tsc.c.

435 {
436  HAL_StatusTypeDef status = HAL_OK;
437 
438  if (pCallback == NULL)
439  {
440  /* Update the error code */
441  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
442 
443  return HAL_ERROR;
444  }
445  /* Process locked */
446  __HAL_LOCK(htsc);
447 
448  if (HAL_TSC_STATE_READY == htsc->State)
449  {
450  switch (CallbackID)
451  {
453  htsc->ConvCpltCallback = pCallback;
454  break;
455 
456  case HAL_TSC_ERROR_CB_ID :
457  htsc->ErrorCallback = pCallback;
458  break;
459 
460  case HAL_TSC_MSPINIT_CB_ID :
461  htsc->MspInitCallback = pCallback;
462  break;
463 
465  htsc->MspDeInitCallback = pCallback;
466  break;
467 
468  default :
469  /* Update the error code */
470  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
471 
472  /* Return error status */
473  status = HAL_ERROR;
474  break;
475  }
476  }
477  else if (HAL_TSC_STATE_RESET == htsc->State)
478  {
479  switch (CallbackID)
480  {
481  case HAL_TSC_MSPINIT_CB_ID :
482  htsc->MspInitCallback = pCallback;
483  break;
484 
486  htsc->MspDeInitCallback = pCallback;
487  break;
488 
489  default :
490  /* Update the error code */
491  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
492 
493  /* Return error status */
494  status = HAL_ERROR;
495  break;
496  }
497  }
498  else
499  {
500  /* Update the error code */
501  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
502 
503  /* Return error status */
504  status = HAL_ERROR;
505  }
506 
507  /* Release Lock */
508  __HAL_UNLOCK(htsc);
509  return status;
510 }
__IO HAL_TSC_StateTypeDef State
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
void(* MspInitCallback)(struct __TSC_HandleTypeDef *htsc)
return HAL_OK
void(* ConvCpltCallback)(struct __TSC_HandleTypeDef *htsc)
void(* MspDeInitCallback)(struct __TSC_HandleTypeDef *htsc)
void(* ErrorCallback)(struct __TSC_HandleTypeDef *htsc)

◆ HAL_TSC_UnRegisterCallback()

HAL_StatusTypeDef HAL_TSC_UnRegisterCallback ( TSC_HandleTypeDef htsc,
HAL_TSC_CallbackIDTypeDef  CallbackID 
)

Unregister an TSC Callback TSC callback is redirected to the weak predefined callback.

Parameters
htscPointer to a TSC_HandleTypeDef structure that contains the configuration information for the specified TSC.
CallbackIDID of the callback to be unregistered This parameter can be one of the following values: This parameter can be one of the following values:
Return values
HALstatus

Definition at line 526 of file stm32l4xx_hal_tsc.c.

527 {
528  HAL_StatusTypeDef status = HAL_OK;
529 
530  /* Process locked */
531  __HAL_LOCK(htsc);
532 
533  if (HAL_TSC_STATE_READY == htsc->State)
534  {
535  switch (CallbackID)
536  {
538  htsc->ConvCpltCallback = HAL_TSC_ConvCpltCallback; /* Legacy weak ConvCpltCallback */
539  break;
540 
541  case HAL_TSC_ERROR_CB_ID :
542  htsc->ErrorCallback = HAL_TSC_ErrorCallback; /* Legacy weak ErrorCallback */
543  break;
544 
545  case HAL_TSC_MSPINIT_CB_ID :
546  htsc->MspInitCallback = HAL_TSC_MspInit; /* Legacy weak MspInit */
547  break;
548 
550  htsc->MspDeInitCallback = HAL_TSC_MspDeInit; /* Legacy weak MspDeInit */
551  break;
552 
553  default :
554  /* Update the error code */
555  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
556 
557  /* Return error status */
558  status = HAL_ERROR;
559  break;
560  }
561  }
562  else if (HAL_TSC_STATE_RESET == htsc->State)
563  {
564  switch (CallbackID)
565  {
566  case HAL_TSC_MSPINIT_CB_ID :
567  htsc->MspInitCallback = HAL_TSC_MspInit; /* Legacy weak MspInit */
568  break;
569 
571  htsc->MspDeInitCallback = HAL_TSC_MspDeInit; /* Legacy weak MspDeInit */
572  break;
573 
574  default :
575  /* Update the error code */
576  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
577 
578  /* Return error status */
579  status = HAL_ERROR;
580  break;
581  }
582  }
583  else
584  {
585  /* Update the error code */
586  htsc->ErrorCode |= HAL_TSC_ERROR_INVALID_CALLBACK;
587 
588  /* Return error status */
589  status = HAL_ERROR;
590  }
591 
592  /* Release Lock */
593  __HAL_UNLOCK(htsc);
594  return status;
595 }
void HAL_TSC_ErrorCallback(TSC_HandleTypeDef *htsc)
Error callback in non-blocking mode.
__IO HAL_TSC_StateTypeDef State
void HAL_TSC_MspInit(TSC_HandleTypeDef *htsc)
Initialize the TSC MSP.
void HAL_TSC_ConvCpltCallback(TSC_HandleTypeDef *htsc)
Acquisition completed callback in non-blocking mode.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
void(* MspInitCallback)(struct __TSC_HandleTypeDef *htsc)
return HAL_OK
void(* ConvCpltCallback)(struct __TSC_HandleTypeDef *htsc)
void HAL_TSC_MspDeInit(TSC_HandleTypeDef *htsc)
DeInitialize the TSC MSP.
void(* MspDeInitCallback)(struct __TSC_HandleTypeDef *htsc)
void(* ErrorCallback)(struct __TSC_HandleTypeDef *htsc)