1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_ll_pka.c 4 * @author MCD Application Team 5 * @brief PKA LL module driver. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2019 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 #if defined(USE_FULL_LL_DRIVER) 19 20 /* Includes ------------------------------------------------------------------*/ 21 #include "stm32l5xx_ll_pka.h" 22 #include "stm32l5xx_ll_bus.h" 23 24 #ifdef USE_FULL_ASSERT 25 #include "stm32_assert.h" 26 #else 27 #define assert_param(expr) ((void)0U) 28 #endif /* USE_FULL_ASSERT */ 29 30 /** @addtogroup STM32L5xx_LL_Driver 31 * @{ 32 */ 33 34 #if defined(PKA) 35 36 /** @addtogroup PKA_LL 37 * @{ 38 */ 39 40 /* Private types -------------------------------------------------------------*/ 41 /* Private variables ---------------------------------------------------------*/ 42 /* Private constants ---------------------------------------------------------*/ 43 /* Private macros ------------------------------------------------------------*/ 44 /** @defgroup PKA_LL_Private_Macros PKA Private Constants 45 * @{ 46 */ 47 #define IS_LL_PKA_MODE(__VALUE__) (((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP) ||\ 48 ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM) ||\ 49 ((__VALUE__) == LL_PKA_MODE_MODULAR_EXP) ||\ 50 ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_PARAM_ECC) ||\ 51 ((__VALUE__) == LL_PKA_MODE_ECC_KP_PRIMITIVE) ||\ 52 ((__VALUE__) == LL_PKA_MODE_ECDSA_SIGNATURE) ||\ 53 ((__VALUE__) == LL_PKA_MODE_ECDSA_VERIFICATION) ||\ 54 ((__VALUE__) == LL_PKA_MODE_POINT_CHECK) ||\ 55 ((__VALUE__) == LL_PKA_MODE_RSA_CRT_EXP) ||\ 56 ((__VALUE__) == LL_PKA_MODE_MODULAR_INV) ||\ 57 ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_ADD) ||\ 58 ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_SUB) ||\ 59 ((__VALUE__) == LL_PKA_MODE_ARITHMETIC_MUL) ||\ 60 ((__VALUE__) == LL_PKA_MODE_COMPARISON) ||\ 61 ((__VALUE__) == LL_PKA_MODE_MODULAR_REDUC) ||\ 62 ((__VALUE__) == LL_PKA_MODE_MODULAR_ADD) ||\ 63 ((__VALUE__) == LL_PKA_MODE_MODULAR_SUB) ||\ 64 ((__VALUE__) == LL_PKA_MODE_MONTGOMERY_MUL)) 65 /** 66 * @} 67 */ 68 69 /* Private function prototypes -----------------------------------------------*/ 70 71 /* Exported functions --------------------------------------------------------*/ 72 /** @addtogroup PKA_LL_Exported_Functions 73 * @{ 74 */ 75 76 /** @addtogroup PKA_LL_EF_Init 77 * @{ 78 */ 79 80 /** 81 * @brief De-initialize PKA registers (Registers restored to their default values). 82 * @param PKAx PKA Instance. 83 * @retval ErrorStatus 84 * - SUCCESS: PKA registers are de-initialized 85 * - ERROR: PKA registers are not de-initialized 86 */ LL_PKA_DeInit(PKA_TypeDef * PKAx)87ErrorStatus LL_PKA_DeInit(PKA_TypeDef *PKAx) 88 { 89 ErrorStatus status = SUCCESS; 90 91 /* Check the parameters */ 92 assert_param(IS_PKA_ALL_INSTANCE(PKAx)); 93 94 if (PKAx == PKA) 95 { 96 /* Force PKA reset */ 97 LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_PKA); 98 99 /* Release PKA reset */ 100 LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_PKA); 101 } 102 else 103 { 104 status = ERROR; 105 } 106 107 return (status); 108 } 109 110 /** 111 * @brief Initialize PKA registers according to the specified parameters in PKA_InitStruct. 112 * @param PKAx PKA Instance. 113 * @param PKA_InitStruct pointer to a @ref LL_PKA_InitTypeDef structure 114 * that contains the configuration information for the specified PKA peripheral. 115 * @retval ErrorStatus 116 * - SUCCESS: PKA registers are initialized according to PKA_InitStruct content 117 * - ERROR: Not applicable 118 */ LL_PKA_Init(PKA_TypeDef * PKAx,LL_PKA_InitTypeDef * PKA_InitStruct)119ErrorStatus LL_PKA_Init(PKA_TypeDef *PKAx, LL_PKA_InitTypeDef *PKA_InitStruct) 120 { 121 assert_param(IS_PKA_ALL_INSTANCE(PKAx)); 122 assert_param(IS_LL_PKA_MODE(PKA_InitStruct->Mode)); 123 124 LL_PKA_Config(PKAx, PKA_InitStruct->Mode); 125 126 return (SUCCESS); 127 } 128 129 /** 130 * @brief Set each @ref LL_PKA_InitTypeDef field to default value. 131 * @param PKA_InitStruct pointer to a @ref LL_PKA_InitTypeDef structure 132 * whose fields will be set to default values. 133 * @retval None 134 */ 135 LL_PKA_StructInit(LL_PKA_InitTypeDef * PKA_InitStruct)136void LL_PKA_StructInit(LL_PKA_InitTypeDef *PKA_InitStruct) 137 { 138 /* Reset PKA init structure parameters values */ 139 PKA_InitStruct->Mode = LL_PKA_MODE_MONTGOMERY_PARAM_MOD_EXP; 140 } 141 142 /** 143 * @} 144 */ 145 146 /** 147 * @} 148 */ 149 150 /** 151 * @} 152 */ 153 154 #endif /* defined (PKA) */ 155 156 /** 157 * @} 158 */ 159 160 #endif /* USE_FULL_LL_DRIVER */ 161