t03: use router app.
This commit is contained in:
@@ -57,6 +57,7 @@
|
|||||||
|
|
||||||
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
#define MAIN_WITHOUT_MSG_HANDLING ; we do message handling ourselfes
|
||||||
#define APP_STATS_NETDEV2
|
#define APP_STATS_NETDEV2
|
||||||
|
#define APP_ROUTER_NO_ADDR_MGR
|
||||||
|
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
;#define MODULES_COM
|
;#define MODULES_COM
|
||||||
@@ -78,7 +79,8 @@
|
|||||||
;#define MODULES_COMONUART0
|
;#define MODULES_COMONUART0
|
||||||
#define MODULES_TTYONUART1
|
#define MODULES_TTYONUART1
|
||||||
#define APPS_STATS
|
#define APPS_STATS
|
||||||
#define APPS_NETWORK
|
;#define APPS_NETWORK
|
||||||
|
#define APPS_ROUTER
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -95,6 +97,7 @@
|
|||||||
.equ VALUE_ID_DS18B20_TEMP = 0x06
|
.equ VALUE_ID_DS18B20_TEMP = 0x06
|
||||||
|
|
||||||
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
.equ VALUE_ID_LEDSIMPLE_TIMING = 0x88
|
||||||
|
.equ VALUE_ID_ROUTER_SETRANGE = 0x89
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -184,13 +187,9 @@ firmwareStart:
|
|||||||
; @routine onSystemStart
|
; @routine onSystemStart
|
||||||
|
|
||||||
onSystemStart:
|
onSystemStart:
|
||||||
; set interface number for UART0
|
ldi r16, 0xf0
|
||||||
ldi r16, COMONUART0_IFACENUM
|
sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16
|
||||||
sts netInterfaceData2+NET_IFACE_OFFS_IFACENUM, r16
|
sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16
|
||||||
; set interface number for UART1
|
|
||||||
ldi r16, TTYONUART1_IFACENUM
|
|
||||||
sts ttyOnUart1_iface+NET_IFACE_OFFS_IFACENUM, r16
|
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -211,7 +210,6 @@ onEveryDay:
|
|||||||
; Called on every loop (i.e. after awakening from sleep).
|
; Called on every loop (i.e. after awakening from sleep).
|
||||||
|
|
||||||
onEveryLoop:
|
onEveryLoop:
|
||||||
rcall checkRecvdMsg
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
@@ -229,113 +227,6 @@ onMessageReceived:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine checkRecvdMsg
|
|
||||||
;
|
|
||||||
; Read messages from either interface and forward to the other one.
|
|
||||||
|
|
||||||
checkRecvdMsg:
|
|
||||||
rcall NET_PeekNextIncomingMsgNum ; check read queue (bufNum->r16)
|
|
||||||
brcc checkRecvdMsg_end ; no msg, jmp
|
|
||||||
rcall NET_Buffer_Locate ; (R17)
|
|
||||||
; let system handle incoming messages
|
|
||||||
push r16
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
adiw xh:xl, 1
|
|
||||||
rcall letSysHandleMsg
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
pop r16
|
|
||||||
|
|
||||||
; forward to other interface
|
|
||||||
ld r17, X
|
|
||||||
andi r17, (1<<NET_IFACE_BUFFER_IFACENUM1_BIT) | (1<<NET_IFACE_BUFFER_IFACENUM0_BIT)
|
|
||||||
rcall reverseInterfaceNum ; (R17)
|
|
||||||
; 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
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
letSysHandleMsg:
|
|
||||||
ld r16, X
|
|
||||||
cpi r16, 0xff
|
|
||||||
breq letSysHandleMsg_forMe
|
|
||||||
lds r17, netInterfaceData2+NET_IFACE_OFFS_ADDRESS
|
|
||||||
cp r16, r17
|
|
||||||
brne letSysHandleMsg_end
|
|
||||||
letSysHandleMsg_forMe:
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall onMessageReceived
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall mainModulesOnPacketReceived
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
push xl
|
|
||||||
push xh
|
|
||||||
rcall mainAppsOnPacketReceived
|
|
||||||
pop xh
|
|
||||||
pop xl
|
|
||||||
letSysHandleMsg_end:
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine reverseInterfaceNum
|
|
||||||
;
|
|
||||||
; @param r17 buffer num
|
|
||||||
; @return r17 reversed interface number
|
|
||||||
; @clobbers r17
|
|
||||||
|
|
||||||
reverseInterfaceNum:
|
|
||||||
andi r17, (1<<NET_IFACE_BUFFER_IFACENUM1_BIT) | (1<<NET_IFACE_BUFFER_IFACENUM0_BIT)
|
|
||||||
cpi r17, COMONUART0_IFACENUM
|
|
||||||
brne reverseInterfaceNum_notUart0
|
|
||||||
ldi r17, TTYONUART1_IFACENUM
|
|
||||||
ret
|
|
||||||
reverseInterfaceNum_notUart0:
|
|
||||||
ldi r17, COMONUART0_IFACENUM
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
|
||||||
; @routine addMsgToInterface
|
|
||||||
; @param r16 buffer num
|
|
||||||
; @param r17 interface num
|
|
||||||
|
|
||||||
addMsgToInterface:
|
|
||||||
cpi r17, COMONUART0_IFACENUM
|
|
||||||
breq addMsgToInterface_toUart0
|
|
||||||
cpi r17, TTYONUART1_IFACENUM
|
|
||||||
breq addMsgToInterface_toUart1
|
|
||||||
clc
|
|
||||||
ret
|
|
||||||
addMsgToInterface_toUart0:
|
|
||||||
ldi yl, LOW(netInterfaceData2)
|
|
||||||
ldi yh, HIGH(netInterfaceData2)
|
|
||||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
|
||||||
addMsgToInterface_toUart1:
|
|
||||||
ldi yl, LOW(ttyOnUart1_iface)
|
|
||||||
ldi yh, HIGH(ttyOnUart1_iface)
|
|
||||||
rjmp NET_Interface_AddOutgoingMsgNum ; try to add msg to interface
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user