Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

static void scc_init_ccitt_crc ( void   )  [static]

Populate the partial CRC lookup table.

Returns:
none

Definition at line 1133 of file scc2_driver.c.

References CRC_POLYNOMIAL, and scc_crc_lookup_table.

{
      int dividend;           /* index for lookup table */
      uint16_t remainder;     /* partial value for a given dividend */
      int bit;          /* index into bits of a byte */

      /*
       * Compute the remainder of each possible dividend.
       */
      for (dividend = 0; dividend < 256; ++dividend) {
            /*
             * Start with the dividend followed by zeros.
             */
            remainder = dividend << (8);

            /*
             * Perform modulo-2 division, a bit at a time.
             */
            for (bit = 8; bit > 0; --bit) {
                  /*
                   * Try to divide the current data bit.
                   */
                  if (remainder & 0x8000) {
                        remainder = (remainder << 1) ^ CRC_POLYNOMIAL;
                  } else {
                        remainder = (remainder << 1);
                  }
            }

            /*
             * Store the result into the table.
             */
            scc_crc_lookup_table[dividend] = remainder;
      }

}                       /* scc_init_ccitt_crc() */


Generated by  Doxygen 1.6.0   Back to index