MXC_A39_20240320/SW/components/drivers/peripheral/Src/driver_crc.c

54 lines
1.4 KiB
C
Raw Normal View History

2024-03-07 16:46:43 +08:00
/*
******************************************************************************
* @file driver_crc.c
* @author FreqChip Firmware Team
* @version V1.0.0
* @date 2023
* @brief CRC module driver.
* This file provides firmware functions to manage the
* CRC(Cyclic Redundancy Check) peripheral
******************************************************************************
* @attention
*
* Copyright (c) 2023 FreqChip.
* All rights reserved.
******************************************************************************
*/
#include "fr30xx.h"
/************************************************************************************
* @fn crc_init
*
* @brief Initial crc according to the mode
*
* @param fe_crc_mode: crc mode.
*/
void crc_init(enum_CRC_MODE_SEL_t fe_crc_mode)
{
/* CRC control config */
CRC->CRC_CTRL = fe_crc_mode | CRC_START;
}
/************************************************************************************
* @fn crc_Calculate
*
* @brief Calculate CRC from the input data.
*
* @param fp_Data: Input calculated data.
* @param fu32_size: The data size need to do crc.
*/
uint32_t crc_Calculate(uint8_t *fp_Data, uint32_t fu32_size)
{
if (fu32_size == 0)
{
return 0;
}
while(fu32_size--)
{
CRC->CRC_FIFO_DATA = *(fp_Data++);
}
return CRC->CRC_RESULT;
}