avr/uart_hw, t03: cross messaging now works!!
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
; ---------------------------------------------------------------------------
|
||||
; COM module
|
||||
|
||||
.equ COM_BIT_LENGTH = 52000 ; 104000ns=9600, 52000ns=19200, 26000ns=38400
|
||||
|
||||
.equ COM_ATTN_DDR = DDRA
|
||||
.equ COM_ATTN_INPUT = PINA
|
||||
.equ COM_ATTN_OUTPUT = PORTA
|
||||
|
||||
@@ -212,7 +212,7 @@ onSystemTimerTick:
|
||||
; rcall maybeSendDeviceMsg
|
||||
rcall maybeSendTStatsMsg
|
||||
rcall maybeSendRStatsMsg
|
||||
; rcall maybeSendMStatsMsg
|
||||
rcall maybeSendMStatsMsg
|
||||
ret
|
||||
|
||||
|
||||
@@ -286,6 +286,7 @@ initModules:
|
||||
; includes
|
||||
|
||||
.include "common/utils.asm"
|
||||
.include "common/utils_wait.asm"
|
||||
.include "common/utils_wait_fixed.asm"
|
||||
.include "common/utils_copy_from_flash.asm"
|
||||
.include "common/utils_copy_sdram.asm"
|
||||
@@ -358,17 +359,9 @@ maybeSendTStatsMsg:
|
||||
lds r25, sendTStatsCounter+1
|
||||
sbiw r25:r24, 1
|
||||
brne maybeSendTStatsMsg_storeCounter
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
; brcc maybeSendTStatsMsg_resetCounter
|
||||
brcc maybeSendTStatsMsg_end
|
||||
push r16
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_SendStats_Write ; (R16, R17, R18, R19, R20, R21, Z)
|
||||
sbiw xh:xl, 1
|
||||
pop r16
|
||||
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||
brcc maybeSendTStatsMsg_end
|
||||
|
||||
rcall sendTStatsForUart0ToUart1
|
||||
|
||||
; reset counter
|
||||
maybeSendTStatsMsg_resetCounter:
|
||||
ldi r24, LOW(SEND_STATS_EVERY)
|
||||
@@ -380,6 +373,28 @@ maybeSendTStatsMsg_end:
|
||||
ret
|
||||
|
||||
|
||||
sendTStatsForUart0ToUart1:
|
||||
push yl
|
||||
push yh
|
||||
; send device msg
|
||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||
brcc sendTStatsForUart0ToUart1_end
|
||||
push r16
|
||||
ldi yl, LOW(comOnUart0_iface)
|
||||
ldi yh, HIGH(comOnUart0_iface)
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_SendStats_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)
|
||||
sendTStatsForUart0ToUart1_end:
|
||||
pop yh
|
||||
pop yl
|
||||
ret
|
||||
|
||||
|
||||
|
||||
maybeSendRStatsMsg:
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
@@ -391,7 +406,7 @@ maybeSendRStatsMsg:
|
||||
brne maybeSendRStatsMsg_storeCounter
|
||||
|
||||
rcall sendRStatsForUart0ToUart1
|
||||
rcall sendRStatsForUart1ToUart1
|
||||
; rcall sendRStatsForUart1ToUart1
|
||||
|
||||
; reset counter
|
||||
maybeSendRStatsMsg_resetCounter:
|
||||
@@ -481,29 +496,32 @@ maybeSendMStatsMsg_end:
|
||||
|
||||
|
||||
checkRecvdMsg:
|
||||
rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16)
|
||||
brcc checkRecvdMsg_end ; no msg, jmp
|
||||
rcall NET_Buffer_Locate ; (R17)
|
||||
adiw xh:xl, 1
|
||||
push r16
|
||||
rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X)
|
||||
pop r16
|
||||
brcs checkRecvdMsg_sendMsg
|
||||
; release buffer
|
||||
rcall NET_GetNextIncomingMsgNum ; take off the queue
|
||||
rcall NET_Buffer_ReleaseByNum ; delete
|
||||
clc
|
||||
rjmp checkRecvdMsg_end
|
||||
checkRecvdMsg_sendMsg:
|
||||
sbiw xh:xl, 1
|
||||
ld r17, X
|
||||
andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT)
|
||||
; 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
|
||||
sec
|
||||
rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16)
|
||||
brcc checkRecvdMsg_end ; no msg, jmp
|
||||
rcall NET_Buffer_Locate ; (R17)
|
||||
push r16
|
||||
push xl
|
||||
push xh
|
||||
adiw xh:xl, 1
|
||||
rcall NETMSG_CheckMessageInBuffer ; (R16, R17, R18, R19, R20, X)
|
||||
pop xh
|
||||
pop xl
|
||||
pop r16
|
||||
brcs checkRecvdMsg_sendMsg
|
||||
; release buffer
|
||||
rcall NET_GetNextIncomingMsgNum ; take off the queue
|
||||
rcall NET_Buffer_ReleaseByNum ; delete
|
||||
clc
|
||||
rjmp checkRecvdMsg_end
|
||||
checkRecvdMsg_sendMsg:
|
||||
ld r17, X
|
||||
andi r17, (NET_IFACE_BUFFER_IFACENUM1_BIT | NET_IFACE_BUFFER_IFACENUM0_BIT)
|
||||
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
|
||||
rjmp checkRecvdMsg
|
||||
checkRecvdMsg_end:
|
||||
ret
|
||||
|
||||
@@ -538,18 +556,19 @@ reverseInterfaceNum_notUart0:
|
||||
; @param r17 interface num
|
||||
|
||||
addMsgToInterface:
|
||||
cpi r16, COMONUART0_IFACENUM
|
||||
cpi r17, COMONUART0_IFACENUM
|
||||
brne addMsgToInterface_notUart0
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
||||
addMsgToInterface_notUart0:
|
||||
cpi r16, TTYONUART1_IFACENUM
|
||||
brne addMsgToInterface_end
|
||||
ldi yl, LOW(comOnUart0_iface)
|
||||
ldi yh, HIGH(comOnUart0_iface)
|
||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
||||
addMsgToInterface_notUart0:
|
||||
cpi r17, TTYONUART1_IFACENUM
|
||||
brne addMsgToInterface_end
|
||||
ldi yl, LOW(ttyOnUart1_iface)
|
||||
ldi yh, HIGH(ttyOnUart1_iface)
|
||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
||||
addMsgToInterface_end:
|
||||
clc
|
||||
ret
|
||||
; @end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user