Microchip® Advanced Software Framework

dma_crc.h File Reference

SAM DMA cyclic redundancy check (CRC) Driver.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include <compiler.h>

Data Structures

struct  dma_crc_config
 Configurations for CRC calculation. More...
 

Macros

#define DMA_CRC_CHANNEL_N_OFFSET   0x20
 DMA channel n offset. More...
 

Enumerations

enum  crc_beat_size {
  CRC_BEAT_SIZE_BYTE,
  CRC_BEAT_SIZE_HWORD,
  CRC_BEAT_SIZE_WORD
}
 CRC Beat Type. More...
 
enum  crc_polynomial_type {
  CRC_TYPE_16,
  CRC_TYPE_32
}
 CRC Polynomial Type. More...
 

Functions

static enum status_code dma_crc_channel_enable (uint32_t channel_id, struct dma_crc_config *config)
 Enable DMA CRC module with an DMA channel. More...
 
static void dma_crc_disable (void)
 Disable DMA CRC module. More...
 
static uint32_t dma_crc_get_checksum (void)
 Get DMA CRC checksum value. More...
 
static void dma_crc_get_config_defaults (struct dma_crc_config *config)
 Get DMA CRC default configurations. More...
 
static void dma_crc_io_calculation (void *buffer, uint32_t total_beat_size)
 Calculate CRC with I/O. More...
 
static enum status_code dma_crc_io_enable (struct dma_crc_config *config)
 Enable DMA CRC module with I/O. More...
 

#define DMA_CRC_CHANNEL_N_OFFSET   0x20

DMA channel n offset.

Referenced by dma_crc_channel_enable().

CRC Beat Type.

Enumerator
CRC_BEAT_SIZE_BYTE 

Byte bus access.

CRC_BEAT_SIZE_HWORD 

Half-word bus access.

CRC_BEAT_SIZE_WORD 

Word bus access.

CRC Polynomial Type.

Enumerator
CRC_TYPE_16 

CRC16 (CRC-CCITT).

CRC_TYPE_32 

CRC32 (IEEE 802.3).

static enum status_code dma_crc_channel_enable ( uint32_t  channel_id,
struct dma_crc_config config 
)
inlinestatic

Enable DMA CRC module with an DMA channel.

This function enables a CRC calculation with an allocated DMA channel. This channel ID can be gotten from a successful dma_allocate.

Parameters
[in]channel_idDMA channel expected with CRC calculation
[in]configCRC calculation configurations
Returns
Status of the DMC CRC.
Return values
STATUS_OKGet the DMA CRC module
STATUS_BUSYDMA CRC module is already taken and not ready yet

References DMA_CRC_CHANNEL_N_OFFSET, dma_crc_config::size, STATUS_BUSY, STATUS_OK, and dma_crc_config::type.

static void dma_crc_disable ( void  )
inlinestatic

Disable DMA CRC module.

Referenced by generate_crc().

static uint32_t dma_crc_get_checksum ( void  )
inlinestatic

Get DMA CRC checksum value.

Returns
Calculated CRC checksum.

Referenced by generate_crc().

static void dma_crc_get_config_defaults ( struct dma_crc_config config)
inlinestatic

Get DMA CRC default configurations.

The default configuration is as follows:

  • Polynomial type is set to CRC-16(CRC-CCITT)
  • CRC Beat size: BYTE
Parameters
[in]configdefault configurations

References Assert, CRC_BEAT_SIZE_BYTE, CRC_TYPE_16, dma_crc_config::size, and dma_crc_config::type.

Referenced by generate_crc().

static void dma_crc_io_calculation ( void *  buffer,
uint32_t  total_beat_size 
)
inlinestatic

Calculate CRC with I/O.

This function calculate the CRC of the input data buffer.

Parameters
[in]bufferCRC Pointer to calculation buffer
[in]total_beat_sizeTotal beat size to be calculated
Returns
Calculated CRC checksum value.

References buffer, counter, CRC_BEAT_SIZE_BYTE, CRC_BEAT_SIZE_HWORD, CRC_BEAT_SIZE_WORD, and nop.

Referenced by generate_crc().

static enum status_code dma_crc_io_enable ( struct dma_crc_config config)
inlinestatic

Enable DMA CRC module with I/O.

This function enables a CRC calculation with I/O mode.

Parameters
[in]configCRC calculation configurations.
Returns
Status of the DMC CRC.
Return values
STATUS_OKGet the DMA CRC module
STATUS_BUSYDMA CRC module is already taken and not ready yet

References CRC_TYPE_32, dma_crc_config::size, STATUS_BUSY, STATUS_OK, and dma_crc_config::type.

Referenced by generate_crc().