2.1.5 static __inline__ uint8_t _crc8_ccitt_update

static __inline__ uint8_t _crc8_ccitt_update(uint8_t __crc, uint8_t __data)

Optimized CRC-8-CCITT calculation.

Polynomial: x^8 + x^2 + x + 1 (0xE0)

For use with simple CRC-8 Initial value: 0x0

For use with CRC-8-ROHC Initial value: 0xff Reference: http://tools.ietf.org/html/rfc3095#section-5.9.1

For use with CRC-8-ATM/ITU Initial value: 0xff Final XOR value: 0x55 Reference: http://www.itu.int/rec/T-REC-I.432.1-199902-I/en

The C equivalent has been originally written by Dave Hylands. Assembly code is based on _crc_ibutton_update optimization.

The following is the equivalent functionality written in C.

    uint8_t
    _crc8_ccitt_update (uint8_t inCrc, uint8_t inData)
    {
        uint8_t   i;
        uint8_t   data;

        data = inCrc ^ inData;

        for ( i = 0; i < 8; i++ )
        {
            if (( data & 0x80 ) != 0 )
            {
                data <<= 1;
                data ^= 0x07;
            }
            else
            {
                data <<= 1;
            }
        }
        return data;
    }