1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_hal_crc.h 4 * @author MCD Application Team 5 * @brief Header file of CRC HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2016 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 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32F4xx_HAL_CRC_H 21 #define STM32F4xx_HAL_CRC_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32f4xx_hal_def.h" 29 30 /** @addtogroup STM32F4xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup CRC 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /** @defgroup CRC_Exported_Types CRC Exported Types 40 * @{ 41 */ 42 43 /** 44 * @brief CRC HAL State Structure definition 45 */ 46 typedef enum 47 { 48 HAL_CRC_STATE_RESET = 0x00U, /*!< CRC not yet initialized or disabled */ 49 HAL_CRC_STATE_READY = 0x01U, /*!< CRC initialized and ready for use */ 50 HAL_CRC_STATE_BUSY = 0x02U, /*!< CRC internal process is ongoing */ 51 HAL_CRC_STATE_TIMEOUT = 0x03U, /*!< CRC timeout state */ 52 HAL_CRC_STATE_ERROR = 0x04U /*!< CRC error state */ 53 } HAL_CRC_StateTypeDef; 54 55 56 /** 57 * @brief CRC Handle Structure definition 58 */ 59 typedef struct 60 { 61 CRC_TypeDef *Instance; /*!< Register base address */ 62 63 HAL_LockTypeDef Lock; /*!< CRC Locking object */ 64 65 __IO HAL_CRC_StateTypeDef State; /*!< CRC communication state */ 66 67 } CRC_HandleTypeDef; 68 /** 69 * @} 70 */ 71 72 /* Exported constants --------------------------------------------------------*/ 73 /** @defgroup CRC_Exported_Constants CRC Exported Constants 74 * @{ 75 */ 76 77 /** 78 * @} 79 */ 80 81 /* Exported macros -----------------------------------------------------------*/ 82 /** @defgroup CRC_Exported_Macros CRC Exported Macros 83 * @{ 84 */ 85 86 /** @brief Reset CRC handle state. 87 * @param __HANDLE__ CRC handle. 88 * @retval None 89 */ 90 #define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET) 91 92 /** 93 * @brief Reset CRC Data Register. 94 * @param __HANDLE__ CRC handle 95 * @retval None 96 */ 97 #define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET) 98 99 /** 100 * @brief Store data in the Independent Data (ID) register. 101 * @param __HANDLE__ CRC handle 102 * @param __VALUE__ Value to be stored in the ID register 103 * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits 104 * @retval None 105 */ 106 #define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__))) 107 108 /** 109 * @brief Return the data stored in the Independent Data (ID) register. 110 * @param __HANDLE__ CRC handle 111 * @note Refer to the Reference Manual to get the authorized __VALUE__ length in bits 112 * @retval Value of the ID register 113 */ 114 #define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR) 115 /** 116 * @} 117 */ 118 119 120 /* Private macros --------------------------------------------------------*/ 121 /** @defgroup CRC_Private_Macros CRC Private Macros 122 * @{ 123 */ 124 125 /** 126 * @} 127 */ 128 129 /* Exported functions --------------------------------------------------------*/ 130 /** @defgroup CRC_Exported_Functions CRC Exported Functions 131 * @{ 132 */ 133 134 /* Initialization and de-initialization functions ****************************/ 135 /** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions 136 * @{ 137 */ 138 HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc); 139 HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc); 140 void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc); 141 void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc); 142 /** 143 * @} 144 */ 145 146 /* Peripheral Control functions ***********************************************/ 147 /** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions 148 * @{ 149 */ 150 uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 151 uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength); 152 /** 153 * @} 154 */ 155 156 /* Peripheral State and Error functions ***************************************/ 157 /** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions 158 * @{ 159 */ 160 HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc); 161 /** 162 * @} 163 */ 164 165 /** 166 * @} 167 */ 168 169 /** 170 * @} 171 */ 172 173 /** 174 * @} 175 */ 176 177 #ifdef __cplusplus 178 } 179 #endif 180 181 #endif /* STM32F4xx_HAL_CRC_H */ 182