STM32L4xx_HAL_Driver  1.14.0
Initialization and de-initialization functions

Initialization, configuration and call-back functions. More...

Functions

HAL_StatusTypeDef HAL_HASH_Init (HASH_HandleTypeDef *hhash)
 Initialize the HASH according to the specified parameters in the HASH_HandleTypeDef and create the associated handle. More...
 
HAL_StatusTypeDef HAL_HASH_DeInit (HASH_HandleTypeDef *hhash)
 DeInitialize the HASH peripheral. More...
 
void HAL_HASH_MspInit (HASH_HandleTypeDef *hhash)
 Initialize the HASH MSP. More...
 
void HAL_HASH_MspDeInit (HASH_HandleTypeDef *hhash)
 DeInitialize the HASH MSP. More...
 
void HAL_HASH_InCpltCallback (HASH_HandleTypeDef *hhash)
 Input data transfer complete call back. More...
 
void HAL_HASH_DgstCpltCallback (HASH_HandleTypeDef *hhash)
 Digest computation complete call back. More...
 
void HAL_HASH_ErrorCallback (HASH_HandleTypeDef *hhash)
 Error callback. More...
 
HAL_StatusTypeDef HAL_HASH_RegisterCallback (HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID, pHASH_CallbackTypeDef pCallback)
 Register a User HASH Callback To be used instead of the weak (surcharged) predefined callback. More...
 
HAL_StatusTypeDef HAL_HASH_UnRegisterCallback (HASH_HandleTypeDef *hhash, HAL_HASH_CallbackIDTypeDef CallbackID)
 Unregister a HASH Callback HASH Callback is redirected to the weak (surcharged) predefined callback. More...
 

Detailed Description

Initialization, configuration and call-back functions.

 ===============================================================================
              ##### Initialization and de-initialization functions #####
 ===============================================================================
    [..]  This section provides functions allowing to:
      (+) Initialize the HASH according to the specified parameters
          in the HASH_InitTypeDef and create the associated handle
      (+) DeInitialize the HASH peripheral
      (+) Initialize the HASH MCU Specific Package (MSP)
      (+) DeInitialize the HASH MSP

    [..]  This section provides as well call back functions definitions for user
          code to manage:
      (+) Input data transfer to Peripheral completion
      (+) Calculated digest retrieval completion
      (+) Error management

Function Documentation

◆ HAL_HASH_DeInit()

HAL_StatusTypeDef HAL_HASH_DeInit ( HASH_HandleTypeDef hhash)

DeInitialize the HASH peripheral.

Parameters
hhashHASH handle.
Return values
HALstatus

Definition at line 399 of file stm32l4xx_hal_hash.c.

400 {
401  /* Check the HASH handle allocation */
402  if(hhash == NULL)
403  {
404  return HAL_ERROR;
405  }
406 
407  /* Change the HASH state */
408  hhash->State = HAL_HASH_STATE_BUSY;
409 
410  /* Set the default HASH phase */
411  hhash->Phase = HAL_HASH_PHASE_READY;
412 
413  /* Reset HashInCount, HashITCounter and HashBuffSize */
414  hhash->HashInCount = 0;
415  hhash->HashBuffSize = 0;
416  hhash->HashITCounter = 0;
417  /* Reset digest calculation bridle (MDMAT bit control) */
418  hhash->DigestCalculationDisable = RESET;
419 
420 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
421  if(hhash->MspDeInitCallback == NULL)
422  {
423  hhash->MspDeInitCallback = HAL_HASH_MspDeInit;
424  }
425 
426  /* DeInit the low level hardware */
427  hhash->MspDeInitCallback(hhash);
428 #else
429  /* DeInit the low level hardware: CLOCK, NVIC */
430  HAL_HASH_MspDeInit(hhash);
431 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
432 
433 
434  /* Reset HASH handle status */
435  hhash->Status = HAL_OK;
436 
437  /* Set the HASH state to Ready */
438  hhash->State = HAL_HASH_STATE_RESET;
439 
440  /* Initialise the error code */
441  hhash->ErrorCode = HAL_HASH_ERROR_NONE;
442 
443  /* Reset multi buffers accumulation flag */
444  hhash->Accumulation = 0U;
445 
446  /* Return function status */
447  return HAL_OK;
448 }
void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash)
DeInitialize the HASH MSP.
return HAL_OK

