r05: no longer use APPS_NETWORK.
Implemented some of those features in APP_ROUTER like PING, REBOOT.
This commit is contained in:
@@ -20,6 +20,19 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ***************************************************************************
|
||||||
|
; data
|
||||||
|
|
||||||
|
.dseg
|
||||||
|
|
||||||
|
appRouterDataBegin:
|
||||||
|
appRouterRangeBegin: .byte 1
|
||||||
|
appRouterRangeEnd: .byte 1
|
||||||
|
appRouterDataEnd:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ***************************************************************************
|
; ***************************************************************************
|
||||||
; code
|
; code
|
||||||
|
|
||||||
@@ -29,6 +42,20 @@
|
|||||||
; @routine AppRouter_Init @global
|
; @routine AppRouter_Init @global
|
||||||
|
|
||||||
AppRouter_Init:
|
AppRouter_Init:
|
||||||
|
ldi xh, HIGH(appRouterDataBegin)
|
||||||
|
ldi xl, LOW(appRouterDataBegin)
|
||||||
|
clr r16
|
||||||
|
ldi r17, (appRouterDataEnd-appRouterDataBegin)
|
||||||
|
rcall Utils_FillSram
|
||||||
|
|
||||||
|
ldi r16, 0xe0 ; default range from 0xe0-0xef (will be changed later)
|
||||||
|
sts netInterfaceData+NET_IFACE_OFFS_ADDRESS, r16 ; use first address for router itself
|
||||||
|
sts netInterfaceData2+NET_IFACE_OFFS_ADDRESS, r16 ; use same address for both interfaces to save on addresses
|
||||||
|
inc r16
|
||||||
|
sts appRouterRangeBegin, r16 ; range from router+1
|
||||||
|
ldi r16, 0xef
|
||||||
|
sts appRouterRangeEnd, r16
|
||||||
|
|
||||||
; set interface number for NETDEV0
|
; set interface number for NETDEV0
|
||||||
ldi r16, NETDEV0_IFACENUM
|
ldi r16, NETDEV0_IFACENUM
|
||||||
sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16
|
sts netInterfaceData+NET_IFACE_OFFS_IFACENUM, r16
|
||||||
@@ -40,6 +67,24 @@ AppRouter_Init:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine AppRouter_EveryDay @global
|
||||||
|
;
|
||||||
|
; @clobbers R16, R17, X
|
||||||
|
|
||||||
|
AppRouter_EveryDay:
|
||||||
|
ldi yl, LOW(netInterfaceData)
|
||||||
|
ldi yh, HIGH(netInterfaceData)
|
||||||
|
bigcall NET_Interface_ResetStats ; (R16, R17, X)
|
||||||
|
|
||||||
|
ldi yl, LOW(netInterfaceData2)
|
||||||
|
ldi yh, HIGH(netInterfaceData2)
|
||||||
|
bigcall NET_Interface_ResetStats ; (R16, R17, X)
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine AppRouter_Run @global
|
; @routine AppRouter_Run @global
|
||||||
;
|
;
|
||||||
@@ -51,6 +96,83 @@ AppRouter_Run:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine AppRouter_HandleMsg @global
|
||||||
|
;
|
||||||
|
; @param X pointer to received message
|
||||||
|
|
||||||
|
AppRouter_HandleMsg:
|
||||||
|
adiw xh:xl, NETMSG_OFFS_CMD ; maybe move ping/reboot handling to all/main.asm?
|
||||||
|
ld r16, X
|
||||||
|
sbiw xh:xl, NETMSG_OFFS_CMD
|
||||||
|
cpi r16, NETMSG_CMD_REBOOT_REQUEST
|
||||||
|
breq AppRouter_HandleMsg_handleRebootMsg
|
||||||
|
cpi r16, NETMSG_CMD_PING
|
||||||
|
breq AppRouter_HandleMsg_handlePingMsg
|
||||||
|
rjmp AppRouter_HandleMsg_clcRet
|
||||||
|
AppRouter_HandleMsg_handleRebootMsg:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall appRouterHandleRebootRequest
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
ret
|
||||||
|
AppRouter_HandleMsg_handlePingMsg:
|
||||||
|
push xl
|
||||||
|
push xh
|
||||||
|
rcall appRouterHandlePingRequest
|
||||||
|
pop xh
|
||||||
|
pop xl
|
||||||
|
ret
|
||||||
|
AppRouter_HandleMsg_clcRet:
|
||||||
|
clc
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; ---------------------------------------------------------------------------
|
||||||
|
; @routine appRouterHandleRebootRequest
|
||||||
|
;
|
||||||
|
; @param X pointer to received message
|
||||||
|
|
||||||
|
appRouterHandleRebootRequest:
|
||||||
|
ld r16, X ; dest addr
|
||||||
|
cpi r16, 0xff ; don't reboot for broadcast address
|
||||||
|
breq appRouterHandleRebootRequest_end
|
||||||
|
|
||||||
|
rcall NETMSG_RebootRequestRead
|
||||||
|
brcc appRouterHandleRebootRequest_end
|
||||||
|
; reboot
|
||||||
|
cli
|
||||||
|
bigjmp BOOTLOADER_ADDR
|
||||||
|
appRouterHandleRebootRequest_end:
|
||||||
|
ret
|
||||||
|
; @end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
appRouterHandlePingRequest:
|
||||||
|
adiw xh:xl, NETMSG_OFFS_SRCADDR
|
||||||
|
ld r17, X
|
||||||
|
push r17
|
||||||
|
bigcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||||
|
pop r17
|
||||||
|
brcc appRouterHandlePingRequest_end ; jmp on error
|
||||||
|
push r16 ; buffer num
|
||||||
|
mov r16, r17 ; DEST addr
|
||||||
|
adiw xh:xl, 1
|
||||||
|
ldi yl, LOW(netInterfaceData)
|
||||||
|
ldi yh, HIGH(netInterfaceData)
|
||||||
|
bigcall NETMSG_Pong_Write ; (R16, R17, R18, R19, R20, X)
|
||||||
|
sbiw xh:xl, 1
|
||||||
|
pop r16 ; buffer num
|
||||||
|
bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||||
|
appRouterHandlePingRequest_end:
|
||||||
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine appRouterCheckRecvdMsg
|
; @routine appRouterCheckRecvdMsg
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -89,6 +89,10 @@ mainAppsOnPacketReceived:
|
|||||||
bigcall AppNetwork_HandleMsg
|
bigcall AppNetwork_HandleMsg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef APPS_ROUTER
|
||||||
|
bigcall AppRouter_HandleMsg
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef APPS_MA_LIGHT
|
#ifdef APPS_MA_LIGHT
|
||||||
bigcall AppMotionLight_OnPacketReceived
|
bigcall AppMotionLight_OnPacketReceived
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -244,6 +244,9 @@
|
|||||||
|
|
||||||
#ifdef APPS_ROUTER
|
#ifdef APPS_ROUTER
|
||||||
.include "apps/router/main.asm"
|
.include "apps/router/main.asm"
|
||||||
|
.include "modules/network/msg/reboot-d.asm"
|
||||||
|
.include "modules/network/msg/reboot-r.asm"
|
||||||
|
.include "modules/network/msg/pong-w.asm"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ sysOnEveryDay:
|
|||||||
bigcall AppNetwork_EveryDay
|
bigcall AppNetwork_EveryDay
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef APPS_ROUTER
|
||||||
|
bigcall AppRouter_EveryDay
|
||||||
|
#endif
|
||||||
|
|
||||||
bigjmp onEveryDay
|
bigjmp onEveryDay
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define MAIN_WITHOUT_MSG_HANDLING ; message handling in AppRouter!
|
#define MAIN_WITHOUT_MSG_HANDLING ; message handling in AppRouter!
|
||||||
|
#define APP_STATS_NETDEV2 ; send stats for 2nd device
|
||||||
|
|
||||||
#define MODULES_CLOCK
|
#define MODULES_CLOCK
|
||||||
#define MODULES_LED_SIMPLE
|
#define MODULES_LED_SIMPLE
|
||||||
@@ -70,7 +71,7 @@
|
|||||||
#define MODULES_NETWORK
|
#define MODULES_NETWORK
|
||||||
#define MODULES_COMONUART0
|
#define MODULES_COMONUART0
|
||||||
#define MODULES_COMONUART1
|
#define MODULES_COMONUART1
|
||||||
#define APPS_NETWORK
|
;#define APPS_NETWORK
|
||||||
#define APPS_ROUTER
|
#define APPS_ROUTER
|
||||||
|
|
||||||
|
|
||||||
@@ -168,18 +169,13 @@ onSystemStart:
|
|||||||
|
|
||||||
onEvery100ms:
|
onEvery100ms:
|
||||||
onEverySecond:
|
onEverySecond:
|
||||||
|
onEveryMinute:
|
||||||
onEveryHour:
|
onEveryHour:
|
||||||
onEveryDay:
|
onEveryDay:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
onEveryMinute:
|
|
||||||
ret
|
|
||||||
; @end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
; ---------------------------------------------------------------------------
|
; ---------------------------------------------------------------------------
|
||||||
; @routine onEveryLoop
|
; @routine onEveryLoop
|
||||||
;
|
;
|
||||||
|
|||||||
Reference in New Issue
Block a user