Files
aqhomecontrol/avr/modules/network/main.asm
2025-03-23 01:08:33 +01:00

105 lines
2.5 KiB
NASM

; ***************************************************************************
; copyright : (C) 2025 by Martin Preuss
; email : martin@libchipcard.de
;
; ***************************************************************************
; * This file is part of the project "AqHome". *
; * Please see toplevel file COPYING of that project for license details. *
; ***************************************************************************
.cseg
; ---------------------------------------------------------------------------
; @routine NET_Init
;
; Initializes buffers.
;
; @clobbers R16, R17, X
NET_Init:
#if 0
ldi xh, HIGH(networkDataBegin)
ldi xl, LOW(networkDataBegin)
clr r16
ldi r17, (networkDataEnd-networkDataBegin)
rcall Utils_FillSram ; (R17, X)
#endif
rcall NET_Buffer_Init ; (R16, R17, X)
ldi r16, NET_MSGNUMINBUF_SIZE
ldi yl, LOW(netRingBufferMsgNumIn)
ldi yh, HIGH(netRingBufferMsgNumIn)
rcall RingBufferY_Init ; (R17)
sec
ret
; @end
; ---------------------------------------------------------------------------
; @routine NET_AddIncomingMsgNum @global
;
; @return CFLAG on success, cleared on error
; @param R16 buffer number of the next incoming message
; @clobbers R17, R18, X
NET_AddIncomingMsgNum:
push yl
push yh
ldi yl, LOW(netRingBufferMsgNumIn)
ldi yh, HIGH(netRingBufferMsgNumIn)
rcall RingBufferY_WriteByteGuarded ; R17, R18, X
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine NET_GetNextIncomingMsgNum @global
;
; @return CFLAG on success, cleared on error
; @return R16 buffer number of the next incoming message
; @clobbers R17, R18, X
NET_GetNextIncomingMsgNum:
push yl
push yh
ldi yl, LOW(netRingBufferMsgNumIn)
ldi yh, HIGH(netRingBufferMsgNumIn)
rcall RingBufferY_ReadByteGuarded ; R17, R18, X
pop yh
pop yl
ret
; @end
; ---------------------------------------------------------------------------
; @routine NET_GetPeekIncomingMsgNum @global
;
; @return CFLAG on success, cleared on error
; @return R16 buffer number of the next incoming message
; @param Y pointer to start of interface data
; @clobbers R17, R18, X
NET_PeekNextIncomingMsgNum:
push yl
push yh
ldi yl, LOW(netRingBufferMsgNumIn)
ldi yh, HIGH(netRingBufferMsgNumIn)
rcall RingBufferY_PeekByteGuarded ; R17, R18, X
pop yh
pop yl
ret
; @end