You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

165 lines
5.4 KiB

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