avr: provide polynomial for crc function.

This commit is contained in:
Martin Preuss
2024-09-12 11:44:54 +02:00
parent c055ee6cc2
commit a10cd8293b
2 changed files with 8 additions and 7 deletions

View File

@@ -51,16 +51,14 @@ com2CheckMessageInBuffer_error:
; ---------------------------------------------------------------------------
; com2CalcMsgChecksum
; @routine com2CalcMsgChecksum
;
; calc checksum from msg buffer (except crc byte)
;
; IN:
; - X : pointer to packet buffer (points to checksum byte upon return)
; OUT:
; - r16: crc8 checksum
; - X : points to position of checksum byte
; MODIFIED REGS: R16, R18, (R17, R20, X)
; @return r16 crc8 checksum
; @return X points to position of checksum byte
; @param X pointer to packet buffer (points to checksum byte upon return)
; @clobbers R16, R18, R19, (R17, R20, X)
com2CalcMsgChecksum:
adiw xh:xl, COM2_MSG_OFFS_MSGLEN
@@ -68,6 +66,8 @@ com2CalcMsgChecksum:
sbiw xh:xl, COM2_MSG_OFFS_MSGLEN
inc r18 ; account for dest address
inc r18 ; account for msg len byte
ldi r19, COM2_CRC8_POLYNOMIAL ; polynomial
rjmp crc8Calc ; (R16, R17, R18, R20, X)
; @end

View File

@@ -45,3 +45,4 @@
.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