1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- /**
- ******************************************************************************
- * File Name : CRC.c
- * Description : This file provides code for the configuration
- * of the CRC instances.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© Copyright (c) 2020 STMicroelectronics.
- * All rights reserved.</center></h2>
- *
- * This software component is licensed by ST under Ultimate Liberty license
- * SLA0044, the "License"; You may not use this file except in compliance with
- * the License. You may obtain a copy of the License at:
- * www.st.com/SLA0044
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "crc.h"
- /* USER CODE BEGIN 0 */
- /* USER CODE END 0 */
- CRC_HandleTypeDef hcrc;
- /* CRC init function */
- void MX_CRC_Init(void)
- {
- hcrc.Instance = CRC;
- if (HAL_CRC_Init(&hcrc) != HAL_OK)
- {
- Error_Handler();
- }
- }
- void HAL_CRC_MspInit(CRC_HandleTypeDef* crcHandle)
- {
- if(crcHandle->Instance==CRC)
- {
- /* USER CODE BEGIN CRC_MspInit 0 */
- /* USER CODE END CRC_MspInit 0 */
- /* CRC clock enable */
- __HAL_RCC_CRC_CLK_ENABLE();
- /* USER CODE BEGIN CRC_MspInit 1 */
- /* USER CODE END CRC_MspInit 1 */
- }
- }
- void HAL_CRC_MspDeInit(CRC_HandleTypeDef* crcHandle)
- {
- if(crcHandle->Instance==CRC)
- {
- /* USER CODE BEGIN CRC_MspDeInit 0 */
- /* USER CODE END CRC_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_CRC_CLK_DISABLE();
- /* USER CODE BEGIN CRC_MspDeInit 1 */
- /* USER CODE END CRC_MspDeInit 1 */
- }
- }
- /* USER CODE BEGIN 1 */
- uint32_t crc32(uint8_t const * p_data, uint8_t size)
- {
- uint32_t crc;
- crc = 0xFFFFFFFF;
- for (uint32_t i = 0; i < size; i++)
- {
- if( (i<0x22) || (i>0x2f))
- {
- crc = crc ^ p_data[i];
- for (uint32_t j = 8; j > 0; j--)
- {
- crc = (crc >> 1) ^ (0xEDB88320U & ((crc & 1) ? 0xFFFFFFFF : 0));
- }
- }
- }
- return ~crc;
- }
- /* USER CODE END 1 */
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|