| M480 BSP V3.05.001 The Board Support Package for M480 Series

crc.c
Go to the documentation of this file.
1 /**************************************************************************/
9 #include "NuMicro.h"
10
47 void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
48 {
49 CRC->SEED = u32Seed;
50 CRC->CTL = u32Mode | u32Attribute | u32DataLen | CRC_CTL_CRCEN_Msk;
51
52 /* Setting CHKSINIT bit will reload the initial seed value(CRC_SEED register) to CRC controller */
53 CRC->CTL |= CRC_CTL_CHKSINIT_Msk;
54 }
55
65 uint32_t CRC_GetChecksum(void)
66 {
67 uint32_t ret;
68
69 switch(CRC->CTL & CRC_CTL_CRCMODE_Msk)
70 {
71 case CRC_CCITT:
72 case CRC_16:
73 ret = (CRC->CHECKSUM & 0xFFFFU);
74 break;
75 case CRC_32:
76 ret = (CRC->CHECKSUM);
77 break;
78 case CRC_8:
79 ret = (CRC->CHECKSUM & 0xFFU);
80 break;
81 default:
82 ret = 0U;
83 break;
84 }
85
86 return ret;
87 }
88 /* end of group CRC_EXPORTED_FUNCTIONS */
90 /* end of group CRC_Driver */
92 /* end of group Standard_Driver */
94
95 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
CRC_CTL_CRCMODE_Msk
#define CRC_CTL_CRCMODE_Msk
Definition: crc_reg.h:220
CRC_8
#define CRC_8
Definition: crc.h:33
CRC_GetChecksum
uint32_t CRC_GetChecksum(void)
Get CRC Checksum.
Definition: crc.c:65
NuMicro.h
NuMicro peripheral access layer header file.
CRC
#define CRC
Definition: M480.h:395
CRC_CCITT
#define CRC_CCITT
Definition: crc.h:32
CRC_16
#define CRC_16
Definition: crc.h:34
CRC_CTL_CRCEN_Msk
#define CRC_CTL_CRCEN_Msk
Definition: crc_reg.h:199
CRC_32
#define CRC_32
Definition: crc.h:35
CRC_CTL_CHKSINIT_Msk
#define CRC_CTL_CHKSINIT_Msk
Definition: crc_reg.h:202
CRC_Open
void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
CRC Open.
Definition: crc.c:47