1 /**
2   ******************************************************************************
3   * @file    stm32l5xx_hal_crc_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of CRC HAL extended module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 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 STM32L5xx_HAL_CRC_EX_H
21 #define STM32L5xx_HAL_CRC_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32l5xx_hal_def.h"
29 
30 /** @addtogroup STM32L5xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup CRCEx
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /* Exported constants --------------------------------------------------------*/
40 /** @defgroup CRCEx_Exported_Constants CRC Extended Exported Constants
41   * @{
42   */
43 
44 /** @defgroup CRCEx_Input_Data_Inversion Input Data Inversion Modes
45   * @{
46   */
47 #define CRC_INPUTDATA_INVERSION_NONE               0x00000000U     /*!< No input data inversion            */
48 #define CRC_INPUTDATA_INVERSION_BYTE               CRC_CR_REV_IN_0 /*!< Byte-wise input data inversion     */
49 #define CRC_INPUTDATA_INVERSION_HALFWORD           CRC_CR_REV_IN_1 /*!< HalfWord-wise input data inversion */
50 #define CRC_INPUTDATA_INVERSION_WORD               CRC_CR_REV_IN   /*!< Word-wise input data inversion     */
51 /**
52   * @}
53   */
54 
55 /** @defgroup CRCEx_Output_Data_Inversion Output Data Inversion Modes
56   * @{
57   */
58 #define CRC_OUTPUTDATA_INVERSION_DISABLE         0x00000000U       /*!< No output data inversion       */
59 #define CRC_OUTPUTDATA_INVERSION_ENABLE          CRC_CR_REV_OUT    /*!< Bit-wise output data inversion */
60 /**
61   * @}
62   */
63 
64 /**
65   * @}
66   */
67 
68 /* Exported macro ------------------------------------------------------------*/
69 /** @defgroup CRCEx_Exported_Macros CRC Extended Exported Macros
70   * @{
71   */
72 
73 /**
74   * @brief  Set CRC output reversal
75   * @param  __HANDLE__ CRC handle
76   * @retval None
77   */
78 #define  __HAL_CRC_OUTPUTREVERSAL_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_REV_OUT)
79 
80 /**
81   * @brief  Unset CRC output reversal
82   * @param  __HANDLE__ CRC handle
83   * @retval None
84   */
85 #define __HAL_CRC_OUTPUTREVERSAL_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= ~(CRC_CR_REV_OUT))
86 
87 /**
88   * @brief  Set CRC non-default polynomial
89   * @param  __HANDLE__ CRC handle
90   * @param  __POLYNOMIAL__ 7, 8, 16 or 32-bit polynomial
91   * @retval None
92   */
93 #define __HAL_CRC_POLYNOMIAL_CONFIG(__HANDLE__, __POLYNOMIAL__) ((__HANDLE__)->Instance->POL = (__POLYNOMIAL__))
94 
95 /**
96   * @}
97   */
98 
99 /* Private macros --------------------------------------------------------*/
100 /** @defgroup CRCEx_Private_Macros CRC Extended Private Macros
101   * @{
102   */
103 
104 #define IS_CRC_INPUTDATA_INVERSION_MODE(MODE)     (((MODE) == CRC_INPUTDATA_INVERSION_NONE)     || \
105                                                    ((MODE) == CRC_INPUTDATA_INVERSION_BYTE)     || \
106                                                    ((MODE) == CRC_INPUTDATA_INVERSION_HALFWORD) || \
107                                                    ((MODE) == CRC_INPUTDATA_INVERSION_WORD))
108 
109 #define IS_CRC_OUTPUTDATA_INVERSION_MODE(MODE)    (((MODE) == CRC_OUTPUTDATA_INVERSION_DISABLE) || \
110                                                    ((MODE) == CRC_OUTPUTDATA_INVERSION_ENABLE))
111 
112 /**
113   * @}
114   */
115 
116 /* Exported functions --------------------------------------------------------*/
117 
118 /** @addtogroup CRCEx_Exported_Functions
119   * @{
120   */
121 
122 /** @addtogroup CRCEx_Exported_Functions_Group1
123   * @{
124   */
125 /* Initialization and de-initialization functions  ****************************/
126 HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength);
127 HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode);
128 HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode);
129 
130 /**
131   * @}
132   */
133 
134 /**
135   * @}
136   */
137 
138 /**
139   * @}
140   */
141 
142 /**
143   * @}
144   */
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 
150 #endif /* STM32L5xx_HAL_CRC_EX_H */
151