diff --git a/aqhome/mqtt/endpoint_mqttc.c b/aqhome/mqtt/endpoint_mqttc.c index bdde1da..9f9512e 100644 --- a/aqhome/mqtt/endpoint_mqttc.c +++ b/aqhome/mqtt/endpoint_mqttc.c @@ -333,23 +333,23 @@ void _processRecvStatsMessage(GWEN_MSG_ENDPOINT *ep, GWEN_MSG *nodeMsg) packetsInInt=AQH_RecvStatsMsg_GetPacketsIn(nodeMsg); if (packetsInInt) { double packetsIn; - double errors; - double handled; - double errorsPercentage=0.0; - double handledPercentage=0.0; + double crcErrors; + double ioErrors; + double crcErrorsPercentage=0.0; + double ioErrorsPercentage=0.0; packetsIn=(double) packetsInInt; - errors=(double)AQH_RecvStatsMsg_GetErrors(nodeMsg); - handled=(double)AQH_RecvStatsMsg_GetHandled(nodeMsg); + crcErrors=(double)AQH_RecvStatsMsg_GetCrcErrors(nodeMsg); + ioErrors=(double)AQH_RecvStatsMsg_GetIoErrors(nodeMsg); - errorsPercentage=errors*100.0/packetsIn; - handledPercentage=handled*100.0/packetsIn; + crcErrorsPercentage=crcErrors*100.0/packetsIn; + ioErrorsPercentage=ioErrors*100.0/packetsIn; _publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/packetsIn", packetsInInt); - _publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/errors", (int) AQH_RecvStatsMsg_GetErrors(nodeMsg)); - _publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/handled", (int) AQH_RecvStatsMsg_GetHandled(nodeMsg)); - _publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/errorsPercent", errorsPercentage); - _publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/handledPercent", handledPercentage); + _publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/crcerrors", (int) AQH_RecvStatsMsg_GetCrcErrors(nodeMsg)); + _publishInt(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/ioerrors", (int) AQH_RecvStatsMsg_GetIoErrors(nodeMsg)); + _publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/crcerrorsPercent", crcErrorsPercentage); + _publishDouble(ep, AQH_RecvStatsMsg_GetUid(nodeMsg), 0, "net/ioerrorsPercent", ioErrorsPercentage); } } diff --git a/aqhome/msg/msg_node.c b/aqhome/msg/msg_node.c index 4463155..814cefb 100644 --- a/aqhome/msg/msg_node.c +++ b/aqhome/msg/msg_node.c @@ -17,7 +17,7 @@ -static uint8_t _calcChecksum(const uint8_t *ptr, uint8_t len); +static uint8_t _calcXorChecksum(const uint8_t *ptr, uint8_t len); @@ -105,7 +105,7 @@ int AQH_NodeMsg_IsMsgComplete(const GWEN_MSG *msg) int AQH_NodeMsg_IsChecksumValid(const GWEN_MSG *msg) { if (msg && AQH_NodeMsg_IsMsgComplete(msg)) - return (_calcChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))==0)?1:0; + return (_calcXorChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))==0)?1:0; return 0; } @@ -116,7 +116,7 @@ int AQH_NodeMsg_AddChecksum(GWEN_MSG *msg) if (msg) { int rv; - rv=GWEN_Msg_AddByte(msg, _calcChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))); + rv=GWEN_Msg_AddByte(msg, _calcXorChecksum(GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg))); if (rv<0) { DBG_INFO(NULL, "here (%d)", rv); return rv; @@ -171,7 +171,7 @@ uint32_t AQH_NodeMsg_GetMsgGroup(uint8_t msgType) -uint8_t _calcChecksum(const uint8_t *ptr, uint8_t len) +uint8_t _calcXorChecksum(const uint8_t *ptr, uint8_t len) { int i; uint8_t x=0; @@ -185,4 +185,26 @@ uint8_t _calcChecksum(const uint8_t *ptr, uint8_t len) +uint8_t _calcCrc8Checksum(const uint8_t *ptr, uint8_t len) +{ + int i; + uint8_t x=0xff; + + for (i=0; i=AQH_MSG_RECVSTATS_MINSIZE) { const uint8_t *ptr; - ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_ERRORS; + ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_CRCERRORS; return (uint16_t)(ptr[0])+(ptr[1]<<8); } return 0; @@ -67,12 +67,12 @@ uint16_t AQH_RecvStatsMsg_GetErrors(const GWEN_MSG *msg) -uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg) +uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg) { if (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE) { const uint8_t *ptr; - ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_HANDLED; + ptr=GWEN_Msg_GetConstBuffer(msg)+AQH_MSG_OFFS_ALL_DATA_BEGIN+AQH_MSG_OFFS_RECVSTATS_IOERRORS; return (uint16_t)(ptr[0])+(ptr[1]<<8); } return 0; @@ -85,14 +85,14 @@ void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const if ((AQH_NodeMsg_GetMsgType(msg)==AQH_MSG_TYPE_COMRECVSTATS) && (GWEN_Msg_GetBytesInBuffer(msg)>=AQH_MSG_RECVSTATS_MINSIZE)) { GWEN_Buffer_AppendArgs(dbuf, - "0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, errors=%d, handled=%d)\n", + "0x%02x->0x%02x: RECVSTATS %s (uid=0x%08x, in=%d, crc errors=%d, io errors=%d)\n", AQH_NodeMsg_GetSourceAddress(msg), AQH_NodeMsg_GetDestAddress(msg), sText, (unsigned int) AQH_RecvStatsMsg_GetUid(msg), AQH_RecvStatsMsg_GetPacketsIn(msg), - AQH_RecvStatsMsg_GetErrors(msg), - AQH_RecvStatsMsg_GetHandled(msg)); + AQH_RecvStatsMsg_GetCrcErrors(msg), + AQH_RecvStatsMsg_GetIoErrors(msg)); } } diff --git a/aqhome/msg/msg_recvstats.h b/aqhome/msg/msg_recvstats.h index 5d4b65f..ba0521f 100644 --- a/aqhome/msg/msg_recvstats.h +++ b/aqhome/msg/msg_recvstats.h @@ -20,8 +20,8 @@ AQHOME_API uint32_t AQH_RecvStatsMsg_GetUid(const GWEN_MSG *msg); AQHOME_API uint16_t AQH_RecvStatsMsg_GetPacketsIn(const GWEN_MSG *msg); -AQHOME_API uint16_t AQH_RecvStatsMsg_GetErrors(const GWEN_MSG *msg); -AQHOME_API uint16_t AQH_RecvStatsMsg_GetHandled(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_RecvStatsMsg_GetCrcErrors(const GWEN_MSG *msg); +AQHOME_API uint16_t AQH_RecvStatsMsg_GetIoErrors(const GWEN_MSG *msg); AQHOME_API void AQH_RecvStatsMsg_DumpToBuffer(const GWEN_MSG *msg, GWEN_BUFFER *dbuf, const char *sText); diff --git a/aqhome/msgmanager.c b/aqhome/msgmanager.c index dacb891..b038b27 100644 --- a/aqhome/msgmanager.c +++ b/aqhome/msgmanager.c @@ -348,8 +348,8 @@ void _handleMsgComRecvStat(GWEN_MSG_ENDPOINT_MGR *emgr, GWEN_MSG_ENDPOINT *ep, c DBG_INFO(AQH_LOGDOMAIN, "Error handling message"); } AQH_NodeInfo_SetStatsPacketsIn(ni, AQH_RecvStatsMsg_GetPacketsIn(msg)); - AQH_NodeInfo_SetStatsErrors(ni, AQH_RecvStatsMsg_GetErrors(msg)); - AQH_NodeInfo_SetStatsHandled(ni, AQH_RecvStatsMsg_GetHandled(msg)); + AQH_NodeInfo_SetStatsCrcErrors(ni, AQH_RecvStatsMsg_GetCrcErrors(msg)); + AQH_NodeInfo_SetStatsIoErrors(ni, AQH_RecvStatsMsg_GetIoErrors(msg)); AQH_NodeDb_SetModified(xmgr->nodeDb); } } diff --git a/aqhome/nodes/nodeinfo.t2d b/aqhome/nodes/nodeinfo.t2d index 21df9bf..01b6f8e 100644 --- a/aqhome/nodes/nodeinfo.t2d +++ b/aqhome/nodes/nodeinfo.t2d @@ -97,7 +97,14 @@ - + + 0 + 0 + public + + + + 0 0 public diff --git a/avr/MESSAGES b/avr/MESSAGES index 4ca1860..8b318ab 100644 --- a/avr/MESSAGES +++ b/avr/MESSAGES @@ -213,7 +213,7 @@ Offset Length Meaning --------------------------------------------------------- 4 4 UID of the sending node 8 2 packets in - 10 2 errors - 12 2 packets handled + 10 2 crc errors + 12 2 io errors diff --git a/avr/att84_temp1.asm b/avr/att84_temp1.asm index 8403192..0bcb955 100644 --- a/avr/att84_temp1.asm +++ b/avr/att84_temp1.asm @@ -221,6 +221,11 @@ .include "com.asm" .include "comproto.asm" .include "comproto_addr.asm" +.include "comproto_stats.asm" +.include "comproto_device.asm" +.include "comproto_values.asm" +;.include "comproto_debug.asm" +;.include "comproto_twi.asm" .include "twimaster.asm" .include "lcd.asm" .include "si7021.asm" @@ -328,12 +333,13 @@ onEveryMinute: breq onEveryMinute_l1 ; no, do nothing ; will later send this only every hour or so + ldi r16, 0xff ; send stats to everybody rcall CPRO_EnqueueComSendStats ldi r16, 0xff ; send recv to everybody rcall CPRO_EnqueueComRecvStats - + ldi r16, 0xff ; send device info to everybody rcall CPRO_EnqueueDevice onEveryMinute_l1: diff --git a/avr/com.asm b/avr/com.asm index 26b5ddf..832159e 100644 --- a/avr/com.asm +++ b/avr/com.asm @@ -62,11 +62,14 @@ comDataBegin: comStatsPacketsOut: .byte 2 comStatsRecvErrs: .byte 2 + comStatsRecvCrcErrs: .byte 2 comStatsCollisions: .byte 2 comStatsMissed: .byte 2 comStatsAborted: .byte 2 comStatsIgnored: .byte 2 comStatsHandled: .byte 2 + + comStatsNoBuffer: .byte 2 comRecvBuffersReadPos: .byte 1 comRecvBuffersWritePos: .byte 1 @@ -151,8 +154,8 @@ Com_Init: in r16, GIMSK ; enable pin change irq PCIE0 or PCIE1 ori r16, (1< CARRY - brcs comSendByte_setHigh ; HI: +2, LO: +1 -comSendByte_setLow: - sbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as output - Utils_WaitNanoSecs COM_BIT_LENGTH, 9, r22 - rjmp comSendByte_loopEnd ; +2 -comSendByte_setHigh: - cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE - nop ; +1 (to make pin change available) - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 11, r22 ; wait for half a bit length for line to safely settle - sbis COM_PIN_DATA, COM_PINNUM_DATA ; +1 if no skip, +2 if skipped - rjmp comSendByte_error ; +2 if error (collision: we wanted line to be high but it is low) - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 0, r22 -comSendByte_loopEnd: - dec r21 ; +1 - brne comSendByte_loop ; +2, sum per loop: 10 cycles - ; send stopbit - cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE - Utils_WaitNanoSecs COM_BIT_LENGTH, 4, r22 ; wait for one bit length - sec - ret - -comSendByte_error: - clc - ret - - - -; --------------------------------------------------------------------------- -; comReceiveByte -; -; Receive a byte. -; -; IN: -; - nothing -; OUT: -; - CFLAG: set if okay, clear otherwise -; - R16: byte read (if CFLAG set) -; MODIFIED REGS: R16, R20, R21, R22 (R17) - -comReceiveByte: - cbi COM_DDR_DATA, COM_PINNUM_DATA ; set DATA port as input - cbi COM_PORT_DATA, COM_PINNUM_DATA ; disable internal pullup for DATA - - ldi r21, 8 ; bits left - clr r20 ; byte currently receiving - ; wait for startbit - rcall comWaitForDataLow ; (R17) - brcc comReceiveByte_error - Utils_WaitNanoSecs COM_BIT_LENGTH/2, 5, r22 ; goto middle of startbit to maximize sync stability -comReceiveByte_loop: - Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits - sec ; +1 - sbic COM_PIN_DATA, COM_PINNUM_DATA ; LOW: +2, HIGH: +1 - rjmp comReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG - clc ; LOW: +1 -comReceiveByte_shiftIn: - ror r20 ; +1 - dec r21 ; +1 - brne comReceiveByte_loop ; +2, sum per loop: 8 cycles - rcall comWaitForDataHigh ; wait for start of stopbit - brcc comReceiveByte_error - mov r16, r20 - sec - ret -comReceiveByte_error: - clc - ret - - - -; --------------------------------------------------------------------------- -; comWaitForDataLow -; -; Waits up to COM_MAXWAIT loops for low data line -; IN: -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGISTERS: r17, r22 - -comWaitForDataLow: - ldi r17, COM_MAXWAIT - -comWaitForDataLow_loop: - sbis COM_PIN_DATA, COM_PINNUM_DATA - rjmp comWaitForDataLow_done - Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs - dec r17 - brne comWaitForDataLow_loop - clc ; timeout - ret - -comWaitForDataLow_done: - sec ; ok - ret - - - -; --------------------------------------------------------------------------- -; comWaitForDataHigh -; -; Waits up to COM_MAXWAIT loops for high data line -; IN: -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGISTERS: r17, r22, X - -comWaitForDataHigh: - ldi r17, COM_MAXWAIT - -comWaitForDataHigh_loop: - sbic COM_PIN_DATA, COM_PINNUM_DATA - rjmp comWaitForDataHigh_done - Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs - dec r17 - brne comWaitForDataHigh_loop - clc ; timeout - ret - -comWaitForDataHigh_done: - sec ; ok - ret - - - -; --------------------------------------------------------------------------- -; comWaitForAttnHigh -; -; Waits up to COM_MAXWAIT loops for high ATTN line -; IN: -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGISTERS: r17, r22, X - -comWaitForAttnHigh: - ldi r17, COM_MAXWAIT - -comWaitForAttnHigh_loop: - sbic COM_PIN_ATTN, COM_PINNUM_ATTN - rjmp comWaitForAttnHigh_done - Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs - dec r17 - brne comWaitForAttnHigh_loop - clc ; timeout - ret - -comWaitForAttnHigh_done: - sec ; ok - ret - - - -; *************************************************************************** -; buffer functions - - - -; --------------------------------------------------------------------------- -; COM_BufferAlloc -; -; Allocate a transfer buffer. -; IN: -; - nothing -; OUT: -; - CFLAG: set if okay, clear otherwise -; - Y: pointer to allocated buffer in SRAM -; MODIFIED REGISTERS: r16, r17, r21 - - -COM_BufferAlloc: - in r21, SREG ; save global interrupt enable bit from SREG - cli - lds r17, comRecvBuffersUsed - cpi r17, COM_BUFFER_NUM - brcc COM_AllocBuffer_error ; no buffer available - inc r17 ; increment number of buffers used - sts comRecvBuffersUsed, r17 ; store new value - lds r16, comRecvBuffersWritePos ; get current write pos - mov r17, r16 ; increment for next call - inc r17 - cpi r17, COM_BUFFER_NUM ; CF set if COM_BUFFER_NUM > R17 - brcs COM_AllocBuffer_l1 - clr r17 ; wraparound -COM_AllocBuffer_l1: - sts comRecvBuffersWritePos, r17 ; store new writepos for next caller - rcall COM_BufferPosToY ; (R16, R17) - clr r17 - std y+COM_BUFFER_OFFS_FLAGS, r17 ; preset flags - out SREG, r21 ; restore global interrupt enable bit in SREG - sec - ret -COM_AllocBuffer_error: - out SREG, r21 - clc - ret - - - -; --------------------------------------------------------------------------- -; COM_BufferDeallocBack -; -; Release a transfer buffer at the end of the list by decreasing the write pos. -; This releases the last allocated buffer! -; -; IN: -; - nothing -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGISTERS: r16, r17, r21 - -COM_BufferDeallocBack: - in r21, SREG ; save global interrupt enable bit from SREG - cli - lds r17, comRecvBuffersUsed - tst r17 - breq COM_BufferDeallocBack_error ; no buffer allocated, nothing to release - dec r17 - sts comRecvBuffersUsed, r17 ; store new value - lds r17, comRecvBuffersWritePos - tst r17 ; 0? - brne COM_BufferDeallocBack_l1 ; nope go directly decrement r17 - ldi r17, COM_BUFFER_NUM ; wrap-around -COM_BufferDeallocBack_l1: - dec r17 - sts comRecvBuffersWritePos, r17 - out SREG, r21 - sec - ret -COM_BufferDeallocBack_error: - out SREG, r21 - clc - ret - - - -; --------------------------------------------------------------------------- -; COM_BufferDeallocFront -; -; Release a transfer buffer by increasing the read pos. -; -; IN: -; - nothing -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGISTERS: r16, r17, r21 - -COM_BufferDeallocFront: - in r21, SREG ; save global interrupt enable bit from SREG - cli - lds r17, comRecvBuffersUsed - tst r17 - breq COM_BufferDeallocFront_error ; no buffer allocated, nothing to release - dec r17 - sts comRecvBuffersUsed, r17 ; store new value - lds r17, comRecvBuffersReadPos - inc r17 - cpi r17, COM_BUFFER_NUM - brcs COM_BufferDeallocFront_l1 - clr r17 ; wrap-around -COM_BufferDeallocFront_l1: - sts comRecvBuffersReadPos, r17 - out SREG, r21 - sec - ret -COM_BufferDeallocFront_error: - out SREG, r21 - clc - ret - - - -; --------------------------------------------------------------------------- -; COM_BufferPosToY -; -; Get a pointer to the SRAM position of the given buffer. -; CAVE: Code must correspond to COM_BUFFER_SIZE!! -; IN: -; - R16: buffer number (starting with 0) -; OUT: -; - Y: pointer to buffer in SRAM -; MODIFIED REGISTERS: R16, R17 - -COM_BufferPosToY: - ; calculate offset - clr r17 - mov yl, r16 - clr yh - - lsl yl - rol yh ; *2 - - add yl, r16 - adc yh, r17 ; *3 - - lsl yl - rol yh ; *6 - - lsl yl - rol yh ; *12 - - lsl yl - rol yh ; *24 - - ; add base position of buffers - ldi r16, LOW(comRecvBuffers) - ldi r17, HIGH(comRecvBuffers) - add yl, r16 - adc yh, r17 - ret diff --git a/avr/com_buffer.asm b/avr/com_buffer.asm new file mode 100644 index 0000000..a7931f2 --- /dev/null +++ b/avr/com_buffer.asm @@ -0,0 +1,163 @@ + +; *************************************************************************** +; code + +.cseg + + +; --------------------------------------------------------------------------- +; COM_BufferAlloc +; +; Allocate a transfer buffer. +; IN: +; - nothing +; OUT: +; - CFLAG: set if okay, clear otherwise +; - Y: pointer to allocated buffer in SRAM +; MODIFIED REGISTERS: r16, r17, r21 + + +COM_BufferAlloc: + in r21, SREG ; save global interrupt enable bit from SREG + cli + lds r17, comRecvBuffersUsed + cpi r17, COM_BUFFER_NUM + brcc COM_AllocBuffer_error ; no buffer available + inc r17 ; increment number of buffers used + sts comRecvBuffersUsed, r17 ; store new value + lds r16, comRecvBuffersWritePos ; get current write pos + mov r17, r16 ; increment for next call + inc r17 + cpi r17, COM_BUFFER_NUM ; CF set if COM_BUFFER_NUM > R17 + brcs COM_AllocBuffer_l1 + clr r17 ; wraparound +COM_AllocBuffer_l1: + sts comRecvBuffersWritePos, r17 ; store new writepos for next caller + rcall COM_BufferPosToY ; (R16, R17) + clr r17 + std y+COM_BUFFER_OFFS_FLAGS, r17 ; preset flags + out SREG, r21 ; restore global interrupt enable bit in SREG + sec + ret +COM_AllocBuffer_error: + out SREG, r21 + clc + ret + + + +; --------------------------------------------------------------------------- +; COM_BufferDeallocBack +; +; Release a transfer buffer at the end of the list by decreasing the write pos. +; This releases the last allocated buffer! +; +; IN: +; - nothing +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r16, r17, r21 + +COM_BufferDeallocBack: + in r21, SREG ; save global interrupt enable bit from SREG + cli + lds r17, comRecvBuffersUsed + tst r17 + breq COM_BufferDeallocBack_error ; no buffer allocated, nothing to release + dec r17 + sts comRecvBuffersUsed, r17 ; store new value + lds r17, comRecvBuffersWritePos + tst r17 ; 0? + brne COM_BufferDeallocBack_l1 ; nope go directly decrement r17 + ldi r17, COM_BUFFER_NUM ; wrap-around +COM_BufferDeallocBack_l1: + dec r17 + sts comRecvBuffersWritePos, r17 + out SREG, r21 + sec + ret +COM_BufferDeallocBack_error: + out SREG, r21 + clc + ret + + + +; --------------------------------------------------------------------------- +; COM_BufferDeallocFront +; +; Release a transfer buffer by increasing the read pos. +; +; IN: +; - nothing +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r16, r17, r21 + +COM_BufferDeallocFront: + in r21, SREG ; save global interrupt enable bit from SREG + cli + lds r17, comRecvBuffersUsed + tst r17 + breq COM_BufferDeallocFront_error ; no buffer allocated, nothing to release + dec r17 + sts comRecvBuffersUsed, r17 ; store new value + lds r17, comRecvBuffersReadPos + inc r17 + cpi r17, COM_BUFFER_NUM + brcs COM_BufferDeallocFront_l1 + clr r17 ; wrap-around +COM_BufferDeallocFront_l1: + sts comRecvBuffersReadPos, r17 + out SREG, r21 + sec + ret +COM_BufferDeallocFront_error: + out SREG, r21 + clc + ret + + + +; --------------------------------------------------------------------------- +; COM_BufferPosToY +; +; Get a pointer to the SRAM position of the given buffer. +; CAVE: Code must correspond to COM_BUFFER_SIZE!! +; IN: +; - R16: buffer number (starting with 0) +; OUT: +; - Y: pointer to buffer in SRAM +; MODIFIED REGISTERS: R16, R17 + +COM_BufferPosToY: + ; calculate offset + clr r17 + mov yl, r16 + clr yh + + lsl yl + rol yh ; *2 + + add yl, r16 + adc yh, r17 ; *3 + + lsl yl + rol yh ; *6 + + lsl yl + rol yh ; *12 + + lsl yl + rol yh ; *24 + + ; add base position of buffers + ldi r16, LOW(comRecvBuffers) + ldi r17, HIGH(comRecvBuffers) + add yl, r16 + adc yh, r17 + ret + + + + diff --git a/avr/com_crc.asm b/avr/com_crc.asm new file mode 100644 index 0000000..943bc5c --- /dev/null +++ b/avr/com_crc.asm @@ -0,0 +1,110 @@ + +; *************************************************************************** +; code + +.cseg + + + + +; --------------------------------------------------------------------------- +; add checksum byte to buffer +; +; IN: +; - X : pointer to packet buffer +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17, R18, X + +comCalcAndAddChecksumByte: + adiw xh:xl, COM_MSG_OFFS_MSGLEN + ld r18, X ; read msg len + inc r18 ; account for dest address + inc r18 ; account for msg len bytes + sbiw xh:xl, COM_MSG_OFFS_MSGLEN + rcall cproCalcXor ; (R16, R17, R18, X) + st X, r16 ; add checksum byte + sec + ret + + + +; --------------------------------------------------------------------------- +; check message in buffer +; +; IN: +; - X : pointer to packet buffer +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17, R18, X + +cproCheckMessageInBuffer: + adiw xh:xl, COM_MSG_OFFS_MSGLEN + ld r18, X ; read msg len + inc r18 ; account for dest address + inc r18 ; account for msg len bytes + sbiw xh:xl, COM_MSG_OFFS_MSGLEN + rcall cproCalcXor ; (R16, R17, R18, X) + ld r17, X + cp r16,r17 ; should be equal + brne cproCheckMessageInBuffer_error + sec + ret +cproCheckMessageInBuffer_error: + clc + ret + + + +; --------------------------------------------------------------------------- +; calc xor checksum +; +; IN: +; - X : pointer to data to calc crc8 for +; - r18: number of bytes to calc crc8 for +; OUT: +; - r16: xor checksum +; - X : point directly behind the checked area +; MODIFIED REGS: R16, R17, R18, X +cproCalcXor: + clr r16 +cproCalcXor_loop1: + ld r17, X+ + eor r16, r17 + dec r18 + brne cproCalcXor_loop1 + ret + + + +; --------------------------------------------------------------------------- +; calc crc8 checksum using given polynomial +; +; IN: +; - X : pointer to data to calc crc8 for +; - r18: number of bytes to calc crc8 for +; - r19: polynomial to use (e.g. 0x97: HD=4 up to 119 bytes, e.g. detects all 1 to 3 bit errors) +; OUT: +; - r16: crc8 checksum +; - X : point directly behind the checked area +; MODIFIED REGS: R16, R17, R18, R20, X + +cproCalcCrc8: + ldi r16, 0xff ; crc + +cproCalcCrc8_loop1: + ld r17, X+ ; running var + eor r16, r17 + ldi r20, 8 ; counter for loop2 +cproCalcCrc8_loop2: + lsl r16 + brcc cproCalcCrc8_l1 + eor r16, r19 +cproCalcCrc8_l1: + dec r20 + brne cproCalcCrc8_loop2 + dec r18 + brne cproCalcCrc8_loop1 + ret + + diff --git a/avr/com_lowlevel.asm b/avr/com_lowlevel.asm new file mode 100644 index 0000000..95db07a --- /dev/null +++ b/avr/com_lowlevel.asm @@ -0,0 +1,183 @@ + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; comSendByte +; +; Send a byte. +; We only set the data pin to low at the beginning for the startbit. After that +; we only change the pin direction (e.g. input vs output): +; - for 0 bit: set DDR to output, forcing the data line low +; - for 1 bit: set DDR to input, letting the external pullup R pull the data line to HIGH +; since the output pin is still set to 0 the internal pullup is disabled +; IN: +; - R16: byte to send +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R21, R22 + +comSendByte: + ldi r21, 8 ; +1 bits left + ; send startbit + cbi COM_PORT_DATA, COM_PINNUM_DATA ; +2 set DATA low + sbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as output + Utils_WaitNanoSecs COM_BIT_LENGTH, 5, r22 ; wait for one bit duration + ; send data bits +comSendByte_loop: ; 9 for low bit + lsr r16 ; 1+ bit to send -> CARRY + brcs comSendByte_setHigh ; HI: +2, LO: +1 +comSendByte_setLow: + sbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as output + Utils_WaitNanoSecs COM_BIT_LENGTH, 9, r22 + rjmp comSendByte_loopEnd ; +2 +comSendByte_setHigh: + cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE + nop ; +1 (to make pin change available) + Utils_WaitNanoSecs COM_BIT_LENGTH/2, 11, r22 ; wait for half a bit length for line to safely settle + sbis COM_PIN_DATA, COM_PINNUM_DATA ; +1 if no skip, +2 if skipped + rjmp comSendByte_error ; +2 if error (collision: we wanted line to be high but it is low) + Utils_WaitNanoSecs COM_BIT_LENGTH/2, 0, r22 +comSendByte_loopEnd: + dec r21 ; +1 + brne comSendByte_loop ; +2, sum per loop: 10 cycles + ; send stopbit + cbi COM_DDR_DATA, COM_PINNUM_DATA ; +2 set DATA as input, pullup R makes it ONE + Utils_WaitNanoSecs COM_BIT_LENGTH, 4, r22 ; wait for one bit length + sec + ret + +comSendByte_error: + clc + ret + + + +; --------------------------------------------------------------------------- +; comReceiveByte +; +; Receive a byte. +; +; IN: +; - nothing +; OUT: +; - CFLAG: set if okay, clear otherwise +; - R16: byte read (if CFLAG set) +; MODIFIED REGS: R16, R20, R21, R22 (R17) + +comReceiveByte: + cbi COM_DDR_DATA, COM_PINNUM_DATA ; set DATA port as input + cbi COM_PORT_DATA, COM_PINNUM_DATA ; disable internal pullup for DATA + + ldi r21, 8 ; bits left + clr r20 ; byte currently receiving + ; wait for startbit + rcall comWaitForDataLow ; (R17) + brcc comReceiveByte_error + Utils_WaitNanoSecs COM_BIT_LENGTH/2, 5, r22 ; goto middle of startbit to maximize sync stability +comReceiveByte_loop: + Utils_WaitNanoSecs COM_BIT_LENGTH, 8, r22 ; 8 cycles used in the complete loop between waits + sec ; +1 + sbic COM_PIN_DATA, COM_PINNUM_DATA ; LOW: +2, HIGH: +1 + rjmp comReceiveByte_shiftIn ; HIGH: +2, rjmp, use set CFLAG + clc ; LOW: +1 +comReceiveByte_shiftIn: + ror r20 ; +1 + dec r21 ; +1 + brne comReceiveByte_loop ; +2, sum per loop: 8 cycles + rcall comWaitForDataHigh ; wait for start of stopbit + brcc comReceiveByte_error + mov r16, r20 + sec + ret +comReceiveByte_error: + clc + ret + + + +; --------------------------------------------------------------------------- +; comWaitForDataLow +; +; Waits up to COM_MAXWAIT loops for low data line +; IN: +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r17, r22 + +comWaitForDataLow: + ldi r17, COM_MAXWAIT + +comWaitForDataLow_loop: + sbis COM_PIN_DATA, COM_PINNUM_DATA + rjmp comWaitForDataLow_done + Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs + dec r17 + brne comWaitForDataLow_loop + clc ; timeout + ret + +comWaitForDataLow_done: + sec ; ok + ret + + + +; --------------------------------------------------------------------------- +; comWaitForDataHigh +; +; Waits up to COM_MAXWAIT loops for high data line +; IN: +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r17, r22, X + +comWaitForDataHigh: + ldi r17, COM_MAXWAIT + +comWaitForDataHigh_loop: + sbic COM_PIN_DATA, COM_PINNUM_DATA + rjmp comWaitForDataHigh_done + Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs + dec r17 + brne comWaitForDataHigh_loop + clc ; timeout + ret + +comWaitForDataHigh_done: + sec ; ok + ret + + + +; --------------------------------------------------------------------------- +; comWaitForAttnHigh +; +; Waits up to COM_MAXWAIT loops for high ATTN line +; IN: +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r17, r22, X + +comWaitForAttnHigh: + ldi r17, COM_MAXWAIT + +comWaitForAttnHigh_loop: + sbic COM_PIN_ATTN, COM_PINNUM_ATTN + rjmp comWaitForAttnHigh_done + Utils_WaitNanoSecs 100, 0, r22 ; wait for 100 nanosecs + dec r17 + brne comWaitForAttnHigh_loop + clc ; timeout + ret + +comWaitForAttnHigh_done: + sec ; ok + ret + + + diff --git a/avr/com_recv.asm b/avr/com_recv.asm new file mode 100644 index 0000000..0cb2757 --- /dev/null +++ b/avr/com_recv.asm @@ -0,0 +1,147 @@ + +; *************************************************************************** +; code + +.cseg + + + +; --------------------------------------------------------------------------- +; comReceivePacketHandleBuffer +; +; Allocate a buffer and receive a packet into it. +; On success the buffer flags will have COM_BUFFER_FLAGS_RECEIVED set. +; On error the buffer will be deallocated. +; IN: +; - nothing +; OUT: +; - CFLAG: set if okay, cleared otherwise +; MODIFIED REGISTERS: R16, R17, X, Y (R1, R18, R19, R20, R21, R22) + +comReceivePacketHandleBuffer: + rcall COM_BufferAlloc + brcs comReceivePacketHandleBuffer_haveBuffer + ldi xl, LOW(comStatsNoBuffer) + ldi xh, HIGH(comStatsNoBuffer) + rjmp comReceivePacketHandleBuffer_errorWithCounter + +comReceivePacketHandleBuffer_haveBuffer: + ; get pos of data portion for the allocated buffer + mov xl, yl + mov xh, yh + adiw xh:xl, COM_BUFFER_OFFS_DATA + rcall comReceivePacketToXandCheck ; (r16, r17, r18, r20, r21, r22, X) + brcs comReceivePacketHandleBuffer_haveMessage + push r16 + rcall COM_BufferDeallocBack ; (r16, r17, r21) + pop r16 + cpi r16, COM_ERR_NOTFORME ; packet just not for me? + breq comReceivePacketHandleBuffer_notforme ; correct, don't count as error + ldi xl, LOW(comStatsRecvCrcErrs) + ldi xh, HIGH(comStatsRecvCrcErrs) + cpi r16, COM_ERR_CHECKSUM + breq comReceivePacketHandleBuffer_errorWithCounter + ldi xl, LOW(comStatsRecvErrs) ; generic error + ldi xh, HIGH(comStatsRecvErrs) + rjmp comReceivePacketHandleBuffer_errorWithCounter + +comReceivePacketHandleBuffer_haveMessage: + ; handle buffer flags + ldi r16, COM_BUFFER_FLAGS_RECEIVED + std y+COM_BUFFER_OFFS_FLAGS, r16 + ldi xl, LOW(comStatsPacketsIn) + ldi xh, HIGH(comStatsPacketsIn) + rcall Utils_IncrementCounter16 ; (r18, r19, 22) + sec + ret + +comReceivePacketHandleBuffer_errorWithCounter: + rcall Utils_IncrementCounter16 ; (r18, r19, 22) +comReceivePacketHandleBuffer_notforme: + clc + ret + + + +; --------------------------------------------------------------------------- +; comReceivePacketToXandCheck +; +; Receive a packet to the given SRAM position. +; IN: +; - X: pointer to start of buffer to receive bytes +; OUT: +; - CFLAG: set if okay, clear otherwise +; - R16: error code if CFLAG cleared +; MODIFIED REGISTERS: r16, r17, r18, X (r20, r21, r22) + +comReceivePacketToXandCheck: + push xh + push xl + rcall comReceivePacketToSram ; (r16, r17, R20, R21, R22, X) + pop xl + pop xh + brcc comReceivePacketToXandCheck_error + rcall cproCheckMessageInBuffer ; (R16, R17, R18, X) + ldi r16, COM_ERR_CHECKSUM + brcc comReceivePacketToXandCheck_error + sec + ret +comReceivePacketToXandCheck_error: + clc + ret + + + +; --------------------------------------------------------------------------- +; comReceivePacketToSram +; +; Receive a packet to the given SRAM position. +; IN: +; - X: pointer to start of buffer to receive bytes +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGISTERS: r16, r17, X (R20, R21, R22) + +comReceivePacketToSram: + ; read destination address + rcall comReceiveByte ; read byte (R16, R17, R20, R21, R22) + brcc comReceivePacketToSram_error + ; compare destination address (accept "00", "FF" and own address) + tst r16 + breq comReceivePacketToSram_acceptAddr + cpi r16, 0xff + breq comReceivePacketToSram_acceptAddr + lds r17, comAddress + cp r16, r17 + breq comReceivePacketToSram_acceptAddr + ldi r16, COM_ERR_NOTFORME + clc ; not for me + ret +comReceivePacketToSram_acceptAddr: + st X+, r16 ; store dest address + ; read msg length + rcall comReceiveByte ; read packet length (R16, R17, R20, R21, R22) + brcc comReceivePacketToSram_error + st X+, r16 + cpi r16, (COM_BUFFER_SIZE-3-COM_BUFFER_OFFS_DATA)+1 + brcc comReceivePacketToSram_error ; packet too long (TODO: count overruns) + inc r16 ; account for checksum byte + mov r17, r16 +comReceivePacketToSram_loop: + push r17 + rcall comReceiveByte ; read byte (R16, R17, R20, R21, R22) + pop r17 + brcc comReceivePacketToSram_error + st X+, r16 + dec r17 + brne comReceivePacketToSram_loop + sec + ret +comReceivePacketToSram_error: + ldi r16, COM_ERR_IO + clc + ret + + + + diff --git a/avr/com_send.asm b/avr/com_send.asm new file mode 100644 index 0000000..bb3e744 --- /dev/null +++ b/avr/com_send.asm @@ -0,0 +1,197 @@ + +; *************************************************************************** +; code + +.cseg + + +; --------------------------------------------------------------------------- +; comSendPacketHandleRepeat +; +; IN: +; - Y: pointer to current buffer (pointed to by comRecvBuffersReadPos) +; OUT: +; - CFLAG: set if something done, can be called again immediately (otherwise: wait for timer interrupt and retry) +; MODIFIED REGS: R15, R17, R22, X (R16, R17, R18, R21, R22) + +comSendPacketHandleRepeat: + in r15, SREG + cli + cbi COM_PORT_ATTN, COM_PINNUM_ATTN ; disable pullup on ATTN + cbi COM_DDR_ATTN, COM_PINNUM_ATTN ; set ATTN as input + nop ; needed to sample current input + sbis COM_PIN_ATTN, COM_PINNUM_ATTN ; ATTN low? + rjmp comSendPacketHandleRepeat_adjustRepeat ; jump if it is + ldd r16, y+COM_BUFFER_OFFS_FLAGS + rcall comSetupRepeat ; setup comRepeatCount if not already done (R16, R17) + cbi COM_PORT_ATTN, COM_PINNUM_ATTN ; set ATTN low + sbi COM_DDR_ATTN, COM_PINNUM_ATTN ; set ATTN as output + Utils_WaitNanoSecs COM_BIT_LENGTH, 0, r22 ; wait for one bit duration + rcall comSendPacketHandleBuffer ; (R16, R17, R21, R22) + cbi COM_DDR_ATTN, COM_PINNUM_ATTN ; release ATTN line (by setting direction to IN) + brcc comSendPacketHandleRepeat_collision + ; packet sent, adjust stats, release buffer + ldi xl, LOW(comStatsPacketsOut) + ldi xh, HIGH(comStatsPacketsOut) + rcall comDeallocReadBufAndIncrCounter ; (r16, r17, r18) + rjmp comSendPacketHandleRepeat_retC +comSendPacketHandleRepeat_collision: + ; increment collisions counter + ldi xl, LOW(comStatsCollisions) + ldi xh, HIGH(comStatsCollisions) + rcall Utils_IncrementCounter16 ; (r18, r19, 22) +comSendPacketHandleRepeat_adjustRepeat: + ; decrement repeat counter (except for vital messages) + lds r17, comRepeatCount + cpi r17, COM_REPEAT_VITAL + breq comSendPacketHandleRepeat_retNC ; vital message, repeat forever + dec r17 + sts comRepeatCount, r17 + brne comSendPacketHandleRepeat_retNC + ; dealloc buffer, inc abort counter + ldi xl, LOW(comStatsAborted) + ldi xh, HIGH(comStatsAborted) + rcall comDeallocReadBufAndIncrCounter + rjmp comSendPacketHandleRepeat_retC + +comSendPacketHandleRepeat_retNC: + out SREG, r15 + clc + ret + +comSendPacketHandleRepeat_retC: + out SREG, r15 + sec + ret + + + +; --------------------------------------------------------------------------- +; comSetupRepeat +; +; IN: +; - R16: priority +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17 + +comSetupRepeat: + lds r17, comRepeatCount + tst r17 + brne comSetupRepeat_l99 ; comRepeatCount already setup + ; set comRepeatCount according to priority + andi r16, (COM_BUFFER_FLAGS_PRIO1 | COM_BUFFER_FLAGS_PRIO0) ; r16: flags + cpi r16, COM_REPEAT_INFO + brne comSetupRepeat_l1 + ldi r17, COM_REPEAT_INFO + rjmp comSetupRepeat_l98 +comSetupRepeat_l1: + cpi r16, COM_REPEAT_NORMAL + brne comSetupRepeat_l2 + ldi r17, COM_REPEAT_NORMAL + rjmp comSetupRepeat_l98 +comSetupRepeat_l2: + cpi r16, COM_REPEAT_IMPORTANT + brne comSetupRepeat_l3 + ldi r17, COM_REPEAT_IMPORTANT + rjmp comSetupRepeat_l98 +comSetupRepeat_l3: + ldi r17, COM_REPEAT_VITAL +comSetupRepeat_l98: + sts comRepeatCount, r17 +comSetupRepeat_l99: + ret + + + +; --------------------------------------------------------------------------- +; comSendPacketHandleBuffer +; +; Send a packet from the current read buffer (pointed to by comRecvBuffersReadPos). +; On success the flag COM_BUFFER_FLAGS_DONE is set in the buffer. +; The buffer is not released. +; +; CAVE: Expects interrupts to be disabled! +; +; IN: +; - Y : pointer to current read buffer +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17 (R21, R22) + +comSendPacketHandleBuffer: + mov xl, yl + mov xh, yh + ldi r16, COM_BUFFER_OFFS_DATA + clr r17 + add xl, r16 + adc xh, r17 + ldd r16, y+(COM_BUFFER_OFFS_DATA+COM_MSG_OFFS_MSGLEN) ; get msg payload length + ldi r17, 3 + add r16, r17 ; add dest addr, msg len and XOR byte + rcall comSendPacketFromSram ; send all that + brcc comSendPacketHandleBuffer_error + ldd r16, y+COM_BUFFER_OFFS_FLAGS + ori r16, COM_BUFFER_FLAGS_DONE + std y+COM_BUFFER_OFFS_FLAGS, r16 + sec + ret +comSendPacketHandleBuffer_error: + clc + ret + + +; --------------------------------------------------------------------------- +; comSendPacketFromSram +; +; Send a packet from SRAM +; +; IN: +; - R16: number of bytes to send +; - X: pointer to buffer to read from +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17 (R21, R22) + +comSendPacketFromSram: + mov r17, r16 +comSendPacketFromSram_loop: + ld r16, X+ + rcall comSendByte ; send byte (R16, R21, R22) + brcc comSendPacketFromSram_error + dec r17 + brne comSendPacketFromSram_loop + sec + ret + +comSendPacketFromSram_error: + clc + ret + + + +; --------------------------------------------------------------------------- +; comDeallocReadBufAndIncrCounter +; +; IN: +; - X : pointer to counter +; OUT: +; - nothing +; REGS: r16, r17, r21 + +comDeallocReadBufAndIncrCounter: + rcall COM_BufferDeallocFront ; (r16, r17, r21) + ldi r21, 1 + ld r16, x+ + ld r17, x + add r16, r21 + dec r21 + adc r17, r21 + st x, r17 + st -x, r16 + sts comRepeatCount, r21 ; set comRepeatCount to zero + ret + + + + diff --git a/avr/com_twi.asm b/avr/com_twi.asm new file mode 100644 index 0000000..66b43ad --- /dev/null +++ b/avr/com_twi.asm @@ -0,0 +1,56 @@ + +; *************************************************************************** +; code + +.cseg + + +; --------------------------------------------------------------------------- +; Enqueue a TWI Bus Member packet. +; +; IN: +; - R16: destination address +; - R1 : Address of the bus member +; - R2 : availability (0=not available, 1=available) +; OUT: +; - CFLAG: set if okay, clear otherwise +; MODIFIED REGS: R16, R17, R20, X (R15, Y) + +CPRO_EnqueueTwiBusMember: + push r16 + rcall COM_AllocBufferAndGetXY ; (r16, r17, r21) + pop r16 + brcc CPRO_EnqueueTwiBusMember_error + clr r17 ; r17: XOR byte + ; write header (dest address, msg length) + st X+, r16 ; destination address + eor r17, r16 + ldi r16, 4 ; 4 bytes payload + st X+, r16 + eor r17, r16 + ; write payload + ldi r16, CPRO_CMD_TWIBUSMEMBER ; send command + st X+, r16 + eor r17, r16 + lds r16, comAddress ; send source address + st X+, r16 + eor r17, r16 + mov r16, r1 ; send i2c bus member address + st X+, r16 + eor r17, r16 + mov r16, r2 ; send i2c bus member availability + st X+, r16 + eor r17, r16 + ; store XOR byte + st X+, r17 + ; mark buffer as enqueued with PRIO "info" (limited amount of retries) + ldi r20, COM_BUFFER_PRIO_INFO + rcall COM_EnqueuePacket ; (R15, R16) + brcc CPRO_EnqueueTwiBusMember_error + sec + ret +CPRO_EnqueueTwiBusMember_error: + clc + ret + + diff --git a/avr/comproto.asm b/avr/comproto.asm index 9178f73..6b48710 100644 --- a/avr/comproto.asm +++ b/avr/comproto.asm @@ -187,10 +187,6 @@ cproHandlePing_notHandled: - - - - ; --------------------------------------------------------------------------- ; Enqueue a PING packet. ; @@ -223,443 +219,6 @@ CPRO_EnqueuePong: -#ifndef BASE_SYSTEM -; --------------------------------------------------------------------------- -; Enqueue a COM Send stats packet. -; -; IN: -; - R16: destination address -; OUT: -; - CFLAG: set if okay, clear otherwise -; MODIFIED REGS: R16, R17, R20, X (R15, Y) - -CPRO_EnqueueComSendStats: - push r15 - in r15, SREG - cli - push r16 - rcall COM_AllocBufferAndGetXY ; (r16, r17, r21) - pop r16 - brcc CPRO_EnqueueComSendStats_error - - ldi r17, CPRO_PAYLOAD_FLAGS_UID | (6< Y=buffer, X=msg + pop r16 + brcc CPRO_EnqueueComSendStats_error + + ldi r17, CPRO_PAYLOAD_FLAGS_UID | (6<