[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect

From: Joerg Wunsch
Subject: Re: [avr-libc-dev] [bug #37901] CRC-CCITT calculation incorrect
Date: Tue, 11 Dec 2012 16:39:19 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

As Weddington, Eric wrote:

> > They are already well supported by _crc_xmodem_update(), they just
> > need to be told. ;-)

> That's unacceptable as that's an internal function name. We need to
> have a first-class function name that can be used by xmega users.

There are no "first-class" and "second-class" names. ;-)

All the functions of this header file (_crc16_update which once
started the file but uses the "IBM-CRC-16" polynomial,
_crc_xmodem_update, _crc_ccitt_update, and finally
_crc_ibutton_update) have been deliberately chosen to lie in the
implementation namespace so they don't collide with the application

Thus, an application could do something like this:

#if defined(__AVR__) && defined(__GNUC__)
#  define crc_ccitt_update(c, v) _crc_ccitt_update(c, v)
inline uint16_t crc_ccitt_update(uint16_t crc, uint8_t data)
    data ^= crc & 0xff;
    data ^= data << 4;

    return ((((uint16_t)data << 8) | ((crc & 0xff00) >> 8))
            ^ (uint8_t)(data >> 4)
            ^ ((uint16_t)data << 3));

cheers, J"org               .-.-.   --... ...--   -.. .  DL8DTL

http://www.sax.de/~joerg/                        NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]