◆ HAL_HASH_DgstCpltCallback()

__weak void HAL_HASH_DgstCpltCallback ( HASH_HandleTypeDef hhash)

Digest computation complete call back.

Note
HAL_HASH_DgstCpltCallback() is used under interruption, is not relevant with DMA.
Parameters
hhashHASH handle.
Return values
None

Definition at line 508 of file stm32l4xx_hal_hash.c.

509 {
510  /* Prevent unused argument(s) compilation warning */
511  UNUSED(hhash);
512 
513  /* NOTE : This function should not be modified; when the callback is needed,
514  HAL_HASH_DgstCpltCallback() can be implemented in the user file.
515  */
516 }

◆ HAL_HASH_ErrorCallback()

__weak void HAL_HASH_ErrorCallback ( HASH_HandleTypeDef hhash)

Error callback.

Note
Code user can resort to hhash->Status (HAL_ERROR, HAL_TIMEOUT,...) to retrieve the error type.
Parameters
hhashHASH handle.
Return values
None

Definition at line 525 of file stm32l4xx_hal_hash.c.

526 {
527  /* Prevent unused argument(s) compilation warning */
528  UNUSED(hhash);
529 
530  /* NOTE : This function should not be modified; when the callback is needed,
531  HAL_HASH_ErrorCallback() can be implemented in the user file.
532  */
533 }

◆ HAL_HASH_InCpltCallback()

__weak void HAL_HASH_InCpltCallback ( HASH_HandleTypeDef hhash)

Input data transfer complete call back.

Note
HAL_HASH_InCpltCallback() is called when the complete input message has been fed to the Peripheral. This API is invoked only when input data are entered under interruption or thru DMA.
In case of HASH or HMAC multi-buffer DMA feeding case (MDMAT bit set), HAL_HASH_InCpltCallback() is called at the end of each buffer feeding to the Peripheral.
Parameters
hhashHASH handle.
Return values
None

Definition at line 491 of file stm32l4xx_hal_hash.c.

492 {
493  /* Prevent unused argument(s) compilation warning */
494  UNUSED(hhash);
495 
496  /* NOTE : This function should not be modified; when the callback is needed,
497  HAL_HASH_InCpltCallback() can be implemented in the user file.
498  */
499 }

◆ HAL_HASH_Init()

HAL_StatusTypeDef HAL_HASH_Init ( HASH_HandleTypeDef hhash)

Initialize the HASH according to the specified parameters in the HASH_HandleTypeDef and create the associated handle.

Note
Only MDMAT and DATATYPE bits of HASH Peripheral are set by HAL_HASH_Init(), other configuration bits are set by HASH or HMAC processing APIs.
MDMAT bit is systematically reset by HAL_HASH_Init(). To set it for multi-buffer HASH processing, user needs to resort to __HAL_HASH_SET_MDMAT() macro. For HMAC multi-buffer processing, the relevant APIs manage themselves the MDMAT bit.
Parameters
hhashHASH handle
Return values
HALstatus

Definition at line 324 of file stm32l4xx_hal_hash.c.

