STM32L443xx HAL User Manual
stm32l4xx_ll_pka.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32l4xx_ll_pka.c
00004   * @author  MCD Application Team
00005   * @brief   PKA LL module driver.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 #if defined(USE_FULL_LL_DRIVER)
00019 
00020 /* Includes ------------------------------------------------------------------*/
00021 #include "stm32l4xx_ll_pka.h"
00022 #include "stm32l4xx_ll_bus.h"
00023 
00024 #ifdef  USE_FULL_ASSERT
00025 #include "stm32_assert.h"
00026 #else
00027 #define assert_param(expr) ((void)0U)
00028 #endif /* USE_FULL_ASSERT */
00029 
00030 /** @addtogroup STM32L4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined(PKA)
00035 
00036 /** @addtogroup PKA_LL
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 /* Private constants ---------------------------------------------------------*/
00043 /* Private macros ------------------------------------------------------------*/
00044 /** @defgroup PKA_LL_Private_Macros PKA Private Constants
00045   * @{
00046   */
00047 #define IS_LL_PKA_MODE(__VALUE__)     (((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP) ||\
00048                                        ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM)          ||\
00049                                        ((__VALUE__) == LL_PKA_MODE_MODULAR_EXP)               ||\
00050                                        ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM_ECC)      ||\
00051                                        ((__VALUE__) == LL_PKA_MODE_ECC_KP_PRIMITIVE)          ||\
00052                                        ((__VALUE__) == LL_PKA_MODE_ECDSA_SIGNATURE)           ||\
00053                                        ((__VALUE__) == LL_PKA_MODE_ECDSA_VERIFICATION)        ||\
00054                                        ((__VALUE__) == LL_PKA_MODE_POINT_CHECK)               ||\
00055                                        ((__VALUE__) == LL_PKA_MODE_RSA_CRT_EXP)               ||\
00056                                        ((__VALUE__) == LL_PKA_MODE_MODULAR_INV)               ||\
00057                                        ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_ADD)            ||\
00058                                        ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_SUB)            ||\
00059                                        ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_MUL)            ||\
00060                                        ((__VALUE__) == LL_PKA_MODE_COMPARISON)                ||\
00061                                        ((__VALUE__) == LL_PKA_MODE_MODULAR_REDUC)             ||\
00062                                        ((__VALUE__) == LL_PKA_MODE_MODULAR_ADD)               ||\
00063                                        ((__VALUE__) == LL_PKA_MODE_MODULAR_SUB)               ||\
00064                                        ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_MUL))
00065 /**
00066   * @}
00067   */
00068 
00069 /* Private function prototypes -----------------------------------------------*/
00070 
00071 /* Exported functions --------------------------------------------------------*/
00072 /** @addtogroup PKA_LL_Exported_Functions
00073   * @{
00074   */
00075 
00076 /** @addtogroup PKA_LL_EF_Init
00077   * @{
00078   */
00079 
00080 /**
00081   * @brief  De-initialize PKA registers (Registers restored to their default values).
00082   * @param  PKAx PKA Instance.
00083   * @retval ErrorStatus
00084   *          - SUCCESS: PKA registers are de-initialized
00085   *          - ERROR: PKA registers are not de-initialized
00086   */
00087 ErrorStatus LL_PKA_DeInit(PKA_TypeDef *PKAx)
00088 {
00089   ErrorStatus status = SUCCESS;
00090 
00091   /* Check the parameters */
00092   assert_param(IS_PKA_ALL_INSTANCE(PKAx));
00093 
00094   if (PKAx == PKA)
00095   {
00096     /* Force PKA reset */
00097     LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_PKA);
00098 
00099     /* Release PKA reset */
00100     LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_PKA);
00101   }
00102   else
00103   {
00104     status = ERROR;
00105   }
00106 
00107   return (status);
00108 }
00109 
00110 /**
00111   * @brief  Initialize PKA registers according to the specified parameters in PKA_InitStruct.
00112   * @param  PKAx PKA Instance.
00113   * @param  PKA_InitStruct pointer to a @ref LL_PKA_InitTypeDef structure
00114   *         that contains the configuration information for the specified PKA peripheral.
00115   * @retval ErrorStatus
00116   *          - SUCCESS: PKA registers are initialized according to PKA_InitStruct content
00117   *          - ERROR:   Not applicable
00118   */
00119 ErrorStatus LL_PKA_Init(PKA_TypeDef *PKAx, LL_PKA_InitTypeDef *PKA_InitStruct)
00120 {
00121   assert_param(IS_PKA_ALL_INSTANCE(PKAx));
00122   assert_param(IS_LL_PKA_MODE(PKA_InitStruct->Mode));
00123 
00124   LL_PKA_Config(PKAx, PKA_InitStruct->Mode);
00125 
00126   return (SUCCESS);
00127 }
00128 
00129 /**
00130   * @brief Set each @ref LL_PKA_InitTypeDef field to default value.
00131   * @param PKA_InitStruct pointer to a @ref LL_PKA_InitTypeDef structure
00132   *                       whose fields will be set to default values.
00133   * @retval None
00134   */
00135 
00136 void LL_PKA_StructInit(LL_PKA_InitTypeDef *PKA_InitStruct)
00137 {
00138   /* Reset PKA init structure parameters values */
00139   PKA_InitStruct->Mode       = LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP;
00140 }
00141 
00142 /**
00143   * @}
00144   */
00145 
00146 /**
00147   * @}
00148   */
00149 
00150 /**
00151   * @}
00152   */
00153 
00154 #endif /* defined (PKA) */
00155 
00156 /**
00157   * @}
00158   */
00159 
00160 #endif /* USE_FULL_LL_DRIVER */