stm32h7xx_hal_crc_ex.c
Go to the documentation of this file.
1 
32 /* Includes ------------------------------------------------------------------*/
33 #include "stm32h7xx_hal.h"
34 
44 #ifdef HAL_CRC_MODULE_ENABLED
45 
46 /* Private typedef -----------------------------------------------------------*/
47 /* Private define ------------------------------------------------------------*/
48 /* Private macro -------------------------------------------------------------*/
49 /* Private variables ---------------------------------------------------------*/
50 /* Private function prototypes -----------------------------------------------*/
51 /* Exported functions --------------------------------------------------------*/
52 
89 HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength)
90 {
91  HAL_StatusTypeDef status = HAL_OK;
92  uint32_t msb = 31U; /* polynomial degree is 32 at most, so msb is initialized to max value */
93 
94  /* Check the parameters */
95  assert_param(IS_CRC_POL_LENGTH(PolyLength));
96 
97  /* check polynomial definition vs polynomial size:
98  * polynomial length must be aligned with polynomial
99  * definition. HAL_ERROR is reported if Pol degree is
100  * larger than that indicated by PolyLength.
101  * Look for MSB position: msb will contain the degree of
102  * the second to the largest polynomial member. E.g., for
103  * X^7 + X^6 + X^5 + X^2 + 1, msb = 6. */
104  while ((msb-- > 0U) && ((Pol & ((uint32_t)(0x1U) << (msb & 0x1FU))) == 0U))
105  {
106  }
107 
108  switch (PolyLength)
109  {
110  case CRC_POLYLENGTH_7B:
111  if (msb >= HAL_CRC_LENGTH_7B)
112  {
113  status = HAL_ERROR;
114  }
115  break;
116  case CRC_POLYLENGTH_8B:
117  if (msb >= HAL_CRC_LENGTH_8B)
118  {
119  status = HAL_ERROR;
120  }
121  break;
122  case CRC_POLYLENGTH_16B:
123  if (msb >= HAL_CRC_LENGTH_16B)
124  {
125  status = HAL_ERROR;
126  }
127  break;
128 
129  case CRC_POLYLENGTH_32B:
130  /* no polynomial definition vs. polynomial length issue possible */
131  break;
132  default:
133  status = HAL_ERROR;
134  break;
135  }
136  if (status == HAL_OK)
137  {
138  /* set generating polynomial */
139  WRITE_REG(hcrc->Instance->POL, Pol);
140 
141  /* set generating polynomial size */
142  MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, PolyLength);
143  }
144  /* Return function status */
145  return status;
146 }
147 
160 {
161  /* Check the parameters */
163 
164  /* Change CRC peripheral state */
166 
167  /* set input data inversion mode */
168  MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, InputReverseMode);
169  /* Change CRC peripheral state */
171 
172  /* Return function status */
173  return HAL_OK;
174 }
175 
186 {
187  /* Check the parameters */
189 
190  /* Change CRC peripheral state */
192 
193  /* set output data inversion mode */
194  MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, OutputReverseMode);
195 
196  /* Change CRC peripheral state */
198 
199  /* Return function status */
200  return HAL_OK;
201 }
202 
203 
204 
205 
216 #endif /* HAL_CRC_MODULE_ENABLED */
217 
225 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
IS_CRC_POL_LENGTH
#define IS_CRC_POL_LENGTH(LENGTH)
Definition: stm32h7xx_hal_crc.h:273
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:40
HAL_CRCEx_Input_Data_Reverse
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode)
CRC_CR_REV_IN
#define CRC_CR_REV_IN
Definition: stm32f769xx.h:5929
HAL_ERROR
@ HAL_ERROR
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:43
HAL_CRC_LENGTH_8B
#define HAL_CRC_LENGTH_8B
Definition: stm32h7xx_hal_crc.h:181
HAL_CRC_STATE_BUSY
@ HAL_CRC_STATE_BUSY
Definition: stm32h7xx_hal_crc.h:51
CRC_POLYLENGTH_16B
#define CRC_POLYLENGTH_16B
Definition: stm32h7xx_hal_crc.h:169
HAL_OK
@ HAL_OK
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h:42
CRC_CR_REV_OUT
#define CRC_CR_REV_OUT
Definition: stm32f769xx.h:5934
HAL_CRC_LENGTH_7B
#define HAL_CRC_LENGTH_7B
Definition: stm32h7xx_hal_crc.h:182
CRC_POLYLENGTH_32B
#define CRC_POLYLENGTH_32B
Definition: stm32h7xx_hal_crc.h:168
MODIFY_REG
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:224
CRC_TypeDef::POL
__IO uint32_t POL
Definition: stm32f769xx.h:324
CRC_HandleTypeDef::State
__IO HAL_CRC_StateTypeDef State
Definition: stm32h7xx_hal_crc.h:111
HAL_CRCEx_Polynomial_Set
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength)
CRC_TypeDef::CR
__IO uint32_t CR
Definition: stm32f407xx.h:286
CRC_CR_POLYSIZE
#define CRC_CR_POLYSIZE
Definition: stm32f769xx.h:5924
CRC_HandleTypeDef
CRC Handle Structure definition.
Definition: stm32h7xx_hal_crc.h:103
CRC_POLYLENGTH_7B
#define CRC_POLYLENGTH_7B
Definition: stm32h7xx_hal_crc.h:171
CRC_POLYLENGTH_8B
#define CRC_POLYLENGTH_8B
Definition: stm32h7xx_hal_crc.h:170
HAL_CRC_STATE_READY
@ HAL_CRC_STATE_READY
Definition: stm32h7xx_hal_crc.h:50
HAL_CRC_LENGTH_16B
#define HAL_CRC_LENGTH_16B
Definition: stm32h7xx_hal_crc.h:180
WRITE_REG
#define WRITE_REG(REG, VAL)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:220
CRC_HandleTypeDef::Instance
CRC_TypeDef * Instance
Definition: stm32h7xx_hal_crc.h:105
IS_CRC_INPUTDATA_INVERSION_MODE
#define IS_CRC_INPUTDATA_INVERSION_MODE(MODE)
Definition: stm32h7xx_hal_crc_ex.h:105
HAL_CRCEx_Output_Data_Reverse
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode)
IS_CRC_OUTPUTDATA_INVERSION_MODE
#define IS_CRC_OUTPUTDATA_INVERSION_MODE(MODE)
Definition: stm32h7xx_hal_crc_ex.h:110
hcrc
CRC_HandleTypeDef hcrc
Definition: stm32h735/stm32h735g-dk/Src/pv_audio_rec.c:36


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:54