| NANO102/112 BSP V3.04.000 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{
43 PDMAGCR->GCRCSR |= DMA_GCR_GCRCSR_CRC_CLK_EN_Msk;
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) */
47 PDMACRC->CTL |= DMA_CRC_CTL_CRC_RST_Msk;
48}
49
60 void CRC_StartDMATransfer(uint32_t u32SrcAddr, uint32_t u32ByteCount)
61{
62 PDMACRC->DMASAR = u32SrcAddr;
63 PDMACRC->DMABCR = u32ByteCount;
64 PDMACRC->CTL |= DMA_CRC_CTL_TRIG_EN_Msk;
65}
66
76uint32_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. ***/
Nano1X2Series.h
Nano102/112 peripheral access layer header file. This file contains all the peripheral register's def...
DMA_CRC_CTL_CRC_MODE_Msk
#define DMA_CRC_CTL_CRC_MODE_Msk
Definition: Nano1X2Series.h:2296
DMA_CRC_CTL_CRCCEN_Msk
#define DMA_CRC_CTL_CRCCEN_Msk
Definition: Nano1X2Series.h:2272
DMA_CRC_CTL_CRC_RST_Msk
#define DMA_CRC_CTL_CRC_RST_Msk
Definition: Nano1X2Series.h:2275
DMA_GCR_GCRCSR_CRC_CLK_EN_Msk
#define DMA_GCR_GCRCSR_CRC_CLK_EN_Msk
Definition: Nano1X2Series.h:2352
DMA_CRC_CTL_TRIG_EN_Msk
#define DMA_CRC_CTL_TRIG_EN_Msk
Definition: Nano1X2Series.h:2278
CRC_CCITT
#define CRC_CCITT
Definition: crc.h:36
CRC_16
#define CRC_16
Definition: crc.h:38
CRC_8
#define CRC_8
Definition: crc.h:37
CRC_32
#define CRC_32
Definition: crc.h:39
CRC_Open
void CRC_Open(uint32_t u32Mode, uint32_t u32Attribute, uint32_t u32Seed, uint32_t u32DataLen)
CRC Open.
Definition: crc.c:41
CRC_GetChecksum
uint32_t CRC_GetChecksum(void)
Get CRC Checksum.
Definition: crc.c:76
CRC_StartDMATransfer
void CRC_StartDMATransfer(uint32_t u32SrcAddr, uint32_t u32ByteCount)
CRC Start DMA transfer.
Definition: crc.c:60
PDMACRC
#define PDMACRC
Pointer to PDMA CRC register structure.
Definition: Nano1X2Series.h:10663
PDMAGCR
#define PDMAGCR
Pointer to PDMA global control register structure.
Definition: Nano1X2Series.h:10664