From f7a66d6d81435dafac1b7914e1677647422a6e07 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 30 Mar 2026 00:19:05 +0200 Subject: [PATCH] n30: for code size reduction we don't use stats app. But we need to send DEVICE msg. --- avr/devices/n30/main/main.asm | 54 ++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/avr/devices/n30/main/main.asm b/avr/devices/n30/main/main.asm index ba93b69..ada43fa 100644 --- a/avr/devices/n30/main/main.asm +++ b/avr/devices/n30/main/main.asm @@ -45,6 +45,7 @@ .equ NET_MSGNUMINBUF_SIZE = 8 ; max buffer nums in ringbuffer (global incoming) .equ NET_IFACE_OUTMSGBUF_SIZE = 8 ; max buffer nums in ringbuffer (per interface outbound) +.equ DEVICE_SEND_MINUTES = 3 ; send "DEVICE" message very 3 minutes ; --------------------------------------------------------------------------- @@ -146,6 +147,8 @@ firmwareStart: ; @routine onSystemStart onSystemStart: + ldi r16, DEVICE_SEND_MINUTES + sts minuteCounter, r16 ret ; @end @@ -169,12 +172,34 @@ onMessageReceived: ; Called every 100ms. Add your routine calls here. No arguments, no results. onEvery100ms: -onEveryMinute: onEveryHour: onEveryDay: ret ; @end + + +onEveryMinute: + lds r16, minuteCounter + dec r16 + sts minuteCounter, r16 + brne onEveryMinute_end + ldi r16, DEVICE_SEND_MINUTES + sts minuteCounter, r16 + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + rcall sendDevice +#ifdef APP_STATS_NETDEV2 + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + rcall sendDevice +#endif +onEveryMinute_end: + ret +; @end + + + onEverySecond: ret #if 0 @@ -200,6 +225,27 @@ onEveryLoop: +; --------------------------------------------------------------------------- +; @routine sendDevice + +; @param Y network interface to work with +; @clobbers R16, X (R17, R18, R19, R20, R21, Z) + +sendDevice: + bigcall NET_Buffer_Alloc ; (R16, R17, X) + brcc sendDevice_end + push r16 + adiw xh:xl, 1 + bigcall NETMSG_Device_Write ; (R16, R17, R18, R19, R20, R21, Z) + sbiw xh:xl, 1 + pop r16 + bigcall NET_Interface_AddOrReleaseOutMsg ; (R16, R17, R18, X) +sendDevice_end: + ret +; @end + + + ; *************************************************************************** @@ -208,6 +254,7 @@ onEveryLoop: .include "devices/all/hw_tn84.asm" .include "devices/all/includes.asm" ;.include "common/debug.asm" +.include "modules/network/msg/device-w.asm" @@ -224,3 +271,8 @@ deviceCodeEnd: .endif + +.dseg + +minuteCounter: .byte 1 +