]>
git.zerfleddert.de Git - fnordlicht-mini/blob - firmware/tools/fixcrc.c
4 /* EEPROM data size, not including checksum */
5 #define EEP_DATA_SIZE 494
6 /* FIXME: actually we should either find a way to include the declaration of
7 struct storage_t here or at least make this a command line parameter */
9 /* code from http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html */
10 uint16_t crc16_update(uint16_t crc
, uint8_t a
)
15 for (i
= 0; i
< 8; ++i
)
18 crc
= (crc
>> 1) ^ 0xA001;
26 int main(int argc
, char ** argv
)
29 uint16_t checksum
= 0;
30 for (i
= 0; i
< EEP_DATA_SIZE
; i
++) {
32 if ((c
= getchar()) == EOF
) {
36 checksum
= crc16_update(checksum
, c
);
38 if (putchar(c
) == EOF
) {
42 putchar(checksum
>> 8);
43 putchar(checksum
& 0xff);