Skip to content

Commit

Permalink
fix crc_hw_stm32.c
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyongzhong0 committed Apr 18, 2022
1 parent 859976c commit 421788f
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions src/crc_hw_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,6 @@
#ifdef CRCLIB_USING_CRC_HW
#ifdef CHIP_FAMILY_STM32

#ifdef CHIP_SERIES_STM32F0
#include <stm32f0xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32F1
#include <stm32f1xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32F2
#include <stm32f2xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32F4
#include <stm32f4xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32F7
#include <stm32f7xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32L0
#include <stm32l0xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32L1
#include <stm32l1xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32L2
#include <stm32l2xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32L4
#include <stm32l4xx_ll_crc.h>
#endif
#ifdef CHIP_SERIES_STM32H7
#include <stm32h7xx_ll_crc.h>
#endif

static bool crc_is_busy = false;

void crc_hw_init(crc_hw_inst_t *hinst, u32 poly)
Expand Down Expand Up @@ -70,18 +39,15 @@ u32 crc_hw_cyc_cal(crc_hw_inst_t *hinst, u32 init_val, u8 *pdata, u32 len)

__HAL_RCC_CRC_CLK_ENABLE();

LL_CRC_SetInputDataReverseMode(CRC, LL_CRC_INDATA_REVERSE_BYTE);
LL_CRC_SetOutputDataReverseMode(CRC, LL_CRC_OUTDATA_REVERSE_BIT);
LL_CRC_SetPolynomialCoef(CRC, hinst->poly);
LL_CRC_SetPolynomialSize(CRC, hinst->size);
LL_CRC_SetInitialData(CRC, init_val);
LL_CRC_ResetCRCCalculationUnit(CRC);

CRC->POL = hinst->poly;
CRC->INIT = init_val;
CRC->CR = ((1<<0) | (hinst->size) | (1<<5) | (1<<7));

for(int i=0; i<len; i++)
{
LL_CRC_FeedData8(CRC, pdata[i]);
*((u8 *)&(CRC->DR)) = pdata[i];
}
u32 rst = LL_CRC_ReadData32(CRC);
u32 rst = CRC->DR;

__HAL_RCC_CRC_CLK_DISABLE();
crc_is_busy = false;
Expand Down

0 comments on commit 421788f

Please sign in to comment.