avr: introduced network module
this will be the base module for network modules.
This commit is contained in:
82
avr/modules/network/main.asm
Normal file
82
avr/modules/network/main.asm
Normal file
@@ -0,0 +1,82 @@
|
||||
; ***************************************************************************
|
||||
; 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:
|
||||
ldi xh, HIGH(networkDataBegin)
|
||||
ldi xl, LOW(networkDataBegin)
|
||||
clr r16
|
||||
ldi r17, (networkDataEnd-networkDataBegin)
|
||||
rcall Utils_FillSram ; (R17, X)
|
||||
|
||||
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
|
||||
; @param Y pointer to start of interface data
|
||||
; @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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user