Nano102_112 Series BSP  V3.03.002
The Board Support Package for Nano102_112 Series
crc.c
Go to the documentation of this file.
1 /**************************************************************************/
12 #include "Nano1X2Series.h"
13 
14 
15 
41 void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
42 {
44  PDMACRC->SEED = u32Seed;
45  PDMACRC->CTL = u32Mode | u32Attribute | u32DataLen | DMA_CRC_CTL_CRCCEN_Msk;
46  /* When operated in CPU PIO mode, setting RST bit will reload the initial seed value (CRC_SEED register) */
48 }
49 
60 void CRC_StartDMATransfer(uint32_t u32SrcAddr, uint32_t u32ByteCount)
61 {
62  PDMACRC->DMASAR = u32SrcAddr;
63  PDMACRC->DMABCR = u32ByteCount;
65 }
66 
76 uint32_t CRC_GetChecksum(void)
77 {
78  switch (PDMACRC->CTL & DMA_CRC_CTL_CRC_MODE_Msk)
79  {
80  case CRC_CCITT:
81  case CRC_16:
82  return (PDMACRC->CHECKSUM & 0xffff);
83 
84  case CRC_32:
85  return (PDMACRC->CHECKSUM);
86 
87  case CRC_8:
88  return (PDMACRC->CHECKSUM & 0xff);
89 
90  default:
91  return 0;
92  }
93 }
94 
95  /* end of group NANO1X2_CRC_EXPORTED_FUNCTIONS */
97  /* end of group NANO1X2_CRC_Driver */
99  /* end of group NANO1X2_Device_Driver */
101 
102 /*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
CRC Open.
Definition: crc.c:41
#define CRC_32
Definition: crc.h:39
void CRC_StartDMATransfer(uint32_t u32SrcAddr, uint32_t u32ByteCount)
CRC Start DMA transfer.
Definition: crc.c:60
#define CRC_16
Definition: crc.h:38
uint32_t CRC_GetChecksum(void)
Get CRC Checksum.
Definition: crc.c:76
#define PDMACRC
Pointer to PDMA CRC register structure.
#define DMA_CRC_CTL_CRCCEN_Msk
#define DMA_CRC_CTL_CRC_RST_Msk
#define PDMAGCR
Pointer to PDMA global control register structure.
Nano102/112 peripheral access layer header file. This file contains all the peripheral register's def...
#define CRC_8
Definition: crc.h:37
#define DMA_CRC_CTL_TRIG_EN_Msk
#define DMA_GCR_GCRCSR_CRC_CLK_EN_Msk
#define DMA_CRC_CTL_CRC_MODE_Msk
#define CRC_CCITT
Definition: crc.h:36