avr: more work on basic device code.
This commit is contained in:
@@ -24,7 +24,9 @@
|
|||||||
<subdirs>
|
<subdirs>
|
||||||
all
|
all
|
||||||
n21
|
n21
|
||||||
|
n22
|
||||||
n23
|
n23
|
||||||
|
t03
|
||||||
</subdirs>
|
</subdirs>
|
||||||
|
|
||||||
</gwbuild>
|
</gwbuild>
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ initApps:
|
|||||||
#ifdef APPS_STATS
|
#ifdef APPS_STATS
|
||||||
rcall AppStats_Init
|
rcall AppStats_Init
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef APPS_MA_LIGHT
|
||||||
|
rcall AppMotionLight_Init
|
||||||
|
#endif
|
||||||
|
|
||||||
; done
|
; done
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
.include "modules/network/msg/common.asm"
|
.include "modules/network/msg/common.asm"
|
||||||
.include "modules/network/msg/crc.asm"
|
.include "modules/network/msg/crc.asm"
|
||||||
.include "modules/network/msg/value-w.asm"
|
.include "modules/network/msg/value-w.asm"
|
||||||
|
.include "modules/network/msg/value-r.asm"
|
||||||
.include "modules/network/msg/addr-r.asm"
|
.include "modules/network/msg/addr-r.asm"
|
||||||
.include "modules/network/msg/addr-w.asm"
|
.include "modules/network/msg/addr-w.asm"
|
||||||
#endif
|
#endif
|
||||||
@@ -134,4 +135,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef APPS_MA_LIGHT
|
||||||
|
.include "apps/ma_light/defs.asm"
|
||||||
|
.include "apps/ma_light/data.asm"
|
||||||
|
.include "apps/ma_light/main.asm"
|
||||||
|
.include "apps/ma_light/recv.asm"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -53,13 +53,6 @@ main:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
main_loop:
|
main_loop:
|
||||||
rcall runModules
|
|
||||||
rcall runApps
|
|
||||||
|
|
||||||
#ifdef MODULES_NETWORK
|
|
||||||
rcall handleMessages
|
|
||||||
#endif
|
|
||||||
|
|
||||||
; only modify SE, SM1 and SM0
|
; only modify SE, SM1 and SM0
|
||||||
cli
|
cli
|
||||||
in r16, MCUCR
|
in r16, MCUCR
|
||||||
@@ -70,6 +63,14 @@ main_loop:
|
|||||||
out MCUCR, r16
|
out MCUCR, r16
|
||||||
sei ; make sure interrupts really are enabled
|
sei ; make sure interrupts really are enabled
|
||||||
sleep ; sleep, wait for interrupt
|
sleep ; sleep, wait for interrupt
|
||||||
|
|
||||||
|
rcall runModules
|
||||||
|
rcall runApps
|
||||||
|
|
||||||
|
#ifdef MODULES_NETWORK
|
||||||
|
rcall handleMessages
|
||||||
|
#endif
|
||||||
|
|
||||||
rjmp main_loop
|
rjmp main_loop
|
||||||
|
|
||||||
main_loop_reboot:
|
main_loop_reboot:
|
||||||
@@ -118,6 +119,10 @@ onSystemTimerTick:
|
|||||||
rcall AppDoor_Every100ms
|
rcall AppDoor_Every100ms
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef APPS_MA_LIGHT
|
||||||
|
rcall AppMotionLight_Every100ms
|
||||||
|
#endif
|
||||||
|
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,11 @@ handleMessages:
|
|||||||
rcall AppNetwork_HandleMsg
|
rcall AppNetwork_HandleMsg
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef APPS_MA_LIGHT
|
||||||
|
rcall AppMotionLight_OnPacketReceived
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
; add more here
|
; add more here
|
||||||
pop r16
|
pop r16
|
||||||
rcall NET_Buffer_ReleaseByNum
|
rcall NET_Buffer_ReleaseByNum
|
||||||
|
|||||||
@@ -26,21 +26,18 @@
|
|||||||
|
|
||||||
Main_SendValueReport:
|
Main_SendValueReport:
|
||||||
push r17
|
push r17
|
||||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||||
pop r17
|
pop r17
|
||||||
brcc Main_SendValueReport_end ; jmp on error
|
brcc Main_SendValueReport_end ; jmp on error
|
||||||
push r16 ; buffer num
|
push r16 ; buffer num
|
||||||
ldi r16, 0xff ; DEST addr
|
ldi r16, 0xff ; DEST addr
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
rcall NETMSG_ValueWriteReport ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
||||||
sbiw xh:xl, 1
|
sbiw xh:xl, 1
|
||||||
pop r16 ; buffer num
|
pop r16 ; buffer num
|
||||||
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
|
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||||
brcs Main_SendValueReport_end ; jump if okay
|
|
||||||
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
|
|
||||||
clc
|
|
||||||
Main_SendValueReport_end:
|
Main_SendValueReport_end:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
@@ -53,27 +50,24 @@ Main_SendValueReport_end:
|
|||||||
; @param R17 value id
|
; @param R17 value id
|
||||||
; @param R19:R18 value
|
; @param R19:R18 value
|
||||||
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
|
; @param R21:R20 denom (e.g. 100, meaning value must be divided by 100)
|
||||||
; @param R22 value type
|
|
||||||
; @param R23 command
|
; @param R23 command
|
||||||
; @param R25:R24 ref msg id
|
; @param R25:R24 ref msg id
|
||||||
|
|
||||||
Main_SendValueResponse:
|
Main_SendValueResponse:
|
||||||
push r17
|
push r17
|
||||||
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
rcall NET_Buffer_Alloc ; (R16, R17, X)
|
||||||
pop r17
|
pop r17
|
||||||
brcc Main_SendValueResponse_end ; jmp on error
|
brcc Main_SendValueResponse_end ; jmp on error
|
||||||
push r16 ; buffer num
|
push r16 ; buffer num
|
||||||
ldi r16, 0xff ; DEST addr
|
ldi r16, 0xff ; DEST addr
|
||||||
|
clr r22 ; value type
|
||||||
adiw xh:xl, 1
|
adiw xh:xl, 1
|
||||||
ldi yl, LOW(netInterfaceData)
|
ldi yl, LOW(netInterfaceData)
|
||||||
ldi yh, HIGH(netInterfaceData)
|
ldi yh, HIGH(netInterfaceData)
|
||||||
rcall NETMSG_ValueWriteResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
rcall NETMSG_ValueWriteResponse ; (R16, R17, R18, R19, R20, R21, R23, R24, R25)
|
||||||
sbiw xh:xl, 1
|
sbiw xh:xl, 1
|
||||||
pop r16 ; buffer num
|
pop r16 ; buffer num
|
||||||
rcall NET_Interface_AddOutgoingMsgNum ; (R17, R18, X)
|
rcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X)
|
||||||
brcs Main_SendValueResponse_end ; jump if okay
|
|
||||||
rcall NET_Buffer_ReleaseByNum ; otherwise release buffer
|
|
||||||
clc
|
|
||||||
Main_SendValueResponse_end:
|
Main_SendValueResponse_end:
|
||||||
ret
|
ret
|
||||||
; @end
|
; @end
|
||||||
|
|||||||
Reference in New Issue
Block a user