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