CRC Synchronous Driver

The functions in the Cyclic Redundancy Check (CRC) synchronous driver will block (i.e. not return) until the operation is done.

Summary of the API's Functional Features

The API provides functions to:
  • Initialization and de-initialization

  • Enabling and Disabling

  • CRC32 (IEEE-802.3)

  • CRC16 (CCITT)

Summary of Configuration Options

Normally there is no parameter to be configured in START.

Driver Implementation Description

The driver supports IEEE CRC32 polynomial and CCITT CRC16 polynomial. The initial value used for the CRC calculation must be assigned. This value is normally 0xFFFFFFFF(CRC32) or 0xFFFF(CRC16), but can be, for example, the result of a previously computed CRC separate memory blocks.

Example of Usage

The following shows a simple example of using the CRC32 functions.

          /* CRC Data in flash */
          COMPILER_ALIGNED(4)
          static const uint32_t crc_datas[] = {0x00000000,
                                               0x11111111,
                                               0x22222222,
                                               0x33333333,
                                               0x44444444,
                                               0x55555555,
                                               0x66666666,
                                               0x77777777,
                                               0x88888888,
                                               0x99999999};
          /**
           * Example of using CRC_0 to Calculate CRC32 for a buffer.
           */
          void CRC_0_example(void)
          {
              /* The initial value used for the CRC32 calculation usually be 0xFFFFFFFF,
                * but can be, for example, the result of a previous CRC32 calculation if
                * generating a common CRC32 of separate memory blocks.
                */
              uint32_t crc = 0xFFFFFFFF;
              uint32_t crc2;
              uint32_t ind;
              crc_sync_enable(&CRC_0);
              crc_sync_crc32(&CRC_0, (uint32_t *)crc_datas, 10, &crc);
              /* The read value must be complemented to match standard CRC32
                * implementations or kept non-inverted if used as starting point for
                * subsequent CRC32 calculations.
                */
              crc ^= 0xFFFFFFFF;
              /* Calculate the same data with subsequent CRC32 calculations, the result
                * should be same as previous way.
                */
              crc2 = 0xFFFFFFFF;
              for (ind = 0; ind < 10; ind++) {
                  crc_sync_crc32(&CRC_0, (uint32_t *)&crc_datas[ind], 1, &crc2);
              }
              crc2 ^= 0xFFFFFFFF;
              /* The calculate result should be same. */
              while (crc != crc2)
                  ;
          }
        

Dependencies

  • CRC capable hardware. For Cortex-M0+ based SAM devices, the CRC uses hardware DSU engine which only supports CRC32 (IEEE-802.3) reversed polynomial representation.