diff --git a/avr/modules/com2/crc.asm b/avr/modules/com2/crc.asm index e4afb4c..68bf2aa 100644 --- a/avr/modules/com2/crc.asm +++ b/avr/modules/com2/crc.asm @@ -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 diff --git a/avr/modules/com2/defs.asm b/avr/modules/com2/defs.asm index 30fda1a..a13ea89 100644 --- a/avr/modules/com2/defs.asm +++ b/avr/modules/com2/defs.asm @@ -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