| NUC472_NUC442_BSP V3.04.000 The Board Support Package for NUC472/NUC442

crc.c
Go to the documentation of this file.
1/**************************************************************************/
13#include "NUC472_442.h"
50 void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
51{
52 CRC->SEED = u32Seed;
53 CRC->CTL = u32Mode | u32Attribute | u32DataLen | CRC_CTL_CRCEN_Msk;
54
55 /* Setting CRCRST bit will reload the initial seed value(CRC_SEED register) to CRC controller */
56 CRC->CTL |= CRC_CTL_CRCRST_Msk;
57}
58
68uint32_t CRC_GetChecksum(void)
69{
70 switch(CRC->CTL & CRC_CTL_CRCMODE_Msk)
71 {
72 case CRC_CCITT:
73 case CRC_16:
74 return (CRC->CHECKSUM & 0xFFFF);
75
76 case CRC_32:
77 return (CRC->CHECKSUM);
78
79 case CRC_8:
80 return (CRC->CHECKSUM & 0xFF);
81
82 default:
83 return 0;
84 }
85}
86 /* end of group NUC472_442_CRC_EXPORTED_FUNCTIONS */
88 /* end of group NUC472_442_CRC_Driver */
90 /* end of group NUC472_442_Device_Driver */
92
93/*** (C) COPYRIGHT 2015 Nuvoton Technology Corp. ***/
NUC472_442.h
NUC472/NUC442 peripheral access layer header file. This file contains all the peripheral register's d...
CRC_CTL_CRCRST_Msk
#define CRC_CTL_CRCRST_Msk
Definition: NUC472_442.h:4084
CRC_CTL_CRCEN_Msk
#define CRC_CTL_CRCEN_Msk
Definition: NUC472_442.h:4081
CRC_CTL_CRCMODE_Msk
#define CRC_CTL_CRCMODE_Msk
Definition: NUC472_442.h:4102
CRC_CCITT
#define CRC_CCITT
Definition: crc.h:35
CRC_16
#define CRC_16
Definition: crc.h:37
CRC_8
#define CRC_8
Definition: crc.h:36
CRC_32
#define CRC_32
Definition: crc.h:38
CRC_Open
void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
CRC Open.
Definition: crc.c:50
CRC_GetChecksum
uint32_t CRC_GetChecksum(void)
Get CRC Checksum.
Definition: crc.c:68
CRC
#define CRC
Definition: NUC472_442.h:28824