From a81acf7b19c74f7d75c8215e02c579e2c75e477f Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Mon, 8 Sep 2025 23:34:38 +0200 Subject: [PATCH] com2wi2: test with two interfaces. --- avr/apps/stats/main.asm | 27 ++++---- avr/devices/s03/defs.asm | 7 +++ avr/devices/s03/main/main.asm | 6 +- avr/modules/com2w/com2wi2.asm | 113 ++++++++++++++++++++++++++++++++-- 4 files changed, 135 insertions(+), 18 deletions(-) diff --git a/avr/apps/stats/main.asm b/avr/apps/stats/main.asm index 0e6a419..0251b5a 100644 --- a/avr/apps/stats/main.asm +++ b/avr/apps/stats/main.asm @@ -11,7 +11,8 @@ ; *************************************************************************** ; defines -.equ APP_STATS_INTERVAL_MINS = 30 +;.equ APP_STATS_INTERVAL_MINS = 30 +.equ APP_STATS_INTERVAL_MINS = 10 @@ -74,18 +75,20 @@ AppStats_OnEveryMinute_store: andi r17, 3 brne AppStats_OnEveryMinute_sendStats ; send device announcement - push yl - push yh - ldi yl, LOW(netInterfaceData) - ldi yh, HIGH(netInterfaceData) - rcall AppNetwork_SendDevice + push r16 + push yl + push yh + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) + rcall AppNetwork_SendDevice #ifdef APP_STATS_NETDEV2 - ldi yl, LOW(netInterfaceData2) - ldi yh, HIGH(netInterfaceData2) - rcall AppNetwork_SendDevice + ldi yl, LOW(netInterfaceData2) + ldi yh, HIGH(netInterfaceData2) + rcall AppNetwork_SendDevice #endif - pop yh - pop yl + pop yh + pop yl + pop r16 AppStats_OnEveryMinute_sendStats: cpi r16, 2 breq AppStats_OnEveryMinute_sendMemStats @@ -106,6 +109,8 @@ AppStats_OnEveryMinute_sendStats: ; add more here ret AppStats_OnEveryMinute_sendMemStats: + ldi yl, LOW(netInterfaceData) + ldi yh, HIGH(netInterfaceData) rjmp AppNetwork_SendMemStats AppStats_OnEveryMinute_sendRecvStats1: diff --git a/avr/devices/s03/defs.asm b/avr/devices/s03/defs.asm index b5712c6..5a31457 100644 --- a/avr/devices/s03/defs.asm +++ b/avr/devices/s03/defs.asm @@ -133,9 +133,16 @@ .equ COM_MASK_IRQ7 = (1<0 com2wi0_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >1 +com2wi1_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >2 +com2wi2_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >3 +com2wi3_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >4 +com2wi4_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >5 +com2wi5_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >6 +com2wi6_iface: .byte COM2WI_IFACE_SIZE +.endif + +.if COM_PORTS >7 +com2wi7_iface: .byte COM2WI_IFACE_SIZE +.endif @@ -115,7 +148,34 @@ com2wi0_iface: .byte COM2WI_IFACE_SIZE ; @routine COM2WI_Init COM2WI_Init: +.if COM_PORTS >0 mCOM2WI_INIT 0 +.endif + +.if COM_PORTS >1 + mCOM2WI_INIT 1 +.endif + +.if COM_PORTS >2 + mCOM2WI_INIT 2 +.endif +.if COM_PORTS >3 + mCOM2WI_INIT 3 +.endif + +.if COM_PORTS >4 + mCOM2WI_INIT 4 +.endif +.if COM_PORTS >5 + mCOM2WI_INIT 5 +.endif + +.if COM_PORTS >6 + mCOM2WI_INIT 6 +.endif +.if COM_PORTS >7 + mCOM2WI_INIT 7 +.endif rcall com2wiSetupTimer1 ret @@ -141,9 +201,7 @@ COM2WI_Timer1Isr: push yh push zl push zh - ldi yl, LOW(com2wi0_iface) - ldi yh, HIGH(com2wi0_iface) - rcall com2wiHandleIrq ; (r16, r17, Z) + rcall COM2WI_HandleTimerIrq ; (r16, r17, r18, Y, Z) pop zh pop zl pop yh @@ -164,7 +222,53 @@ COM2WI_Timer1Isr: COM2WI_Run: ldi yl, LOW(com2wi0_iface) ldi yh, HIGH(com2wi0_iface) - rcall com2wiRun + ldi r18, COM_PORTS + clr r19 +COM2WI_Run_loop: + push r18 + push r19 + rcall com2wiRun + pop r19 + pop r18 + sbci r19, 0 + ldi r16, COM2WI_IFACE_SIZE + add yl, r16 + adc yh, r16 + sub yh, r16 + dec r18 + brne COM2WI_Run_loop + + ; check for repeat request + tst r19 + clc + breq COM2WI_Run_end + sec +COM2WI_Run_end: + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine COM2WI_HandleTimerIrq +; +; @param Y pointer to interface data in SRAM +; @clobbers R16, R17, R18, Y, Z + +COM2WI_HandleTimerIrq: + ldi yl, LOW(com2wi0_iface) + ldi yh, HIGH(com2wi0_iface) + ldi r18, COM_PORTS +COM2WI_HandleTimerIrq_loop: + push r18 + rcall com2wiHandleIrq ; R16, R17, R18, Z + pop r18 + ldi r16, COM2WI_IFACE_SIZE + add yl, r16 + adc yh, r16 + sub yh, r16 + dec r18 + brne COM2WI_HandleTimerIrq_loop ret ; @end @@ -349,6 +453,7 @@ com2wiDataSetLow: + ; --------------------------------------------------------------------------- ; @routine com2wiHandleIrq ;