From b9419520f408f3ae6df246da7fb1c1904c9967bc Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Sat, 26 Apr 2025 11:04:28 +0200 Subject: [PATCH] network: removed duplicate code. --- avr/modules/network/msg/common.asm | 93 ------------------------------ 1 file changed, 93 deletions(-) diff --git a/avr/modules/network/msg/common.asm b/avr/modules/network/msg/common.asm index a14bdf6..7b39be6 100644 --- a/avr/modules/network/msg/common.asm +++ b/avr/modules/network/msg/common.asm @@ -30,46 +30,6 @@ NETMSG_Common_AddUidToBuffer: -; --------------------------------------------------------------------------- -; @routine NETMSG_CalcAndAddChecksumByte @global -; -; @return CFLAG set if okay, clear otherwise -; @return X points behind checksum byte pos upon return -; @param X pointer to packet buffer (points behind checksum upon return) -; @clobbers R16, R17, R18, R19, R20, X - -NETMSG_CalcAndAddChecksumByte: - rcall netMsgCalcMsgChecksum ; (R16, R17, R18, R19, R20, X) - st X+, r16 ; add checksum byte - sec - ret -; @end - - - -; --------------------------------------------------------------------------- -; @routine NETMSG_CheckMessageInBuffer -; -; check message in buffer -; -; @return CFLAG set if okay, clear otherwise -; @param X pointer to packet buffer -; @clobbers R16, R17 (R18, R19, R20, X) - -NETMSG_CheckMessageInBuffer: - rcall netMsgCalcMsgChecksum ; (R16, R17, R18, R19, R20, X) - ld r17, X - cp r16, r17 ; should be equal - brne netMsgCheckMessageInBuffer_error - sec - ret -netMsgCheckMessageInBuffer_error: - clc - ret -; @end - - - ; --------------------------------------------------------------------------- ; @routine NETMSG_AddNextMsgIdToBuffer @global ; @@ -96,56 +56,3 @@ NETMSG_AddNextMsgIdToBuffer: -; --------------------------------------------------------------------------- -; @routine netMsgCalcMsgChecksum -; -; calc checksum from msg buffer (except crc byte) -; -; @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 R18 (R16, R17, R19, R20, X) - -netMsgCalcMsgChecksum: - adiw xh:xl, NETMSG_OFFS_MSGLEN - ld r18, X ; read msg len - sbiw xh:xl, NETMSG_OFFS_MSGLEN - inc r18 ; account for dest address - inc r18 ; account for msg len byte - rjmp netMsgCrcCalc ; (R16, R17, R18, R19, R20, X) -; @end - - - -; --------------------------------------------------------------------------- -; @routine netMsgCrcCalc @global -; calc checksum using given polynomial -; -; @return r16 calculated 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 -; @clobbers R16, R17, R18, R19, R20, X - -netMsgCrcCalc: - ldi r16, 0xff ; start crc - ldi r19, NETMSG_CRC8_POLYNOMIAL - -netMsgCrcCalc_loop1: - ld r17, X+ ; running var - eor r16, r17 - ldi r20, 8 ; counter for loop2 -netMsgCrcCalc_loop2: - lsl r16 - brcc netMsgCrcCalc_l1 - eor r16, r19 -netMsgCrcCalc_l1: - dec r20 - brne netMsgCrcCalc_loop2 - dec r18 - brne netMsgCrcCalc_loop1 - ret -; @end - - -