avr: provide polynomial for crc function.
This commit is contained in:
@@ -51,16 +51,14 @@ com2CheckMessageInBuffer_error:
|
|||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; com2CalcMsgChecksum
|
; @routine com2CalcMsgChecksum
|
||||||
;
|
;
|
||||||
; calc checksum from msg buffer (except crc byte)
|
; calc checksum from msg buffer (except crc byte)
|
||||||
;
|
;
|
||||||
; IN:
|
; @return r16 crc8 checksum
|
||||||
; - X : pointer to packet buffer (points to checksum byte upon return)
|
; @return X points to position of checksum byte
|
||||||
; OUT:
|
; @param X pointer to packet buffer (points to checksum byte upon return)
|
||||||
; - r16: crc8 checksum
|
; @clobbers R16, R18, R19, (R17, R20, X)
|
||||||
; - X : points to position of checksum byte
|
|
||||||
; MODIFIED REGS: R16, R18, (R17, R20, X)
|
|
||||||
|
|
||||||
com2CalcMsgChecksum:
|
com2CalcMsgChecksum:
|
||||||
adiw xh:xl, COM2_MSG_OFFS_MSGLEN
|
adiw xh:xl, COM2_MSG_OFFS_MSGLEN
|
||||||
@@ -68,6 +66,8 @@ com2CalcMsgChecksum:
|
|||||||
sbiw xh:xl, COM2_MSG_OFFS_MSGLEN
|
sbiw xh:xl, COM2_MSG_OFFS_MSGLEN
|
||||||
inc r18 ; account for dest address
|
inc r18 ; account for dest address
|
||||||
inc r18 ; account for msg len byte
|
inc r18 ; account for msg len byte
|
||||||
|
ldi r19, COM2_CRC8_POLYNOMIAL ; polynomial
|
||||||
rjmp crc8Calc ; (R16, R17, R18, R20, X)
|
rjmp crc8Calc ; (R16, R17, R18, R20, X)
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,3 +45,4 @@
|
|||||||
.equ COM2_ERROR_COLLISION = 5
|
.equ COM2_ERROR_COLLISION = 5
|
||||||
|
|
||||||
|
|
||||||
|
.equ COM2_CRC8_POLYNOMIAL = 0x97 ; HD=4 up to 119 bytes, e.g. detects all 1 to 3 bit errors
|
||||||
|
|||||||
Reference in New Issue
Block a user