Commits

Martin Scharrer committed 8d6347a

Compacter CRC algoritm.

  • Participants
  • Parent commits 391d783

Comments (0)

Files changed (1)

 void crc16_update(uint16_t* crc, uint8_t* data, size_t length)
 {
     int i;
-    uint16_t byte;
     while (length-- > 0)
     {
-        byte = (uint16_t)*data++ << 8;
+        *crc ^= (uint16_t)*data++ << 8;
         for (i=0; i<8; i++)
         {
-            if ( (*crc & 0x8000) ^ (byte & 0x8000) )
+            if ( (*crc & 0x8000) )
             {
                 *crc = (*crc << 1) ^ CRC16_POLY;
             }
             {
                 *crc <<= 1;
             }
-            byte <<= 1;
         }
     }
 }