325 {
326  /* Check the parameters */
327  assert_param(IS_HASH_DATATYPE(hhash->Init.DataType));
328 
329  /* Check the hash handle allocation */
330  if(hhash == NULL)
331  {
332  return HAL_ERROR;
333  }
334 
335 #if (USE_HAL_HASH_REGISTER_CALLBACKS == 1)
336  if (hhash->State == HAL_HASH_STATE_RESET)
337  {
338  /* Allocate lock resource and initialize it */
339  hhash->Lock = HAL_UNLOCKED;
340 
341  /* Reset Callback pointers in HAL_HASH_STATE_RESET only */
342  hhash->InCpltCallback = HAL_HASH_InCpltCallback; /* Legacy weak (surcharged) input completion callback */
343  hhash->DgstCpltCallback = HAL_HASH_DgstCpltCallback; /* Legacy weak (surcharged) digest computation completion callback */
344  hhash->ErrorCallback = HAL_HASH_ErrorCallback; /* Legacy weak (surcharged) error callback */
345  if(hhash->MspInitCallback == NULL)
346  {
347  hhash->MspInitCallback = HAL_HASH_MspInit;
348  }
349 
350  /* Init the low level hardware */
351  hhash->MspInitCallback(hhash);
352  }
353 #else
354  if(hhash->State == HAL_HASH_STATE_RESET)
355  {
356  /* Allocate lock resource and initialize it */
357  hhash->Lock = HAL_UNLOCKED;
358 
359  /* Init the low level hardware */
360  HAL_HASH_MspInit(hhash);
361  }
362 #endif /* (USE_HAL_HASH_REGISTER_CALLBACKS) */
363 
364  /* Change the HASH state */
365  hhash->State = HAL_HASH_STATE_BUSY;
366 
367  /* Reset HashInCount, HashITCounter, HashBuffSize and NbWordsAlreadyPushed */
368  hhash->HashInCount = 0;
369  hhash->HashBuffSize = 0;
370  hhash->HashITCounter = 0;
371  hhash->NbWordsAlreadyPushed = 0;
372  /* Reset digest calculation bridle (MDMAT bit control) */
373  hhash->DigestCalculationDisable = RESET;
374  /* Set phase to READY */
375  hhash->Phase = HAL_HASH_PHASE_READY;
376 
377  /* Set the data type bit */
378  MODIFY_REG(HASH->CR, HASH_CR_DATATYPE, hhash->Init.DataType);
379  /* Reset MDMAT bit */
380 __HAL_HASH_RESET_MDMAT();
381  /* Reset HASH handle status */
382  hhash->Status = HAL_OK;
383 
384  /* Set the HASH state to Ready */
385  hhash->State = HAL_HASH_STATE_READY;
386 
387  /* Initialise the error code */
388  hhash->ErrorCode = HAL_HASH_ERROR_NONE;
389 
390  /* Return function status */
391  return HAL_OK;
392 }
void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash)
Initialize the HASH MSP.
void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash)
Input data transfer complete call back.
void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash)
Digest computation complete call back.
return HAL_OK
void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash)
Error callback.
MODIFY_REG(hrtc->Instance->CR, RTC_CR_WUCKSEL,(uint32_t) WakeUpClock)
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_HASH_MspDeInit()

__weak void HAL_HASH_MspDeInit ( HASH_HandleTypeDef hhash)

DeInitialize the HASH MSP.

Parameters
hhashHASH handle.
Return values
None

Definition at line 470 of file stm32l4xx_hal_hash.c.

471 {
472  /* Prevent unused argument(s) compilation warning */
473  UNUSED(hhash);
474 
475  /* NOTE : This function should not be modified; when the callback is needed,
476  HAL_HASH_MspDeInit() can be implemented in the user file.
477  */
478 }

◆ HAL_HASH_MspInit()

__weak void HAL_HASH_MspInit ( HASH_HandleTypeDef hhash)

Initialize the HASH MSP.

Parameters
hhashHASH handle.
Return values
None

Definition at line 455 of file stm32l4xx_hal_hash.c.

456 {
457  /* Prevent unused argument(s) compilation warning */
458  UNUSED(hhash);
459 
460  /* NOTE : This function should not be modified; when the callback is needed,
461  HAL_HASH_MspInit() can be implemented in the user file.
462  */
463 }

◆ HAL_HASH_RegisterCallback()

HAL_StatusTypeDef HAL_HASH_RegisterCallback ( HASH_HandleTypeDef hhash,
HAL_HASH_CallbackIDTypeDef  CallbackID,
pHASH_CallbackTypeDef  pCallback 
)

Register a User HASH Callback To be used instead of the weak (surcharged) predefined callback.

Parameters
hhashHASH handle
CallbackIDID of the callback to be registered This parameter can be one of the following values:
pCallbackpointer to the Callback function
Return values
status

Definition at line 550 of file stm32l4xx_hal_hash.c.

