avr/t03: more tests.

This commit is contained in:
Martin Preuss
2025-03-22 13:00:35 +01:00
parent 0f598a5552
commit 8586269033

View File

@@ -171,9 +171,11 @@ main_loop:
rcall BaseTimer_Run
rcall TtyOnUart1_Run
rcall ComOnUart0_Run
; check incoming msg
rcall checkRecvdMsg
; rcall freeRecvdMsg
rjmp main_loop
@@ -205,11 +207,12 @@ onSystemTimerTick:
rcall LedSimple_Every100ms
#endif
rcall TtyOnUart1_Periodically
rcall sendDebug
rcall maybeSendDeviceMsg
rcall ComOnUart0_Periodically
; rcall sendDebug
; rcall maybeSendDeviceMsg
rcall maybeSendTStatsMsg
rcall maybeSendRStatsMsg
rcall maybeSendMStatsMsg
; rcall maybeSendMStatsMsg
ret
@@ -386,23 +389,10 @@ maybeSendRStatsMsg:
lds r25, sendRStatsCounter+1
sbiw r25:r24, 1
brne maybeSendRStatsMsg_storeCounter
; send device msg
rcall NET_Buffer_Alloc ; (R16, R17, X)
; brcc maybeSendTStatsMsg_resetCounter
brcc maybeSendRStatsMsg_end
push r16
push yl
push yh
ldi yl, LOW(comOnUart0_iface)
ldi yh, HIGH(comOnUart0_iface)
adiw xh:xl, 1
rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
sbiw xh:xl, 1
pop yh
pop yl
pop r16
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
brcc maybeSendRStatsMsg_end
rcall sendRStatsForUart0ToUart1
rcall sendRStatsForUart1ToUart1
; reset counter
maybeSendRStatsMsg_resetCounter:
ldi r24, LOW(SEND_STATS_EVERY)
@@ -415,6 +405,50 @@ maybeSendRStatsMsg_end:
sendRStatsForUart0ToUart1:
push yl
push yh
; send device msg
rcall NET_Buffer_Alloc ; (R16, R17, X)
brcc sendRStatsForUart0ToUart1_end
push r16
ldi yl, LOW(comOnUart0_iface)
ldi yh, HIGH(comOnUart0_iface)
adiw xh:xl, 1
rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
sbiw xh:xl, 1
pop r16
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
sendRStatsForUart0ToUart1_end:
pop yh
pop yl
ret
sendRStatsForUart1ToUart1:
push yl
push yh
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
; send device msg
rcall NET_Buffer_Alloc ; (R16, R17, X)
brcc sendRStatsForUart1ToUart1_end
push r16
adiw xh:xl, 1
rcall NETMSG_RecvStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
sbiw xh:xl, 1
pop r16
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
sendRStatsForUart1ToUart1_end:
pop yh
pop yl
ret
maybeSendMStatsMsg:
ldi yl, LOW(ttyOnUart1_iface)
ldi yh, HIGH(ttyOnUart1_iface)
@@ -464,7 +498,8 @@ checkRecvdMsg_sendMsg:
sbiw xh:xl, 1
ld r17, X
andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT)
rcall reverseInterfaceNum
; rcall reverseInterfaceNum
ldi r17, TTYONUART1_IFACENUM ; DEBUG: send everything to uart1 to test that code first
rcall addMsgToInterface
brcc checkRecvdMsg_end ; could not add, jmp
rcall NET_GetNextIncomingMsgNum ; take off the queue
@@ -474,6 +509,15 @@ checkRecvdMsg_end:
freeRecvdMsg:
rcall NET_GetNextIncomingMsgNum ; take off the queue
brcc freeRecvdMsg_end
rcall NET_Buffer_ReleaseByNum ; delete
freeRecvdMsg_end:
ret
; @return r17 reversed interface number
; @param r17 buffer num
; @clobbers r17