avr: make COM2 buffer functions macros.

This commit is contained in:
Martin Preuss
2024-10-20 18:40:24 +02:00
parent d7705590fe
commit 3cba4a1f7c
2 changed files with 191 additions and 84 deletions

View File

@@ -8,6 +8,9 @@
; ***************************************************************************
.include "modules/com2/buffer.asm"
; ***************************************************************************
; data
@@ -19,6 +22,7 @@ com2DataBegin:
com2Address: .byte 1
com2Interrupts: .byte 2
com2LastMsgId: .byte 2
com2RecvStatsBegin: ; 12 bytes
com2StatsPacketsIn: .byte 2
@@ -26,7 +30,6 @@ com2RecvStatsBegin: ; 12 bytes
com2StatsIoError: .byte 2
com2StatsNoBufferError: .byte 2
com2StatsHandled: .byte 2
com2StatsNotForMe: .byte 2
com2StatsMissed: .byte 2 ; currently not used
com2RecvStatsEnd:
@@ -36,6 +39,7 @@ com2SendStatsBegin: ; 6 bytes
com2StatsBusyError: .byte 2
com2SendStatsEnd:
com2StatsNotForMe: .byte 2
com2StatsIgnored: .byte 2
com2RecvBuffersUsed: .byte 1
@@ -399,6 +403,78 @@ COM2_SendPacket_okay:
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; Buffer Management
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; ---------------------------------------------------------------------------
; @routine COM2_BufferAlloc
;
; Allocate a transfer buffer.
;
; @return CFLAG set if okay, clear otherwise
; @return X pointer to allocated buffer in SRAM
; @clobbers r16, r17, r21
COM2_BufferAlloc:
COM2_M_BufferAlloc COM2_BUFFER_NUM, com2MaxBuffersUsed, com2RecvBuffersUsed, com2RecvBuffersWritePos
ret
; @end
; ---------------------------------------------------------------------------
; @routine COM2_BufferDeallocBack
;
; Release a transfer buffer at the end of the list by decreasing the write pos.
; This releases the last allocated buffer!
;
; @return CFLAG set if okay, clear otherwise
; @clobbers r16, r17, r21
COM2_BufferDeallocBack:
COM2_M_BufferDeallocBack COM2_BUFFER_NUM, com2RecvBuffersUsed, com2RecvBuffersWritePos
ret
; @end
; ---------------------------------------------------------------------------
; @routine COM2_BufferDeallocFront
;
; Release a transfer buffer by increasing the read pos.
;
; @return CFLAG set if okay, clear otherwise
; @clobbers r16, r17, r21
COM2_BufferDeallocFront:
COM2_M_BufferDeallocFront COM2_BUFFER_NUM, com2RecvBuffersUsed, com2RecvBuffersReadPos
ret
; @end
; ---------------------------------------------------------------------------
; @routine COM2_BufferPosToX
;
; Get a pointer to the SRAM position of the given buffer.
; CAVE: Code must correspond to COM2_BUFFER_SIZE!!
;
; @param R16 buffer number (starting with 0)
; @return X pointer to buffer in SRAM
; @clobbers R16, R17
COM2_BufferPosToX:
COM2_M_BufferPosToX com2RecvBuffers
ret
; @end
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; ISR
; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -451,7 +527,6 @@ com2IsrPcint0_end:
.include "modules/com2/packets.asm"
.include "modules/com2/lowlevel.asm"
.include "modules/com2/buffer.asm"
.include "modules/com2/crc.asm"