Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sat Jun 03 00:22:44 2017 +0000
Revision:
46:b156ef445742
Parent:
18:6a4db94011d3
Final code for internal battlebot competition.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sahilmgandhi 18:6a4db94011d3 1 /**
sahilmgandhi 18:6a4db94011d3 2 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 3 * @file stm32f4xx_hal_hash.h
sahilmgandhi 18:6a4db94011d3 4 * @author MCD Application Team
sahilmgandhi 18:6a4db94011d3 5 * @version V1.5.0
sahilmgandhi 18:6a4db94011d3 6 * @date 06-May-2016
sahilmgandhi 18:6a4db94011d3 7 * @brief Header file of HASH HAL module.
sahilmgandhi 18:6a4db94011d3 8 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 9 * @attention
sahilmgandhi 18:6a4db94011d3 10 *
sahilmgandhi 18:6a4db94011d3 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
sahilmgandhi 18:6a4db94011d3 12 *
sahilmgandhi 18:6a4db94011d3 13 * Redistribution and use in source and binary forms, with or without modification,
sahilmgandhi 18:6a4db94011d3 14 * are permitted provided that the following conditions are met:
sahilmgandhi 18:6a4db94011d3 15 * 1. Redistributions of source code must retain the above copyright notice,
sahilmgandhi 18:6a4db94011d3 16 * this list of conditions and the following disclaimer.
sahilmgandhi 18:6a4db94011d3 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
sahilmgandhi 18:6a4db94011d3 18 * this list of conditions and the following disclaimer in the documentation
sahilmgandhi 18:6a4db94011d3 19 * and/or other materials provided with the distribution.
sahilmgandhi 18:6a4db94011d3 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
sahilmgandhi 18:6a4db94011d3 21 * may be used to endorse or promote products derived from this software
sahilmgandhi 18:6a4db94011d3 22 * without specific prior written permission.
sahilmgandhi 18:6a4db94011d3 23 *
sahilmgandhi 18:6a4db94011d3 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
sahilmgandhi 18:6a4db94011d3 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sahilmgandhi 18:6a4db94011d3 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
sahilmgandhi 18:6a4db94011d3 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
sahilmgandhi 18:6a4db94011d3 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sahilmgandhi 18:6a4db94011d3 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
sahilmgandhi 18:6a4db94011d3 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
sahilmgandhi 18:6a4db94011d3 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
sahilmgandhi 18:6a4db94011d3 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
sahilmgandhi 18:6a4db94011d3 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
sahilmgandhi 18:6a4db94011d3 34 *
sahilmgandhi 18:6a4db94011d3 35 ******************************************************************************
sahilmgandhi 18:6a4db94011d3 36 */
sahilmgandhi 18:6a4db94011d3 37
sahilmgandhi 18:6a4db94011d3 38 /* Define to prevent recursive inclusion -------------------------------------*/
sahilmgandhi 18:6a4db94011d3 39 #ifndef __STM32F4xx_HAL_HASH_H
sahilmgandhi 18:6a4db94011d3 40 #define __STM32F4xx_HAL_HASH_H
sahilmgandhi 18:6a4db94011d3 41
sahilmgandhi 18:6a4db94011d3 42 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 43 extern "C" {
sahilmgandhi 18:6a4db94011d3 44 #endif
sahilmgandhi 18:6a4db94011d3 45
sahilmgandhi 18:6a4db94011d3 46 #if defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F437xx) || defined(STM32F439xx) || defined(STM32F479xx)
sahilmgandhi 18:6a4db94011d3 47
sahilmgandhi 18:6a4db94011d3 48 /* Includes ------------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 49 #include "stm32f4xx_hal_def.h"
sahilmgandhi 18:6a4db94011d3 50
sahilmgandhi 18:6a4db94011d3 51 /** @addtogroup STM32F4xx_HAL_Driver
sahilmgandhi 18:6a4db94011d3 52 * @{
sahilmgandhi 18:6a4db94011d3 53 */
sahilmgandhi 18:6a4db94011d3 54
sahilmgandhi 18:6a4db94011d3 55 /** @addtogroup HASH
sahilmgandhi 18:6a4db94011d3 56 * @brief HASH HAL module driver
sahilmgandhi 18:6a4db94011d3 57 * @{
sahilmgandhi 18:6a4db94011d3 58 */
sahilmgandhi 18:6a4db94011d3 59
sahilmgandhi 18:6a4db94011d3 60 /* Exported types ------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 61 /** @defgroup HASH_Exported_Types HASH Exported Types
sahilmgandhi 18:6a4db94011d3 62 * @{
sahilmgandhi 18:6a4db94011d3 63 */
sahilmgandhi 18:6a4db94011d3 64
sahilmgandhi 18:6a4db94011d3 65 /** @defgroup HASH_Exported_Types_Group1 HASH Configuration Structure definition
sahilmgandhi 18:6a4db94011d3 66 * @{
sahilmgandhi 18:6a4db94011d3 67 */
sahilmgandhi 18:6a4db94011d3 68
sahilmgandhi 18:6a4db94011d3 69 typedef struct
sahilmgandhi 18:6a4db94011d3 70 {
sahilmgandhi 18:6a4db94011d3 71 uint32_t DataType; /*!< 32-bit data, 16-bit data, 8-bit data or 1-bit string.
sahilmgandhi 18:6a4db94011d3 72 This parameter can be a value of @ref HASH_Data_Type */
sahilmgandhi 18:6a4db94011d3 73
sahilmgandhi 18:6a4db94011d3 74 uint32_t KeySize; /*!< The key size is used only in HMAC operation */
sahilmgandhi 18:6a4db94011d3 75
sahilmgandhi 18:6a4db94011d3 76 uint8_t* pKey; /*!< The key is used only in HMAC operation */
sahilmgandhi 18:6a4db94011d3 77 }HASH_InitTypeDef;
sahilmgandhi 18:6a4db94011d3 78
sahilmgandhi 18:6a4db94011d3 79 /**
sahilmgandhi 18:6a4db94011d3 80 * @}
sahilmgandhi 18:6a4db94011d3 81 */
sahilmgandhi 18:6a4db94011d3 82
sahilmgandhi 18:6a4db94011d3 83 /** @defgroup HASH_Exported_Types_Group2 HASH State structures definition
sahilmgandhi 18:6a4db94011d3 84 * @{
sahilmgandhi 18:6a4db94011d3 85 */
sahilmgandhi 18:6a4db94011d3 86
sahilmgandhi 18:6a4db94011d3 87 typedef enum
sahilmgandhi 18:6a4db94011d3 88 {
sahilmgandhi 18:6a4db94011d3 89 HAL_HASH_STATE_RESET = 0x00U, /*!< HASH not yet initialized or disabled */
sahilmgandhi 18:6a4db94011d3 90 HAL_HASH_STATE_READY = 0x01U, /*!< HASH initialized and ready for use */
sahilmgandhi 18:6a4db94011d3 91 HAL_HASH_STATE_BUSY = 0x02U, /*!< HASH internal process is ongoing */
sahilmgandhi 18:6a4db94011d3 92 HAL_HASH_STATE_TIMEOUT = 0x03U, /*!< HASH timeout state */
sahilmgandhi 18:6a4db94011d3 93 HAL_HASH_STATE_ERROR = 0x04U /*!< HASH error state */
sahilmgandhi 18:6a4db94011d3 94 }HAL_HASH_StateTypeDef;
sahilmgandhi 18:6a4db94011d3 95
sahilmgandhi 18:6a4db94011d3 96 /**
sahilmgandhi 18:6a4db94011d3 97 * @}
sahilmgandhi 18:6a4db94011d3 98 */
sahilmgandhi 18:6a4db94011d3 99
sahilmgandhi 18:6a4db94011d3 100 /** @defgroup HASH_Exported_Types_Group3 HASH phase structures definition
sahilmgandhi 18:6a4db94011d3 101 * @{
sahilmgandhi 18:6a4db94011d3 102 */
sahilmgandhi 18:6a4db94011d3 103
sahilmgandhi 18:6a4db94011d3 104 typedef enum
sahilmgandhi 18:6a4db94011d3 105 {
sahilmgandhi 18:6a4db94011d3 106 HAL_HASH_PHASE_READY = 0x01U, /*!< HASH peripheral is ready for initialization */
sahilmgandhi 18:6a4db94011d3 107 HAL_HASH_PHASE_PROCESS = 0x02U /*!< HASH peripheral is in processing phase */
sahilmgandhi 18:6a4db94011d3 108 }HAL_HASH_PhaseTypeDef;
sahilmgandhi 18:6a4db94011d3 109
sahilmgandhi 18:6a4db94011d3 110 /**
sahilmgandhi 18:6a4db94011d3 111 * @}
sahilmgandhi 18:6a4db94011d3 112 */
sahilmgandhi 18:6a4db94011d3 113
sahilmgandhi 18:6a4db94011d3 114 /** @defgroup HASH_Exported_Types_Group4 HASH Handle structures definition
sahilmgandhi 18:6a4db94011d3 115 * @{
sahilmgandhi 18:6a4db94011d3 116 */
sahilmgandhi 18:6a4db94011d3 117
sahilmgandhi 18:6a4db94011d3 118 typedef struct
sahilmgandhi 18:6a4db94011d3 119 {
sahilmgandhi 18:6a4db94011d3 120 HASH_InitTypeDef Init; /*!< HASH required parameters */
sahilmgandhi 18:6a4db94011d3 121
sahilmgandhi 18:6a4db94011d3 122 uint8_t *pHashInBuffPtr; /*!< Pointer to input buffer */
sahilmgandhi 18:6a4db94011d3 123
sahilmgandhi 18:6a4db94011d3 124 uint8_t *pHashOutBuffPtr; /*!< Pointer to input buffer */
sahilmgandhi 18:6a4db94011d3 125
sahilmgandhi 18:6a4db94011d3 126 __IO uint32_t HashBuffSize; /*!< Size of buffer to be processed */
sahilmgandhi 18:6a4db94011d3 127
sahilmgandhi 18:6a4db94011d3 128 __IO uint32_t HashInCount; /*!< Counter of inputed data */
sahilmgandhi 18:6a4db94011d3 129
sahilmgandhi 18:6a4db94011d3 130 __IO uint32_t HashITCounter; /*!< Counter of issued interrupts */
sahilmgandhi 18:6a4db94011d3 131
sahilmgandhi 18:6a4db94011d3 132 HAL_StatusTypeDef Status; /*!< HASH peripheral status */
sahilmgandhi 18:6a4db94011d3 133
sahilmgandhi 18:6a4db94011d3 134 HAL_HASH_PhaseTypeDef Phase; /*!< HASH peripheral phase */
sahilmgandhi 18:6a4db94011d3 135
sahilmgandhi 18:6a4db94011d3 136 DMA_HandleTypeDef *hdmain; /*!< HASH In DMA handle parameters */
sahilmgandhi 18:6a4db94011d3 137
sahilmgandhi 18:6a4db94011d3 138 HAL_LockTypeDef Lock; /*!< HASH locking object */
sahilmgandhi 18:6a4db94011d3 139
sahilmgandhi 18:6a4db94011d3 140 __IO HAL_HASH_StateTypeDef State; /*!< HASH peripheral state */
sahilmgandhi 18:6a4db94011d3 141 } HASH_HandleTypeDef;
sahilmgandhi 18:6a4db94011d3 142
sahilmgandhi 18:6a4db94011d3 143 /**
sahilmgandhi 18:6a4db94011d3 144 * @}
sahilmgandhi 18:6a4db94011d3 145 */
sahilmgandhi 18:6a4db94011d3 146
sahilmgandhi 18:6a4db94011d3 147
sahilmgandhi 18:6a4db94011d3 148 /**
sahilmgandhi 18:6a4db94011d3 149 * @}
sahilmgandhi 18:6a4db94011d3 150 */
sahilmgandhi 18:6a4db94011d3 151
sahilmgandhi 18:6a4db94011d3 152 /* Exported constants --------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 153 /** @defgroup HASH_Exported_Constants HASH Exported Constants
sahilmgandhi 18:6a4db94011d3 154 * @{
sahilmgandhi 18:6a4db94011d3 155 */
sahilmgandhi 18:6a4db94011d3 156
sahilmgandhi 18:6a4db94011d3 157 /** @defgroup HASH_Exported_Constants_Group1 HASH Algorithm Selection
sahilmgandhi 18:6a4db94011d3 158 * @{
sahilmgandhi 18:6a4db94011d3 159 */
sahilmgandhi 18:6a4db94011d3 160 #define HASH_ALGOSELECTION_SHA1 ((uint32_t)0x00000000U) /*!< HASH function is SHA1 */
sahilmgandhi 18:6a4db94011d3 161 #define HASH_ALGOSELECTION_SHA224 HASH_CR_ALGO_1 /*!< HASH function is SHA224 */
sahilmgandhi 18:6a4db94011d3 162 #define HASH_ALGOSELECTION_SHA256 HASH_CR_ALGO /*!< HASH function is SHA256 */
sahilmgandhi 18:6a4db94011d3 163 #define HASH_ALGOSELECTION_MD5 HASH_CR_ALGO_0 /*!< HASH function is MD5 */
sahilmgandhi 18:6a4db94011d3 164 /**
sahilmgandhi 18:6a4db94011d3 165 * @}
sahilmgandhi 18:6a4db94011d3 166 */
sahilmgandhi 18:6a4db94011d3 167
sahilmgandhi 18:6a4db94011d3 168 /** @defgroup HASH_Exported_Constants_Group2 HASH Algorithm Mode
sahilmgandhi 18:6a4db94011d3 169 * @{
sahilmgandhi 18:6a4db94011d3 170 */
sahilmgandhi 18:6a4db94011d3 171 #define HASH_ALGOMODE_HASH ((uint32_t)0x00000000U) /*!< Algorithm is HASH */
sahilmgandhi 18:6a4db94011d3 172 #define HASH_ALGOMODE_HMAC HASH_CR_MODE /*!< Algorithm is HMAC */
sahilmgandhi 18:6a4db94011d3 173 /**
sahilmgandhi 18:6a4db94011d3 174 * @}
sahilmgandhi 18:6a4db94011d3 175 */
sahilmgandhi 18:6a4db94011d3 176
sahilmgandhi 18:6a4db94011d3 177 /** @defgroup HASH_Data_Type HASH Data Type
sahilmgandhi 18:6a4db94011d3 178 * @{
sahilmgandhi 18:6a4db94011d3 179 */
sahilmgandhi 18:6a4db94011d3 180 #define HASH_DATATYPE_32B ((uint32_t)0x00000000U) /*!< 32-bit data. No swapping */
sahilmgandhi 18:6a4db94011d3 181 #define HASH_DATATYPE_16B HASH_CR_DATATYPE_0 /*!< 16-bit data. Each half word is swapped */
sahilmgandhi 18:6a4db94011d3 182 #define HASH_DATATYPE_8B HASH_CR_DATATYPE_1 /*!< 8-bit data. All bytes are swapped */
sahilmgandhi 18:6a4db94011d3 183 #define HASH_DATATYPE_1B HASH_CR_DATATYPE /*!< 1-bit data. In the word all bits are swapped */
sahilmgandhi 18:6a4db94011d3 184 /**
sahilmgandhi 18:6a4db94011d3 185 * @}
sahilmgandhi 18:6a4db94011d3 186 */
sahilmgandhi 18:6a4db94011d3 187
sahilmgandhi 18:6a4db94011d3 188 /** @defgroup HASH_Exported_Constants_Group4 HASH HMAC Long key
sahilmgandhi 18:6a4db94011d3 189 * @brief HASH HMAC Long key used only for HMAC mode
sahilmgandhi 18:6a4db94011d3 190 * @{
sahilmgandhi 18:6a4db94011d3 191 */
sahilmgandhi 18:6a4db94011d3 192 #define HASH_HMAC_KEYTYPE_SHORTKEY ((uint32_t)0x00000000U) /*!< HMAC Key is <= 64 bytes */
sahilmgandhi 18:6a4db94011d3 193 #define HASH_HMAC_KEYTYPE_LONGKEY HASH_CR_LKEY /*!< HMAC Key is > 64 bytes */
sahilmgandhi 18:6a4db94011d3 194 /**
sahilmgandhi 18:6a4db94011d3 195 * @}
sahilmgandhi 18:6a4db94011d3 196 */
sahilmgandhi 18:6a4db94011d3 197
sahilmgandhi 18:6a4db94011d3 198 /** @defgroup HASH_Exported_Constants_Group5 HASH Flags definition
sahilmgandhi 18:6a4db94011d3 199 * @{
sahilmgandhi 18:6a4db94011d3 200 */
sahilmgandhi 18:6a4db94011d3 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 */
sahilmgandhi 18:6a4db94011d3 202 #define HASH_FLAG_DCIS HASH_SR_DCIS /*!< Digest calculation complete */
sahilmgandhi 18:6a4db94011d3 203 #define HASH_FLAG_DMAS HASH_SR_DMAS /*!< DMA interface is enabled (DMAE=1) or a transfer is ongoing */
sahilmgandhi 18:6a4db94011d3 204 #define HASH_FLAG_BUSY HASH_SR_BUSY /*!< The hash core is Busy : processing a block of data */
sahilmgandhi 18:6a4db94011d3 205 #define HASH_FLAG_DINNE HASH_CR_DINNE /*!< DIN not empty : The input buffer contains at least one word of data */
sahilmgandhi 18:6a4db94011d3 206 /**
sahilmgandhi 18:6a4db94011d3 207 * @}
sahilmgandhi 18:6a4db94011d3 208 */
sahilmgandhi 18:6a4db94011d3 209
sahilmgandhi 18:6a4db94011d3 210 /** @defgroup HASH_Exported_Constants_Group6 HASH Interrupts definition
sahilmgandhi 18:6a4db94011d3 211 * @{
sahilmgandhi 18:6a4db94011d3 212 */
sahilmgandhi 18:6a4db94011d3 213 #define HASH_IT_DINI HASH_IMR_DINIE /*!< A new block can be entered into the input buffer (DIN) */
sahilmgandhi 18:6a4db94011d3 214 #define HASH_IT_DCI HASH_IMR_DCIE /*!< Digest calculation complete */
sahilmgandhi 18:6a4db94011d3 215 /**
sahilmgandhi 18:6a4db94011d3 216 * @}
sahilmgandhi 18:6a4db94011d3 217 */
sahilmgandhi 18:6a4db94011d3 218
sahilmgandhi 18:6a4db94011d3 219 /**
sahilmgandhi 18:6a4db94011d3 220 * @}
sahilmgandhi 18:6a4db94011d3 221 */
sahilmgandhi 18:6a4db94011d3 222
sahilmgandhi 18:6a4db94011d3 223 /* Exported macro ------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 224 /** @defgroup HASH_Exported_Macros HASH Exported Macros
sahilmgandhi 18:6a4db94011d3 225 * @{
sahilmgandhi 18:6a4db94011d3 226 */
sahilmgandhi 18:6a4db94011d3 227
sahilmgandhi 18:6a4db94011d3 228 /** @brief Reset HASH handle state
sahilmgandhi 18:6a4db94011d3 229 * @param __HANDLE__: specifies the HASH handle.
sahilmgandhi 18:6a4db94011d3 230 * @retval None
sahilmgandhi 18:6a4db94011d3 231 */
sahilmgandhi 18:6a4db94011d3 232 #define __HAL_HASH_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_HASH_STATE_RESET)
sahilmgandhi 18:6a4db94011d3 233
sahilmgandhi 18:6a4db94011d3 234 /** @brief Check whether the specified HASH flag is set or not.
sahilmgandhi 18:6a4db94011d3 235 * @param __FLAG__: specifies the flag to check.
sahilmgandhi 18:6a4db94011d3 236 * This parameter can be one of the following values:
sahilmgandhi 18:6a4db94011d3 237 * @arg HASH_FLAG_DINIS: A new block can be entered into the input buffer.
sahilmgandhi 18:6a4db94011d3 238 * @arg HASH_FLAG_DCIS: Digest calculation complete
sahilmgandhi 18:6a4db94011d3 239 * @arg HASH_FLAG_DMAS: DMA interface is enabled (DMAE=1) or a transfer is ongoing
sahilmgandhi 18:6a4db94011d3 240 * @arg HASH_FLAG_BUSY: The hash core is Busy : processing a block of data
sahilmgandhi 18:6a4db94011d3 241 * @arg HASH_FLAG_DINNE: DIN not empty : The input buffer contains at least one word of data
sahilmgandhi 18:6a4db94011d3 242 * @retval The new state of __FLAG__ (TRUE or FALSE).
sahilmgandhi 18:6a4db94011d3 243 */
sahilmgandhi 18:6a4db94011d3 244 #define __HAL_HASH_GET_FLAG(__FLAG__) (((__FLAG__) > 8U) ? ((HASH->CR & (__FLAG__)) == (__FLAG__)) :\
sahilmgandhi 18:6a4db94011d3 245 ((HASH->SR & (__FLAG__)) == (__FLAG__)))
sahilmgandhi 18:6a4db94011d3 246
sahilmgandhi 18:6a4db94011d3 247 /**
sahilmgandhi 18:6a4db94011d3 248 * @brief Enable the multiple DMA mode.
sahilmgandhi 18:6a4db94011d3 249 * This feature is available only in STM32F429x and STM32F439x devices.
sahilmgandhi 18:6a4db94011d3 250 * @retval None
sahilmgandhi 18:6a4db94011d3 251 */
sahilmgandhi 18:6a4db94011d3 252 #define __HAL_HASH_SET_MDMAT() HASH->CR |= HASH_CR_MDMAT
sahilmgandhi 18:6a4db94011d3 253
sahilmgandhi 18:6a4db94011d3 254 /**
sahilmgandhi 18:6a4db94011d3 255 * @brief Disable the multiple DMA mode.
sahilmgandhi 18:6a4db94011d3 256 * @retval None
sahilmgandhi 18:6a4db94011d3 257 */
sahilmgandhi 18:6a4db94011d3 258 #define __HAL_HASH_RESET_MDMAT() HASH->CR &= (uint32_t)(~HASH_CR_MDMAT)
sahilmgandhi 18:6a4db94011d3 259
sahilmgandhi 18:6a4db94011d3 260 /**
sahilmgandhi 18:6a4db94011d3 261 * @brief Start the digest computation
sahilmgandhi 18:6a4db94011d3 262 * @retval None
sahilmgandhi 18:6a4db94011d3 263 */
sahilmgandhi 18:6a4db94011d3 264 #define __HAL_HASH_START_DIGEST() HASH->STR |= HASH_STR_DCAL
sahilmgandhi 18:6a4db94011d3 265
sahilmgandhi 18:6a4db94011d3 266 /**
sahilmgandhi 18:6a4db94011d3 267 * @brief Set the number of valid bits in last word written in Data register
sahilmgandhi 18:6a4db94011d3 268 * @param SIZE: size in byte of last data written in Data register.
sahilmgandhi 18:6a4db94011d3 269 * @retval None
sahilmgandhi 18:6a4db94011d3 270 */
sahilmgandhi 18:6a4db94011d3 271 #define __HAL_HASH_SET_NBVALIDBITS(SIZE) do{HASH->STR &= ~(HASH_STR_NBLW);\
sahilmgandhi 18:6a4db94011d3 272 HASH->STR |= 8U * ((SIZE) % 4U);\
sahilmgandhi 18:6a4db94011d3 273 }while(0)
sahilmgandhi 18:6a4db94011d3 274
sahilmgandhi 18:6a4db94011d3 275 /**
sahilmgandhi 18:6a4db94011d3 276 * @}
sahilmgandhi 18:6a4db94011d3 277 */
sahilmgandhi 18:6a4db94011d3 278
sahilmgandhi 18:6a4db94011d3 279 /* Include HASH HAL Extension module */
sahilmgandhi 18:6a4db94011d3 280 #include "stm32f4xx_hal_hash_ex.h"
sahilmgandhi 18:6a4db94011d3 281 /* Exported functions --------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 282
sahilmgandhi 18:6a4db94011d3 283 /** @defgroup HASH_Exported_Functions HASH Exported Functions
sahilmgandhi 18:6a4db94011d3 284 * @{
sahilmgandhi 18:6a4db94011d3 285 */
sahilmgandhi 18:6a4db94011d3 286
sahilmgandhi 18:6a4db94011d3 287 /** @addtogroup HASH_Exported_Functions_Group1
sahilmgandhi 18:6a4db94011d3 288 * @{
sahilmgandhi 18:6a4db94011d3 289 */
sahilmgandhi 18:6a4db94011d3 290 HAL_StatusTypeDef HAL_HASH_Init(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 291 HAL_StatusTypeDef HAL_HASH_DeInit(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 292 /**
sahilmgandhi 18:6a4db94011d3 293 * @}
sahilmgandhi 18:6a4db94011d3 294 */
sahilmgandhi 18:6a4db94011d3 295
sahilmgandhi 18:6a4db94011d3 296 /** @addtogroup HASH_Exported_Functions_Group2
sahilmgandhi 18:6a4db94011d3 297 * @{
sahilmgandhi 18:6a4db94011d3 298 */
sahilmgandhi 18:6a4db94011d3 299 HAL_StatusTypeDef HAL_HASH_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 300 HAL_StatusTypeDef HAL_HASH_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 301 HAL_StatusTypeDef HAL_HASH_MD5_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 302 HAL_StatusTypeDef HAL_HASH_SHA1_Accumulate(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 303 /**
sahilmgandhi 18:6a4db94011d3 304 * @}
sahilmgandhi 18:6a4db94011d3 305 */
sahilmgandhi 18:6a4db94011d3 306
sahilmgandhi 18:6a4db94011d3 307 /** @addtogroup HASH_Exported_Functions_Group3
sahilmgandhi 18:6a4db94011d3 308 * @{
sahilmgandhi 18:6a4db94011d3 309 */
sahilmgandhi 18:6a4db94011d3 310 HAL_StatusTypeDef HAL_HMAC_SHA1_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 311 HAL_StatusTypeDef HAL_HMAC_MD5_Start(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 312 /**
sahilmgandhi 18:6a4db94011d3 313 * @}
sahilmgandhi 18:6a4db94011d3 314 */
sahilmgandhi 18:6a4db94011d3 315
sahilmgandhi 18:6a4db94011d3 316 /** @addtogroup HASH_Exported_Functions_Group4
sahilmgandhi 18:6a4db94011d3 317 * @{
sahilmgandhi 18:6a4db94011d3 318 */
sahilmgandhi 18:6a4db94011d3 319 HAL_StatusTypeDef HAL_HASH_SHA1_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
sahilmgandhi 18:6a4db94011d3 320 HAL_StatusTypeDef HAL_HASH_MD5_Start_IT(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size, uint8_t* pOutBuffer);
sahilmgandhi 18:6a4db94011d3 321 /**
sahilmgandhi 18:6a4db94011d3 322 * @}
sahilmgandhi 18:6a4db94011d3 323 */
sahilmgandhi 18:6a4db94011d3 324
sahilmgandhi 18:6a4db94011d3 325 /** @addtogroup HASH_Exported_Functions_Group5
sahilmgandhi 18:6a4db94011d3 326 * @{
sahilmgandhi 18:6a4db94011d3 327 */
sahilmgandhi 18:6a4db94011d3 328 HAL_StatusTypeDef HAL_HASH_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 329 HAL_StatusTypeDef HAL_HASH_SHA1_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 330 HAL_StatusTypeDef HAL_HASH_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 331 HAL_StatusTypeDef HAL_HASH_MD5_Finish(HASH_HandleTypeDef *hhash, uint8_t* pOutBuffer, uint32_t Timeout);
sahilmgandhi 18:6a4db94011d3 332 /**
sahilmgandhi 18:6a4db94011d3 333 * @}
sahilmgandhi 18:6a4db94011d3 334 */
sahilmgandhi 18:6a4db94011d3 335
sahilmgandhi 18:6a4db94011d3 336 /** @addtogroup HASH_Exported_Functions_Group6
sahilmgandhi 18:6a4db94011d3 337 * @{
sahilmgandhi 18:6a4db94011d3 338 */
sahilmgandhi 18:6a4db94011d3 339 HAL_StatusTypeDef HAL_HMAC_SHA1_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 340 HAL_StatusTypeDef HAL_HMAC_MD5_Start_DMA(HASH_HandleTypeDef *hhash, uint8_t *pInBuffer, uint32_t Size);
sahilmgandhi 18:6a4db94011d3 341 /**
sahilmgandhi 18:6a4db94011d3 342 * @}
sahilmgandhi 18:6a4db94011d3 343 */
sahilmgandhi 18:6a4db94011d3 344
sahilmgandhi 18:6a4db94011d3 345 /** @addtogroup HASH_Exported_Functions_Group7
sahilmgandhi 18:6a4db94011d3 346 * @{
sahilmgandhi 18:6a4db94011d3 347 */
sahilmgandhi 18:6a4db94011d3 348 void HAL_HASH_IRQHandler(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 349 /**
sahilmgandhi 18:6a4db94011d3 350 * @}
sahilmgandhi 18:6a4db94011d3 351 */
sahilmgandhi 18:6a4db94011d3 352
sahilmgandhi 18:6a4db94011d3 353 /** @addtogroup HASH_Exported_Functions_Group8
sahilmgandhi 18:6a4db94011d3 354 * @{
sahilmgandhi 18:6a4db94011d3 355 */
sahilmgandhi 18:6a4db94011d3 356 HAL_HASH_StateTypeDef HAL_HASH_GetState(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 357 void HAL_HASH_MspInit(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 358 void HAL_HASH_MspDeInit(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 359 void HAL_HASH_InCpltCallback(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 360 void HAL_HASH_DgstCpltCallback(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 361 void HAL_HASH_ErrorCallback(HASH_HandleTypeDef *hhash);
sahilmgandhi 18:6a4db94011d3 362 /**
sahilmgandhi 18:6a4db94011d3 363 * @}
sahilmgandhi 18:6a4db94011d3 364 */
sahilmgandhi 18:6a4db94011d3 365
sahilmgandhi 18:6a4db94011d3 366 /**
sahilmgandhi 18:6a4db94011d3 367 * @}
sahilmgandhi 18:6a4db94011d3 368 */
sahilmgandhi 18:6a4db94011d3 369
sahilmgandhi 18:6a4db94011d3 370 /* Private types -------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 371 /** @defgroup HASH_Private_Types HASH Private Types
sahilmgandhi 18:6a4db94011d3 372 * @{
sahilmgandhi 18:6a4db94011d3 373 */
sahilmgandhi 18:6a4db94011d3 374
sahilmgandhi 18:6a4db94011d3 375 /**
sahilmgandhi 18:6a4db94011d3 376 * @}
sahilmgandhi 18:6a4db94011d3 377 */
sahilmgandhi 18:6a4db94011d3 378
sahilmgandhi 18:6a4db94011d3 379 /* Private variables ---------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 380 /** @defgroup HASH_Private_Variables HASH Private Variables
sahilmgandhi 18:6a4db94011d3 381 * @{
sahilmgandhi 18:6a4db94011d3 382 */
sahilmgandhi 18:6a4db94011d3 383
sahilmgandhi 18:6a4db94011d3 384 /**
sahilmgandhi 18:6a4db94011d3 385 * @}
sahilmgandhi 18:6a4db94011d3 386 */
sahilmgandhi 18:6a4db94011d3 387
sahilmgandhi 18:6a4db94011d3 388 /* Private constants ---------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 389 /** @defgroup HASH_Private_Constants HASH Private Constants
sahilmgandhi 18:6a4db94011d3 390 * @{
sahilmgandhi 18:6a4db94011d3 391 */
sahilmgandhi 18:6a4db94011d3 392
sahilmgandhi 18:6a4db94011d3 393 /**
sahilmgandhi 18:6a4db94011d3 394 * @}
sahilmgandhi 18:6a4db94011d3 395 */
sahilmgandhi 18:6a4db94011d3 396
sahilmgandhi 18:6a4db94011d3 397 /* Private macros ------------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 398 /** @defgroup HASH_Private_Macros HASH Private Macros
sahilmgandhi 18:6a4db94011d3 399 * @{
sahilmgandhi 18:6a4db94011d3 400 */
sahilmgandhi 18:6a4db94011d3 401 #define IS_HASH_ALGOSELECTION(__ALGOSELECTION__) (((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA1) || \
sahilmgandhi 18:6a4db94011d3 402 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA224) || \
sahilmgandhi 18:6a4db94011d3 403 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_SHA256) || \
sahilmgandhi 18:6a4db94011d3 404 ((__ALGOSELECTION__) == HASH_ALGOSELECTION_MD5))
sahilmgandhi 18:6a4db94011d3 405
sahilmgandhi 18:6a4db94011d3 406
sahilmgandhi 18:6a4db94011d3 407 #define IS_HASH_ALGOMODE(__ALGOMODE__) (((__ALGOMODE__) == HASH_ALGOMODE_HASH) || \
sahilmgandhi 18:6a4db94011d3 408 ((__ALGOMODE__) == HASH_ALGOMODE_HMAC))
sahilmgandhi 18:6a4db94011d3 409
sahilmgandhi 18:6a4db94011d3 410
sahilmgandhi 18:6a4db94011d3 411 #define IS_HASH_DATATYPE(__DATATYPE__) (((__DATATYPE__) == HASH_DATATYPE_32B)|| \
sahilmgandhi 18:6a4db94011d3 412 ((__DATATYPE__) == HASH_DATATYPE_16B)|| \
sahilmgandhi 18:6a4db94011d3 413 ((__DATATYPE__) == HASH_DATATYPE_8B) || \
sahilmgandhi 18:6a4db94011d3 414 ((__DATATYPE__) == HASH_DATATYPE_1B))
sahilmgandhi 18:6a4db94011d3 415
sahilmgandhi 18:6a4db94011d3 416
sahilmgandhi 18:6a4db94011d3 417 #define IS_HASH_HMAC_KEYTYPE(__KEYTYPE__) (((__KEYTYPE__) == HASH_HMAC_KEYTYPE_SHORTKEY) || \
sahilmgandhi 18:6a4db94011d3 418 ((__KEYTYPE__) == HASH_HMAC_KEYTYPE_LONGKEY))
sahilmgandhi 18:6a4db94011d3 419
sahilmgandhi 18:6a4db94011d3 420 #define IS_HASH_SHA1_BUFFER_SIZE(__SIZE__) ((((__SIZE__)%4) != 0U)? 0U: 1U)
sahilmgandhi 18:6a4db94011d3 421
sahilmgandhi 18:6a4db94011d3 422 /**
sahilmgandhi 18:6a4db94011d3 423 * @}
sahilmgandhi 18:6a4db94011d3 424 */
sahilmgandhi 18:6a4db94011d3 425
sahilmgandhi 18:6a4db94011d3 426 /* Private functions ---------------------------------------------------------*/
sahilmgandhi 18:6a4db94011d3 427 /** @defgroup HASH_Private_Functions HASH Private Functions
sahilmgandhi 18:6a4db94011d3 428 * @{
sahilmgandhi 18:6a4db94011d3 429 */
sahilmgandhi 18:6a4db94011d3 430
sahilmgandhi 18:6a4db94011d3 431 /**
sahilmgandhi 18:6a4db94011d3 432 * @}
sahilmgandhi 18:6a4db94011d3 433 */
sahilmgandhi 18:6a4db94011d3 434
sahilmgandhi 18:6a4db94011d3 435 #endif /* STM32F415xx || STM32F417xx || STM32F437xx || STM32F439xx || STM32F479xx */
sahilmgandhi 18:6a4db94011d3 436 /**
sahilmgandhi 18:6a4db94011d3 437 * @}
sahilmgandhi 18:6a4db94011d3 438 */
sahilmgandhi 18:6a4db94011d3 439
sahilmgandhi 18:6a4db94011d3 440 /**
sahilmgandhi 18:6a4db94011d3 441 * @}
sahilmgandhi 18:6a4db94011d3 442 */
sahilmgandhi 18:6a4db94011d3 443
sahilmgandhi 18:6a4db94011d3 444 #ifdef __cplusplus
sahilmgandhi 18:6a4db94011d3 445 }
sahilmgandhi 18:6a4db94011d3 446 #endif
sahilmgandhi 18:6a4db94011d3 447
sahilmgandhi 18:6a4db94011d3 448
sahilmgandhi 18:6a4db94011d3 449 #endif /* __STM32F4xx_HAL_HASH_H */
sahilmgandhi 18:6a4db94011d3 450
sahilmgandhi 18:6a4db94011d3 451 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/