Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 56 | Rev 77 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32l1xx_hal_cryp.h |
3 | * @file stm32l1xx_hal_cryp.h |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of CRYP HAL module. |
5 | * @brief Header file of CRYP HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
9 | * Copyright (c) 2017 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
16 | * |
16 | ****************************************************************************** |
17 | ****************************************************************************** |
17 | */ |
18 | */ |
18 | |
19 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | #ifndef __STM32L1xx_HAL_CRYP_H |
21 | #ifndef __STM32L1xx_HAL_CRYP_H |
21 | #define __STM32L1xx_HAL_CRYP_H |
22 | #define __STM32L1xx_HAL_CRYP_H |
22 | |
23 | 23 | #ifdef __cplusplus |
|
24 | #ifdef __cplusplus |
24 | extern "C" { |
25 | extern "C" { |
25 | #endif |
26 | #endif |
26 | |
27 | 27 | #if defined(STM32L162xC) || defined(STM32L162xCA) || defined(STM32L162xD) || defined(STM32L162xE) || defined(STM32L162xDX) |
|
28 | #if defined(STM32L162xC) || defined(STM32L162xCA) || defined(STM32L162xD) || defined(STM32L162xE) || defined(STM32L162xDX) |
28 | |
29 | 29 | /* Includes ------------------------------------------------------------------*/ |
|
30 | /* Includes ------------------------------------------------------------------*/ |
30 | #include "stm32l1xx_hal_def.h" |
31 | #include "stm32l1xx_hal_def.h" |
31 | |
32 | 32 | /** @addtogroup STM32L1xx_HAL_Driver |
|
33 | /** @addtogroup STM32L1xx_HAL_Driver |
33 | * @{ |
34 | * @{ |
34 | */ |
35 | */ |
35 | |
36 | 36 | /** @addtogroup CRYP |
|
37 | /** @addtogroup CRYP |
37 | * @{ |
38 | * @{ |
38 | */ |
39 | */ |
39 | |
40 | 40 | /* Exported types ------------------------------------------------------------*/ |
|
41 | /* Exported types ------------------------------------------------------------*/ |
41 | |
42 | 42 | /** @defgroup CRYP_Exported_Types CRYP Exported Types |
|
43 | /** @defgroup CRYP_Exported_Types CRYP Exported Types |
43 | * @{ |
44 | * @{ |
44 | */ |
45 | */ |
45 | |
46 | 46 | /** |
|
47 | /** |
47 | * @brief CRYP Configuration Structure definition |
48 | * @brief CRYP Configuration Structure definition |
48 | */ |
49 | */ |
49 | typedef struct |
50 | typedef struct |
50 | { |
51 | { |
51 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
52 | uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string. |
52 | This parameter can be a value of @ref CRYP_Data_Type */ |
53 | This parameter can be a value of @ref CRYP_Data_Type */ |
53 | |
54 | 54 | uint8_t* pKey; /*!< The key used for encryption/decryption */ |
|
55 | uint8_t* pKey; /*!< The key used for encryption/decryption */ |
55 | |
56 | 56 | uint8_t* pInitVect; /*!< The initialization vector used also as initialization |
|
57 | uint8_t* pInitVect; /*!< The initialization vector used also as initialization |
57 | counter in CTR mode */ |
58 | counter in CTR mode */ |
58 | |
59 | 59 | }CRYP_InitTypeDef; |
|
60 | }CRYP_InitTypeDef; |
60 | |
61 | 61 | /** |
|
62 | /** |
62 | * @brief HAL CRYP State structures definition |
63 | * @brief HAL CRYP State structures definition |
63 | */ |
64 | */ |
64 | typedef enum |
65 | typedef enum |
65 | { |
66 | { |
66 | HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ |
67 | HAL_CRYP_STATE_RESET = 0x00, /*!< CRYP not yet initialized or disabled */ |
67 | HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ |
68 | HAL_CRYP_STATE_READY = 0x01, /*!< CRYP initialized and ready for use */ |
68 | HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ |
69 | HAL_CRYP_STATE_BUSY = 0x02, /*!< CRYP internal processing is ongoing */ |
69 | HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ |
70 | HAL_CRYP_STATE_TIMEOUT = 0x03, /*!< CRYP timeout state */ |
70 | HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ |
71 | HAL_CRYP_STATE_ERROR = 0x04 /*!< CRYP error state */ |
71 | |
72 | 72 | }HAL_CRYP_STATETypeDef; |
|
73 | }HAL_CRYP_STATETypeDef; |
73 | |
74 | 74 | /** |
|
75 | /** |
75 | * @brief HAL CRYP phase structures definition |
76 | * @brief HAL CRYP phase structures definition |
76 | */ |
77 | */ |
77 | typedef enum |
78 | typedef enum |
78 | { |
79 | { |
79 | HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ |
80 | HAL_CRYP_PHASE_READY = 0x01, /*!< CRYP peripheral is ready for initialization. */ |
80 | HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */ |
81 | HAL_CRYP_PHASE_PROCESS = 0x02, /*!< CRYP peripheral is in processing phase */ |
81 | }HAL_PhaseTypeDef; |
82 | }HAL_PhaseTypeDef; |
82 | |
83 | 83 | /** |
|
84 | /** |
84 | * @brief CRYP handle Structure definition |
85 | * @brief CRYP handle Structure definition |
85 | */ |
86 | */ |
86 | typedef struct |
87 | typedef struct |
87 | { |
88 | { |
88 | AES_TypeDef *Instance; /*!< Register base address */ |
89 | AES_TypeDef *Instance; /*!< Register base address */ |
89 | |
90 | 90 | CRYP_InitTypeDef Init; /*!< CRYP required parameters */ |
|
91 | CRYP_InitTypeDef Init; /*!< CRYP required parameters */ |
91 | |
92 | 92 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
|
93 | uint8_t *pCrypInBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
93 | |
94 | 94 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
|
95 | uint8_t *pCrypOutBuffPtr; /*!< Pointer to CRYP processing (encryption, decryption,...) buffer */ |
95 | |
96 | 96 | __IO uint16_t CrypInCount; /*!< Counter of inputted data */ |
|
97 | __IO uint16_t CrypInCount; /*!< Counter of inputed data */ |
97 | |
98 | 98 | __IO uint16_t CrypOutCount; /*!< Counter of outputted data */ |
|
99 | __IO uint16_t CrypOutCount; /*!< Counter of outputed data */ |
99 | |
100 | 100 | HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ |
|
101 | HAL_StatusTypeDef Status; /*!< CRYP peripheral status */ |
101 | |
102 | 102 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ |
|
103 | HAL_PhaseTypeDef Phase; /*!< CRYP peripheral phase */ |
103 | |
104 | 104 | DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ |
|
105 | DMA_HandleTypeDef *hdmain; /*!< CRYP In DMA handle parameters */ |
105 | |
106 | 106 | DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ |
|
107 | DMA_HandleTypeDef *hdmaout; /*!< CRYP Out DMA handle parameters */ |
107 | |
108 | 108 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
|
109 | HAL_LockTypeDef Lock; /*!< CRYP locking object */ |
109 | |
110 | 110 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
|
111 | __IO HAL_CRYP_STATETypeDef State; /*!< CRYP peripheral state */ |
111 | |
112 | 112 | }CRYP_HandleTypeDef; |
|
113 | }CRYP_HandleTypeDef; |
113 | |
114 | 114 | /** |
|
115 | /** |
115 | * @} |
116 | * @} |
116 | */ |
117 | */ |
117 | |
118 | 118 | /* Exported constants --------------------------------------------------------*/ |
|
119 | /* Exported constants --------------------------------------------------------*/ |
119 | |
120 | 120 | /** @defgroup CRYP_Exported_Constants CRYP Exported Constants |
|
121 | /** @defgroup CRYP_Exported_Constants CRYP Exported Constants |
121 | * @{ |
122 | * @{ |
122 | */ |
123 | */ |
123 | |
124 | 124 | /** @defgroup CRYP_Data_Type CRYP Data Type |
|
125 | /** @defgroup CRYP_Data_Type CRYP Data Type |
125 | * @{ |
126 | * @{ |
126 | */ |
127 | */ |
127 | #define CRYP_DATATYPE_32B (0x00000000U) |
128 | #define CRYP_DATATYPE_32B (0x00000000U) |
128 | #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 |
129 | #define CRYP_DATATYPE_16B AES_CR_DATATYPE_0 |
129 | #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 |
130 | #define CRYP_DATATYPE_8B AES_CR_DATATYPE_1 |
130 | #define CRYP_DATATYPE_1B AES_CR_DATATYPE |
131 | #define CRYP_DATATYPE_1B AES_CR_DATATYPE |
131 | |
132 | 132 | #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DATATYPE_32B) || \ |
|
133 | #define IS_CRYP_DATATYPE(DATATYPE) (((DATATYPE) == CRYP_DATATYPE_32B) || \ |
133 | ((DATATYPE) == CRYP_DATATYPE_16B) || \ |
134 | ((DATATYPE) == CRYP_DATATYPE_16B) || \ |
134 | ((DATATYPE) == CRYP_DATATYPE_8B) || \ |
135 | ((DATATYPE) == CRYP_DATATYPE_8B) || \ |
135 | ((DATATYPE) == CRYP_DATATYPE_1B)) |
136 | ((DATATYPE) == CRYP_DATATYPE_1B)) |
136 | /** |
137 | /** |
137 | * @} |
138 | * @} |
138 | */ |
139 | */ |
139 | |
140 | 140 | /** @defgroup CRYP_AlgoModeDirection CRYP Algo Mode Direction |
|
141 | /** @defgroup CRYP_AlgoModeDirection CRYP Algo Mode Direction |
141 | * @{ |
142 | * @{ |
142 | */ |
143 | */ |
143 | #define CRYP_CR_ALGOMODE_DIRECTION (uint32_t)(AES_CR_MODE|AES_CR_CHMOD) |
144 | #define CRYP_CR_ALGOMODE_DIRECTION (uint32_t)(AES_CR_MODE|AES_CR_CHMOD) |
144 | |
145 | 145 | #define CRYP_CR_ALGOMODE_AES_ECB_ENCRYPT (0x00000000U) |
|
146 | #define CRYP_CR_ALGOMODE_AES_ECB_ENCRYPT (0x00000000U) |
146 | #define CRYP_CR_ALGOMODE_AES_ECB_KEYDERDECRYPT (AES_CR_MODE) |
147 | #define CRYP_CR_ALGOMODE_AES_ECB_KEYDERDECRYPT (AES_CR_MODE) |
147 | #define CRYP_CR_ALGOMODE_AES_CBC_ENCRYPT (AES_CR_CHMOD_0) |
148 | #define CRYP_CR_ALGOMODE_AES_CBC_ENCRYPT (AES_CR_CHMOD_0) |
148 | #define CRYP_CR_ALGOMODE_AES_CBC_KEYDERDECRYPT ((uint32_t)(AES_CR_CHMOD_0|AES_CR_MODE)) |
149 | #define CRYP_CR_ALGOMODE_AES_CBC_KEYDERDECRYPT ((uint32_t)(AES_CR_CHMOD_0|AES_CR_MODE)) |
149 | #define CRYP_CR_ALGOMODE_AES_CTR_ENCRYPT (AES_CR_CHMOD_1) |
150 | #define CRYP_CR_ALGOMODE_AES_CTR_ENCRYPT (AES_CR_CHMOD_1) |
150 | #define CRYP_CR_ALGOMODE_AES_CTR_DECRYPT ((uint32_t)(AES_CR_CHMOD_1 | AES_CR_MODE_1)) |
151 | #define CRYP_CR_ALGOMODE_AES_CTR_DECRYPT ((uint32_t)(AES_CR_CHMOD_1 | AES_CR_MODE_1)) |
151 | /** |
152 | /** |
152 | * @} |
153 | * @} |
153 | */ |
154 | */ |
154 | |
155 | 155 | /** @defgroup CRYP_AES_Interrupts AES Interrupts |
|
156 | /** @defgroup CRYP_AES_Interrupts AES Interrupts |
156 | * @{ |
157 | * @{ |
157 | */ |
158 | */ |
158 | #define CRYP_IT_CC AES_CR_CCIE /*!< Computation Complete interrupt */ |
159 | #define CRYP_IT_CC AES_CR_CCIE /*!< Computation Complete interrupt */ |
159 | #define CRYP_IT_ERR AES_CR_ERRIE /*!< Error interrupt */ |
160 | #define CRYP_IT_ERR AES_CR_ERRIE /*!< Error interrupt */ |
160 | |
161 | 161 | /** |
|
162 | /** |
162 | * @} |
163 | * @} |
163 | */ |
164 | */ |
164 | |
165 | 165 | ||
166 | 166 | /** @defgroup CRYP_AES_Flags AES Flags |
|
167 | /** @defgroup CRYP_AES_Flags AES Flags |
167 | * @{ |
168 | * @{ |
168 | */ |
169 | */ |
169 | #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation Complete Flag */ |
170 | #define CRYP_FLAG_CCF AES_SR_CCF /*!< Computation Complete Flag */ |
170 | #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read Error Flag */ |
171 | #define CRYP_FLAG_RDERR AES_SR_RDERR /*!< Read Error Flag */ |
171 | #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error Flag */ |
172 | #define CRYP_FLAG_WRERR AES_SR_WRERR /*!< Write Error Flag */ |
172 | |
173 | 173 | /** |
|
174 | /** |
174 | * @} |
175 | * @} |
175 | */ |
176 | */ |
176 | |
177 | 177 | /** @defgroup CRYP_AES_Clear_Flags AES Clear Flags |
|
178 | /** @defgroup CRYP_AES_Clear_Flags AES Clear Flags |
178 | * @{ |
179 | * @{ |
179 | */ |
180 | */ |
180 | #define CRYP_CLEARFLAG_CCF AES_CR_CCFC /*!< Computation Complete Flag Clear */ |
181 | #define CRYP_CLEARFLAG_CCF AES_CR_CCFC /*!< Computation Complete Flag Clear */ |
181 | #define CRYP_CLEARFLAG_RDERR AES_CR_ERRC /*!< Read Error Clear */ |
182 | #define CRYP_CLEARFLAG_RDERR AES_CR_ERRC /*!< Read Error Clear */ |
182 | #define CRYP_CLEARFLAG_WRERR AES_CR_ERRC /*!< Write Error Clear */ |
183 | #define CRYP_CLEARFLAG_WRERR AES_CR_ERRC /*!< Write Error Clear */ |
183 | |
184 | 184 | /** |
|
185 | /** |
185 | * @} |
186 | * @} |
186 | */ |
187 | */ |
187 | |
188 | 188 | /** |
|
189 | /** |
189 | * @} |
190 | * @} |
190 | */ |
191 | */ |
191 | |
192 | 192 | /* Exported macro ------------------------------------------------------------*/ |
|
193 | /* Exported macro ------------------------------------------------------------*/ |
193 | |
194 | 194 | /** @defgroup CRYP_Exported_Macros CRYP Exported Macros |
|
195 | /** @defgroup CRYP_Exported_Macros CRYP Exported Macros |
195 | * @{ |
196 | * @{ |
196 | */ |
197 | */ |
197 | |
198 | 198 | /** @brief Reset CRYP handle state |
|
199 | /** @brief Reset CRYP handle state |
199 | * @param __HANDLE__ specifies the CRYP handle. |
200 | * @param __HANDLE__ specifies the CRYP handle. |
200 | * @retval None |
201 | * @retval None |
201 | */ |
202 | */ |
202 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
203 | #define __HAL_CRYP_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRYP_STATE_RESET) |
203 | |
204 | 204 | /** |
|
205 | /** |
205 | * @brief Enable/Disable the CRYP peripheral. |
206 | * @brief Enable/Disable the CRYP peripheral. |
206 | * @param __HANDLE__ specifies the CRYP handle. |
207 | * @param __HANDLE__ specifies the CRYP handle. |
207 | * @retval None |
208 | * @retval None |
208 | */ |
209 | */ |
209 | #define __HAL_CRYP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, AES_CR_EN) |
210 | #define __HAL_CRYP_ENABLE(__HANDLE__) SET_BIT((__HANDLE__)->Instance->CR, AES_CR_EN) |
210 | #define __HAL_CRYP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, AES_CR_EN) |
211 | #define __HAL_CRYP_DISABLE(__HANDLE__) CLEAR_BIT((__HANDLE__)->Instance->CR, AES_CR_EN) |
211 | |
212 | 212 | /** |
|
213 | /** |
213 | * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC,... |
214 | * @brief Set the algorithm mode: AES-ECB, AES-CBC, AES-CTR, DES-ECB, DES-CBC,... |
214 | * @param __HANDLE__ specifies the CRYP handle. |
215 | * @param __HANDLE__ specifies the CRYP handle. |
215 | * @param __MODE__ The algorithm mode. |
216 | * @param __MODE__ The algorithm mode. |
216 | * @retval None |
217 | * @retval None |
217 | */ |
218 | */ |
218 | #define __HAL_CRYP_SET_MODE(__HANDLE__,__MODE__) SET_BIT((__HANDLE__)->Instance->CR, (__MODE__)) |
219 | #define __HAL_CRYP_SET_MODE(__HANDLE__,__MODE__) SET_BIT((__HANDLE__)->Instance->CR, (__MODE__)) |
219 | |
220 | 220 | ||
221 | 221 | /** @brief Check whether the specified CRYP flag is set or not. |
|
222 | /** @brief Check whether the specified CRYP flag is set or not. |
222 | * @param __HANDLE__ specifies the CRYP handle. |
223 | * @param __HANDLE__ specifies the CRYP handle. |
223 | * @param __FLAG__ specifies the flag to check. |
224 | * @param __FLAG__ specifies the flag to check. |
224 | * This parameter can be one of the following values: |
225 | * This parameter can be one of the following values: |
225 | * @arg CRYP_FLAG_CCF : Computation Complete Flag |
226 | * @arg CRYP_FLAG_CCF : Computation Complete Flag |
226 | * @arg CRYP_FLAG_RDERR : Read Error Flag |
227 | * @arg CRYP_FLAG_RDERR : Read Error Flag |
227 | * @arg CRYP_FLAG_WRERR : Write Error Flag |
228 | * @arg CRYP_FLAG_WRERR : Write Error Flag |
228 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
229 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
229 | */ |
230 | */ |
230 | #define __HAL_CRYP_GET_FLAG(__HANDLE__,__FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
231 | #define __HAL_CRYP_GET_FLAG(__HANDLE__,__FLAG__) (((__HANDLE__)->Instance->SR & (__FLAG__)) == (__FLAG__)) |
231 | |
232 | 232 | /** @brief Clear the CRYP pending flag. |
|
233 | /** @brief Clear the CRYP pending flag. |
233 | * @param __HANDLE__ specifies the CRYP handle. |
234 | * @param __HANDLE__ specifies the CRYP handle. |
234 | * @param __FLAG__ specifies the flag to clear. |
235 | * @param __FLAG__ specifies the flag to clear. |
235 | * This parameter can be one of the following values: |
236 | * This parameter can be one of the following values: |
236 | * @arg CRYP_CLEARFLAG_CCF : Computation Complete Clear Flag |
237 | * @arg CRYP_CLEARFLAG_CCF : Computation Complete Clear Flag |
237 | * @arg CRYP_CLEARFLAG_RDERR : Read Error Clear |
238 | * @arg CRYP_CLEARFLAG_RDERR : Read Error Clear |
238 | * @arg CRYP_CLEARFLAG_WRERR : Write Error Clear |
239 | * @arg CRYP_CLEARFLAG_WRERR : Write Error Clear |
239 | * @retval None |
240 | * @retval None |
240 | */ |
241 | */ |
241 | #define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__)) |
242 | #define __HAL_CRYP_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BIT((__HANDLE__)->Instance->CR, (__FLAG__)) |
242 | |
243 | 243 | /** |
|
244 | /** |
244 | * @brief Enable the CRYP interrupt. |
245 | * @brief Enable the CRYP interrupt. |
245 | * @param __HANDLE__ specifies the CRYP handle. |
246 | * @param __HANDLE__ specifies the CRYP handle. |
246 | * @param __INTERRUPT__ CRYP Interrupt. |
247 | * @param __INTERRUPT__ CRYP Interrupt. |
247 | * @retval None |
248 | * @retval None |
248 | */ |
249 | */ |
249 | #define __HAL_CRYP_ENABLE_IT(__HANDLE__,__INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) |
250 | #define __HAL_CRYP_ENABLE_IT(__HANDLE__,__INTERRUPT__) SET_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) |
250 | |
251 | 251 | /** |
|
252 | /** |
252 | * @brief Disable the CRYP interrupt. |
253 | * @brief Disable the CRYP interrupt. |
253 | * @param __HANDLE__ specifies the CRYP handle. |
254 | * @param __HANDLE__ specifies the CRYP handle. |
254 | * @param __INTERRUPT__ CRYP interrupt. |
255 | * @param __INTERRUPT__ CRYP interrupt. |
255 | * @retval None |
256 | * @retval None |
256 | */ |
257 | */ |
257 | #define __HAL_CRYP_DISABLE_IT(__HANDLE__,__INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) |
258 | #define __HAL_CRYP_DISABLE_IT(__HANDLE__,__INTERRUPT__) CLEAR_BIT((__HANDLE__)->Instance->CR, (__INTERRUPT__)) |
258 | |
259 | 259 | /** @brief Checks if the specified CRYP interrupt source is enabled or disabled. |
|
260 | /** @brief Checks if the specified CRYP interrupt source is enabled or disabled. |
260 | * @param __HANDLE__ specifies the CRYP handle. |
261 | * @param __HANDLE__ specifies the CRYP handle. |
261 | * @param __INTERRUPT__: CRYP interrupt source to check |
262 | * @param __INTERRUPT__: CRYP interrupt source to check |
262 | * This parameter can be one of the following values: |
263 | * This parameter can be one of the following values: |
263 | * @arg CRYP_IT_CC : Computation Complete interrupt |
264 | * @arg CRYP_IT_CC : Computation Complete interrupt |
264 | * @arg CRYP_IT_ERR : Error interrupt (used for RDERR and WRERR) |
265 | * @arg CRYP_IT_ERR : Error interrupt (used for RDERR and WRERR) |
265 | * @retval State of interruption (SET or RESET) |
266 | * @retval State of interruption (SET or RESET) |
266 | */ |
267 | */ |
267 | #define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ |
268 | #define __HAL_CRYP_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \ |
268 | (( ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__) \ |
269 | (( ((__HANDLE__)->Instance->CR & (__INTERRUPT__)) == (__INTERRUPT__) \ |
269 | )? SET : RESET \ |
270 | )? SET : RESET \ |
270 | ) |
271 | ) |
271 | |
272 | 272 | /** @brief Clear the CRYP pending IT. |
|
273 | /** @brief Clear the CRYP pending IT. |
273 | * @param __HANDLE__ specifies the CRYP handle. |
274 | * @param __HANDLE__ specifies the CRYP handle. |
274 | * @param __IT__ specifies the IT to clear. |
275 | * @param __IT__ specifies the IT to clear. |
275 | * This parameter can be one of the following values: |
276 | * This parameter can be one of the following values: |
276 | * @arg CRYP_CLEARFLAG_CCF : Computation Complete Clear Flag |
277 | * @arg CRYP_CLEARFLAG_CCF : Computation Complete Clear Flag |
277 | * @arg CRYP_CLEARFLAG_RDERR : Read Error Clear |
278 | * @arg CRYP_CLEARFLAG_RDERR : Read Error Clear |
278 | * @arg CRYP_CLEARFLAG_WRERR : Write Error Clear |
279 | * @arg CRYP_CLEARFLAG_WRERR : Write Error Clear |
279 | * @retval None |
280 | * @retval None |
280 | */ |
281 | */ |
281 | #define __HAL_CRYP_CLEAR_IT(__HANDLE__, __IT__) SET_BIT((__HANDLE__)->Instance->CR, (__IT__)) |
282 | #define __HAL_CRYP_CLEAR_IT(__HANDLE__, __IT__) SET_BIT((__HANDLE__)->Instance->CR, (__IT__)) |
282 | |
283 | 283 | /** |
|
284 | /** |
284 | * @} |
285 | * @} |
285 | */ |
286 | */ |
286 | |
287 | 287 | /* Include CRYP HAL Extension module */ |
|
288 | /* Include CRYP HAL Extension module */ |
288 | #include "stm32l1xx_hal_cryp_ex.h" |
289 | #include "stm32l1xx_hal_cryp_ex.h" |
289 | |
290 | 290 | /* Exported functions --------------------------------------------------------*/ |
|
291 | /* Exported functions --------------------------------------------------------*/ |
291 | |
292 | 292 | /** @addtogroup CRYP_Exported_Functions |
|
293 | /** @addtogroup CRYP_Exported_Functions |
293 | * @{ |
294 | * @{ |
294 | */ |
295 | */ |
295 | |
296 | 296 | /** @addtogroup CRYP_Exported_Functions_Group1 |
|
297 | /** @addtogroup CRYP_Exported_Functions_Group1 |
297 | * @{ |
298 | * @{ |
298 | */ |
299 | */ |
299 | |
300 | 300 | /* Initialization/de-initialization functions *********************************/ |
|
301 | /* Initialization/de-initialization functions *********************************/ |
301 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
302 | HAL_StatusTypeDef HAL_CRYP_Init(CRYP_HandleTypeDef *hcryp); |
302 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
303 | HAL_StatusTypeDef HAL_CRYP_DeInit(CRYP_HandleTypeDef *hcryp); |
303 | |
304 | 304 | /* MSP functions *************************************************************/ |
|
305 | /* MSP functions *************************************************************/ |
305 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
306 | void HAL_CRYP_MspInit(CRYP_HandleTypeDef *hcryp); |
306 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
307 | void HAL_CRYP_MspDeInit(CRYP_HandleTypeDef *hcryp); |
307 | |
308 | 308 | /** |
|
309 | /** |
309 | * @} |
310 | * @} |
310 | */ |
311 | */ |
311 | |
312 | 312 | /** @addtogroup CRYP_Exported_Functions_Group2 |
|
313 | /** @addtogroup CRYP_Exported_Functions_Group2 |
313 | * @{ |
314 | * @{ |
314 | */ |
315 | */ |
315 | |
316 | 316 | /* AES encryption/decryption using polling ***********************************/ |
|
317 | /* AES encryption/decryption using polling ***********************************/ |
317 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
318 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
318 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
319 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
319 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
320 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
320 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
321 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
321 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
322 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData, uint32_t Timeout); |
322 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
323 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData, uint32_t Timeout); |
323 | |
324 | 324 | /* AES encryption/decryption using interrupt *********************************/ |
|
325 | /* AES encryption/decryption using interrupt *********************************/ |
325 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
326 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
326 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
327 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
327 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
328 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
328 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
329 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
329 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
330 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
330 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
331 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_IT(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
331 | |
332 | 332 | /* AES encryption/decryption using DMA ***************************************/ |
|
333 | /* AES encryption/decryption using DMA ***************************************/ |
333 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
334 | HAL_StatusTypeDef HAL_CRYP_AESECB_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
334 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
335 | HAL_StatusTypeDef HAL_CRYP_AESECB_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
335 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
336 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
336 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
337 | HAL_StatusTypeDef HAL_CRYP_AESCBC_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
337 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
338 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Encrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pPlainData, uint16_t Size, uint8_t *pCypherData); |
338 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
339 | HAL_StatusTypeDef HAL_CRYP_AESCTR_Decrypt_DMA(CRYP_HandleTypeDef *hcryp, uint8_t *pCypherData, uint16_t Size, uint8_t *pPlainData); |
339 | |
340 | 340 | /** |
|
341 | /** |
341 | * @} |
342 | * @} |
342 | */ |
343 | */ |
343 | |
344 | 344 | /** @addtogroup CRYP_Exported_Functions_Group3 |
|
345 | /** @addtogroup CRYP_Exported_Functions_Group3 |
345 | * @{ |
346 | * @{ |
346 | */ |
347 | */ |
347 | |
348 | 348 | /* CallBack functions ********************************************************/ |
|
349 | /* CallBack functions ********************************************************/ |
349 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
350 | void HAL_CRYP_InCpltCallback(CRYP_HandleTypeDef *hcryp); |
350 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
351 | void HAL_CRYP_OutCpltCallback(CRYP_HandleTypeDef *hcryp); |
351 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
352 | void HAL_CRYP_ErrorCallback(CRYP_HandleTypeDef *hcryp); |
352 | |
353 | 353 | /** |
|
354 | /** |
354 | * @} |
355 | * @} |
355 | */ |
356 | */ |
356 | |
357 | 357 | /** @addtogroup CRYP_Exported_Functions_Group4 |
|
358 | /** @addtogroup CRYP_Exported_Functions_Group4 |
358 | * @{ |
359 | * @{ |
359 | */ |
360 | */ |
360 | |
361 | 361 | /* Processing functions ********************************************************/ |
|
362 | /* Processing functions ********************************************************/ |
362 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
363 | void HAL_CRYP_IRQHandler(CRYP_HandleTypeDef *hcryp); |
363 | |
364 | 364 | /** |
|
365 | /** |
365 | * @} |
366 | * @} |
366 | */ |
367 | */ |
367 | |
368 | 368 | /** @addtogroup CRYP_Exported_Functions_Group5 |
|
369 | /** @addtogroup CRYP_Exported_Functions_Group5 |
369 | * @{ |
370 | * @{ |
370 | */ |
371 | */ |
371 | |
372 | 372 | /* Peripheral State functions **************************************************/ |
|
373 | /* Peripheral State functions **************************************************/ |
373 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
374 | HAL_CRYP_STATETypeDef HAL_CRYP_GetState(CRYP_HandleTypeDef *hcryp); |
374 | |
375 | 375 | /** |
|
376 | /** |
376 | * @} |
377 | * @} |
377 | */ |
378 | */ |
378 | |
379 | 379 | /** |
|
380 | /** |
380 | * @} |
381 | * @} |
381 | */ |
382 | */ |
382 | |
383 | 383 | /** |
|
384 | /** |
384 | * @} |
385 | * @} |
385 | */ |
386 | */ |
386 | |
387 | 387 | /** |
|
388 | /** |
388 | * @} |
389 | * @} |
389 | */ |
390 | */ |
390 | |
391 | 391 | #endif /* STM32L162xC || STM32L162xCA || STM32L162xD || STM32L162xE || STM32L162xDX*/ |
|
392 | #endif /* STM32L162xC || STM32L162xCA || STM32L162xD || STM32L162xE || STM32L162xDX*/ |
392 | |
393 | 393 | #ifdef __cplusplus |
|
394 | #ifdef __cplusplus |
394 | } |
395 | } |
395 | #endif |
396 | #endif |
396 | |
397 | 397 | #endif /* __STM32L1xx_HAL_CRYP_H */ |
|
398 | #endif /* __STM32L1xx_HAL_CRYP_H */ |
- | |
399 | - | ||
400 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |