rt-thread-official/bsp/swm320-lq100/Libraries/SWM320_StdPeriph_Driver/SWM320_crc.c

51 lines
2.3 KiB
C
Raw Normal View History

2018-12-24 17:17:27 +08:00
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : SWM320_crc.c
* : SWM320单片机的CRC模块驱动库
* : http://www.synwit.com.cn/e/tool/gbook/?bid=1
* :
* : V1.1.0 20171025
* :
2018-12-24 17:17:27 +08:00
*
*
*******************************************************************************************************************************************
* @attention
*
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH CODING INFORMATION
* REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME. AS A RESULT, SYNWIT SHALL NOT BE HELD LIABLE
* FOR ANY DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
* OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION CONTAINED HEREIN IN CONN-
* -ECTION WITH THEIR PRODUCTS.
*
* COPYRIGHT 2012 Synwit Technology
*******************************************************************************************************************************************/
#include "SWM320.h"
#include "SWM320_crc.h"
/******************************************************************************************************************************************
2021-09-30 17:55:16 +08:00
* : CRC_Init()
* : CRC
* : CRC_TypeDef * CRCx CRC接口CRC
* uint32_t mode CRC32_IN32CRC32_IN16CRC32_IN8CRC16_IN16CRC16_IN8
* uint32_t out_not
* uint32_t out_rev
* uint32_t ini_val CRC初始值
* :
* :
2018-12-24 17:17:27 +08:00
******************************************************************************************************************************************/
void CRC_Init(CRC_TypeDef *CRCx, uint32_t mode, uint32_t out_not, uint32_t out_rev, uint32_t ini_val)
{
switch ((uint32_t)CRCx)
{
case ((uint32_t)CRC):
SYS->CLKEN |= (0x01 << SYS_CLKEN_CRC_Pos);
break;
}
CRCx->CR = (1 << CRC_CR_EN_Pos) |
(mode << CRC_CR_CRC16_Pos) |
(out_not << CRC_CR_ONOT_Pos) |
(out_rev << CRC_CR_OREV_Pos);
CRCx->INIVAL = ini_val;
}