--- /usr/avr/include/util/crc16.h 2006-02-05 07:19:18.000000000 -0500 +++ crc16.h 2006-04-03 22:41:44.912308637 -0400 @@ -82,7 +82,29 @@ Polynomial: x^16 + x^15 + x^2 + 1 (0xa001)
Initial value: 0xffff - This CRC is normally used in disk-drive controllers. */ + This CRC is normally used in disk-drive controllers. + + The following is the equivalent functionality written in C. + + \code + uint16_t + crc16_update( uint16_t crc, uint8_t a ) + { + int i; + + crc ^= a; + for( i = 0; i < 8; ++i ) + { + if( crc & 1 ) + crc = (crc>>1) ^ 0xA001; + else + crc = (crc>>1); + } + + return crc; + } + + \endcode */ static __inline__ uint16_t _crc16_update(uint16_t __crc, uint8_t __data)