Move telemetry displayport init and cms device registering
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_HAL_Driver / Inc / stm32f4xx_hal_hash.h
blobf52880559bc6c1b0375abeb1f462a45ab4a80503
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_hal_hash.h
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 14-April-2017
7 * @brief Header file of HASH HAL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_HASH_H
40 #define __STM32F4xx_HAL_HASH_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) || defined(STM32F479xx)
48 /* Includes ------------------------------------------------------------------*/
49 #include "stm32f4xx_hal_def.h"
51 /** @addtogroup STM32F4xx_HAL_Driver
52 * @{
55 /** @addtogroup HASH
56 * @brief HASH HAL module driver
57 * @{
58 */
60 /* Exported types ------------------------------------------------------------*/
61 /** @defgroup HASH_Exported_Types HASH Exported Types
62 * @{
65 /** @defgroup HASH_Exported_Types_Group1 HASH Configuration Structure definition
66 * @{
69 typedef struct
71 uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string.
72 This parameter can be a value of @ref HASH_Data_Type */
74 uint32_t KeySize; /*!< The key size is used only in HMAC operation */
76 uint8_t* pKey; /*!< The key is used only in HMAC operation */
77 }HASH_InitTypeDef;
79 /**
80 * @}
83 /** @defgroup HASH_Exported_Types_Group2 HASH State structures definition
84 * @{
87 typedef enum
89 HAL_HASH_STATE_RESET = 0x00U, /*!< HASH not yet initialized or disabled */
90 HAL_HASH_STATE_READY = 0x01U, /*!< HASH initialized and ready for use */
91 HAL_HASH_STATE_BUSY = 0x02U, /*!< HASH internal process is ongoing */
92 HAL_HASH_STATE_TIMEOUT = 0x03U, /*!< HASH timeout state */
93 HAL_HASH_STATE_ERROR = 0x04U /*!< HASH error state */
94 }HAL_HASH_StateTypeDef;
96 /**
97 * @}
100 /** @defgroup HASH_Exported_Types_Group3 HASH phase structures definition
101 * @{
104 typedef enum
106 HAL_HASH_PHASE_READY = 0x01U, /*!< HASH peripheral is ready for initialization */
107 HAL_HASH_PHASE_PROCESS = 0x02U /*!< HASH peripheral is in processing phase */
108 }HAL_HASH_PhaseTypeDef;
110 /**
111 * @}
114 /** @defgroup HASH_Exported_Types_Group4 HASH Handle structures definition
115 * @{
118 typedef struct
120 HASH_InitTypeDef Init; /*!< HASH required parameters */
122 uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */
124 uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */
126 __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */
128 __IO uint32_t HashInCount; /*!< Counter of inputed data */
130 __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */
132 HAL_StatusTypeDef Status; /*!< HASH peripheral status */
134 HAL_HASH_PhaseTypeDef Phase; /*!< HASH peripheral phase */
136 DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */
138 HAL_LockTypeDef Lock; /*!< HASH locking object */
140 __IO HAL_HASH_StateTypeDef State; /*!< HASH peripheral state */
141 } HASH_HandleTypeDef;
143 /**
144 * @}
149 * @}
152 /* Exported constants --------------------------------------------------------*/
153 /** @defgroup HASH_Exported_Constants HASH Exported Constants
154 * @{
157 /** @defgroup HASH_Exported_Constants_Group1 HASH Algorithm Selection
158 * @{
160 #define HASH_ALGOSELECTION_SHA1 0x00000000U /*!< HASH function is SHA1 */
161 #define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */
162 #define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */
163 #define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */
165 * @}
168 /** @defgroup HASH_Exported_Constants_Group2 HASH Algorithm Mode
169 * @{
171 #define HASH_ALGOMODE_HASH 0x00000000U /*!< Algorithm is HASH */
172 #define HASH_ALGOMODE_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */
174 * @}
177 /** @defgroup HASH_Data_Type HASH Data Type
178 * @{
180 #define HASH_DATATYPE_32B 0x00000000U /*!< 32-bit data. No swapping */
181 #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
182 #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
183 #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
185 * @}
188 /** @defgroup HASH_Exported_Constants_Group4 HASH HMAC Long key
189 * @brief HASH HMAC Long key used only for HMAC mode
190 * @{
192 #define HASH_HMAC_KEYTYPE_SHORTKEY 0x00000000U /*!< HMAC Key is <= 64 bytes */
193 #define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */
195 * @}
198 /** @defgroup HASH_Exported_Constants_Group5 HASH Flags definition
199 * @{
201 #define HASH_FLAG_DINIS HASH_SR_DINIS /*!< 16 locations are free in the DIN : A new block can be entered into the input buffer */
202 #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */
203 #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */
204 #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */
205 #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */
207 * @}
210 /** @defgroup HASH_Exported_Constants_Group6 HASH Interrupts definition
211 * @{
213 #define HASH_IT_DINI HASH_IMR_DINIE /*!< A new block can be entered into the input buffer (DIN) */
214 #define HASH_IT_DCI HASH_IMR_DCIE /*!< Digest calculation complete */
216 * @}
220 * @}
223 /* Exported macro ------------------------------------------------------------*/
224 /** @defgroup HASH_Exported_Macros HASH Exported Macros
225 * @{
228 /** @brief Reset HASH handle state
229 * @param __HANDLE__: specifies the HASH handle.
230 * @retval None
232 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
234 /** @brief Check whether the specified HASH flag is set or not.
235 * @param __FLAG__: specifies the flag to check.
236 * This parameter can be one of the following values:
237 * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer.
238 * @arg HASH_FLAG_DCIS: Digest calculation complete
239 * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing
240 * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data
241 * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data
242 * @retval The new state of __FLAG__ (TRUE or FALSE).
244 #define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
245 ((HASH->SR & (__FLAG__)) == (__FLAG__)))
248 * @brief Enable the multiple DMA mode.
249 * This feature is available only in STM32F429x and STM32F439x devices.
250 * @retval None
252 #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT
255 * @brief Disable the multiple DMA mode.
256 * @retval None
258 #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT)
261 * @brief Start the digest computation
262 * @retval None
264 #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL
267 * @brief Set the number of valid bits in last word written in Data register
268 * @param SIZE: size in byte of last data written in Data register.
269 * @retval None
271 #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBLW);\
272 HASH->STR |= 8U * ((SIZE) % 4U);\
273 }while(0)
276 * @}
279 /* Include HASH HAL Extension module */
280 #include "stm32f4xx_hal_hash_ex.h"
281 /* Exported functions --------------------------------------------------------*/
283 /** @defgroup HASH_Exported_Functions HASH Exported Functions
284 * @{
287 /** @addtogroup HASH_Exported_Functions_Group1
288 * @{
290 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
291 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
293 * @}
296 /** @addtogroup HASH_Exported_Functions_Group2
297 * @{
299 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
300 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
301 HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
302 HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
304 * @}
307 /** @addtogroup HASH_Exported_Functions_Group3
308 * @{
310 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
311 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
313 * @}
316 /** @addtogroup HASH_Exported_Functions_Group4
317 * @{
319 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
320 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
322 * @}
325 /** @addtogroup HASH_Exported_Functions_Group5
326 * @{
328 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
329 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
330 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
331 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
333 * @}
336 /** @addtogroup HASH_Exported_Functions_Group6
337 * @{
339 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
340 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
342 * @}
345 /** @addtogroup HASH_Exported_Functions_Group7
346 * @{
348 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
350 * @}
353 /** @addtogroup HASH_Exported_Functions_Group8
354 * @{
356 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
357 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
358 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
359 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
360 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
361 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
363 * @}
367 * @}
370 /* Private types -------------------------------------------------------------*/
371 /** @defgroup HASH_Private_Types HASH Private Types
372 * @{
376 * @}
379 /* Private variables ---------------------------------------------------------*/
380 /** @defgroup HASH_Private_Variables HASH Private Variables
381 * @{
385 * @}
388 /* Private constants ---------------------------------------------------------*/
389 /** @defgroup HASH_Private_Constants HASH Private Constants
390 * @{
394 * @}
397 /* Private macros ------------------------------------------------------------*/
398 /** @defgroup HASH_Private_Macros HASH Private Macros
399 * @{
401 #define IS_HASH_ALGOSELECTION(__ALGOSELECTION__) (((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA1) || \
402 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA224) || \
403 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA256) || \
404 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_MD5))
407 #define IS_HASH_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == HASH_ALGOMODE_HASH) || \
408 ((__ALGOMODE__) == HASH_ALGOMODE_HMAC))
411 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
412 ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
413 ((__DATATYPE__) == HASH_DATATYPE_8B) || \
414 ((__DATATYPE__) == HASH_DATATYPE_1B))
417 #define IS_HASH_HMAC_KEYTYPE(__KEYTYPE__) (((__KEYTYPE__) == HASH_HMAC_KEYTYPE_SHORTKEY) || \
418 ((__KEYTYPE__) == HASH_HMAC_KEYTYPE_LONGKEY))
420 #define IS_HASH_SHA1_BUFFER_SIZE(__SIZE__) ((((__SIZE__)%4U) != 0U)? 0U: 1U)
423 * @}
426 /* Private functions ---------------------------------------------------------*/
427 /** @defgroup HASH_Private_Functions HASH Private Functions
428 * @{
432 * @}
435 #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx || STM32F479xx */
437 * @}
441 * @}
444 #ifdef __cplusplus
446 #endif
449 #endif /* __STM32F4xx_HAL_HASH_H */
451 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/