avr: use provided polynomial.
This commit is contained in:
@@ -8,31 +8,22 @@
|
||||
; ***************************************************************************
|
||||
|
||||
|
||||
; ***************************************************************************
|
||||
; defines
|
||||
|
||||
|
||||
.equ CRC8_POLYNOMIAL = 0x97 ; HD=4 up to 119 bytes, e.g. detects all 1 to 3 bit errors
|
||||
|
||||
|
||||
|
||||
.cseg
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine crc8Calc @global
|
||||
; calc crc8 checksum using given polynomial
|
||||
;
|
||||
; IN:
|
||||
; - X : pointer to data to calc crc8 for
|
||||
; - r18: number of bytes to calc crc8 for
|
||||
; OUT:
|
||||
; - r16: crc8 checksum
|
||||
; - X : point directly behind the checked area
|
||||
; MODIFIED REGS: R16, R17, R18, R19, R20, X
|
||||
; @return r16 crc8 checksum
|
||||
; @return X points directly after last checked byte
|
||||
; @param X pointer to data to calc crc8 for
|
||||
; @param r18 number of bytes to calc crc8 for
|
||||
; @param r19 polynomial to use
|
||||
; @clobbers: R16, R17, R18, R20, X
|
||||
|
||||
crc8Calc:
|
||||
ldi r16, 0xff ; crc
|
||||
ldi r19, CRC8_POLYNOMIAL
|
||||
ldi r16, 0xff ; start crc
|
||||
|
||||
crc8Calc_loop1:
|
||||
ld r17, X+ ; running var
|
||||
@@ -48,6 +39,7 @@ crc8Calc_l1:
|
||||
dec r18
|
||||
brne crc8Calc_loop1
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user