avr: introduced network module
this will be the base module for network modules.
This commit is contained in:
130
avr/modules/network/iface.asm
Normal file
130
avr/modules/network/iface.asm
Normal file
@@ -0,0 +1,130 @@
|
||||
; ***************************************************************************
|
||||
; 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_Interface_Init @global
|
||||
;
|
||||
; @param Y pointer to interface data in SRAM
|
||||
; @clobbers R16, R17, X
|
||||
|
||||
NET_Interface_Init:
|
||||
mov xl, yl
|
||||
mov xh, yh
|
||||
ldi r17, NET_IFACE_SIZE
|
||||
clr r16
|
||||
rcall Utils_FillSram ; (R17, X)
|
||||
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, NET_IFACE_OFFS_OUTMSGRINGBUF
|
||||
ldi r16, NET_IFACE_OUTMSGBUF_SIZE
|
||||
rcall RingBufferY_Init
|
||||
pop yh
|
||||
pop yl
|
||||
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NET_Interface_AddOutgoingMsgNum @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @param r16 byte to write
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
NET_Interface_AddOutgoingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, NET_IFACE_OFFS_OUTMSGRINGBUF
|
||||
rcall RingBufferY_WriteByteGuarded ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NET_Interface_GetNextOutgoingMsgNum @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @return R16 byte read
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
NET_Interface_GetNextOutgoingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, NET_IFACE_OFFS_OUTMSGRINGBUF
|
||||
rcall RingBufferY_ReadByteGuarded ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NET_Interface_PeekNextOutgoingMsgNum @global
|
||||
;
|
||||
; @return CFLAG on success, cleared on error
|
||||
; @return R16 byte read
|
||||
; @param Y pointer to start of interface data
|
||||
; @clobbers R17, R18, X
|
||||
|
||||
NET_Interface_PeekNextOutgoingMsgNum:
|
||||
push yl
|
||||
push yh
|
||||
adiw yh:yl, NET_IFACE_OFFS_OUTMSGRINGBUF
|
||||
rcall RingBufferY_PeekByteGuarded ; R17, R18, X
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
; ---------------------------------------------------------------------------
|
||||
; @routine NET_Interface_IncCounter16 @global
|
||||
;
|
||||
; @param Y pointer to start of interface data
|
||||
; @param R16 offset to Y for counter to increment
|
||||
; @clobbers R24, R25
|
||||
|
||||
NET_Interface_IncCounter16:
|
||||
add yl, r16
|
||||
adc yh, r16
|
||||
sub yh, r16
|
||||
ld r24, Y+
|
||||
ld r25, Y
|
||||
sbiw yh:yl, 1
|
||||
adiw r25:r24, 1
|
||||
breq NET_Interface_IncCounter16_end
|
||||
st Y+, r24
|
||||
st Y, r25
|
||||
sbiw yh:yl, 1
|
||||
NET_Interface_IncCounter16_end:
|
||||
sub yl, r16
|
||||
sbc yh, r16
|
||||
add yh, r16
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user