551 {
552  HAL_StatusTypeDef status = HAL_OK;
553 
554  if(pCallback == NULL)
555  {
556  /* Update the error code */
557  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
558  return HAL_ERROR;
559  }
560  /* Process locked */
561  __HAL_LOCK(hhash);
562 
563  if(HAL_HASH_STATE_READY == hhash->State)
564  {
565  switch (CallbackID)
566  {
568  hhash->InCpltCallback = pCallback;
569  break;
570 
572  hhash->DgstCpltCallback = pCallback;
573  break;
574 
575  case HAL_HASH_ERROR_CB_ID :
576  hhash->ErrorCallback = pCallback;
577  break;
578 
580  hhash->MspInitCallback = pCallback;
581  break;
582 
584  hhash->MspDeInitCallback = pCallback;
585  break;
586 
587  default :
588  /* Update the error code */
589  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
590  /* update return status */
591  status = HAL_ERROR;
592  break;
593  }
594  }
595  else if(HAL_HASH_STATE_RESET == hhash->State)
596  {
597  switch (CallbackID)
598  {
600  hhash->MspInitCallback = pCallback;
601  break;
602 
604  hhash->MspDeInitCallback = pCallback;
605  break;
606 
607  default :
608  /* Update the error code */
609  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
610  /* update return status */
611  status = HAL_ERROR;
612  break;
613  }
614  }
615  else
616  {
617  /* Update the error code */
618  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
619  /* update return status */
620  status = HAL_ERROR;
621  }
622 
623  /* Release Lock */
624  __HAL_UNLOCK(hhash);
625  return status;
626 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK

◆ HAL_HASH_UnRegisterCallback()

HAL_StatusTypeDef HAL_HASH_UnRegisterCallback ( HASH_HandleTypeDef hhash,
HAL_HASH_CallbackIDTypeDef  CallbackID 
)

Unregister a HASH Callback HASH Callback is redirected to the weak (surcharged) predefined callback.

Parameters
hhashHASH handle
CallbackIDID of the callback to be unregistered This parameter can be one of the following values:
Return values
status

Definition at line 641 of file stm32l4xx_hal_hash.c.

642 {
643 HAL_StatusTypeDef status = HAL_OK;
644 
645  /* Process locked */
646  __HAL_LOCK(hhash);
647 
648  if(HAL_HASH_STATE_READY == hhash->State)
649  {
650  switch (CallbackID)
651  {
653  hhash->InCpltCallback = HAL_HASH_InCpltCallback; /* Legacy weak (surcharged) input completion callback */
654  break;
655 
657  hhash->DgstCpltCallback = HAL_HASH_DgstCpltCallback; /* Legacy weak (surcharged) digest computation completion callback */
658  break;
659 
660  case HAL_HASH_ERROR_CB_ID :
661  hhash->ErrorCallback = HAL_HASH_ErrorCallback; /* Legacy weak (surcharged) error callback */
662  break;
663 
665  hhash->MspInitCallback = HAL_HASH_MspInit; /* Legacy weak (surcharged) Msp Init */
666  break;
667 
669  hhash->MspDeInitCallback = HAL_HASH_MspDeInit; /* Legacy weak (surcharged) Msp DeInit */
670  break;
671 
672  default :
673  /* Update the error code */
674  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
675  /* update return status */
676  status = HAL_ERROR;
677  break;
678  }
679  }
680  else if(HAL_HASH_STATE_RESET == hhash->State)
681  {
682  switch (CallbackID)
683  {
685  hhash->MspInitCallback = HAL_HASH_MspInit; /* Legacy weak (surcharged) Msp Init */
686  break;
687 
689  hhash->MspDeInitCallback = HAL_HASH_MspDeInit; /* Legacy weak (surcharged) Msp DeInit */
690  break;
691 
692  default :
693  /* Update the error code */
694  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
695  /* update return status */
696  status = HAL_ERROR;
697  break;
698  }
699  }
700  else
701  {
702  /* Update the error code */
703  hhash->ErrorCode |= HAL_HASH_ERROR_INVALID_CALLBACK;
704  /* update return status */
705  status = HAL_ERROR;
706  }
707 
708  /* Release Lock */
709  __HAL_UNLOCK(hhash);
710  return status;
711 }
void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash)
Initialize the HASH MSP.
void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash)
DeInitialize the HASH MSP.
void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash)
Input data transfer complete call back.
void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash)
Digest computation complete call back.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash)
Error callback.