From 95322c84888cbe2e92024d4d65698f59b016cb52 Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期日, 25 二月 2024 12:29:35 +0800
Subject: [PATCH] move some define from Kbus.h to KBusDefine.h

---
 ComLib/Src/ModbusRTU.c |   24 +++++++++++++++++-------
 1 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/ComLib/Src/ModbusRTU.c b/ComLib/Src/ModbusRTU.c
index cfcd848..f143e6c 100644
--- a/ComLib/Src/ModbusRTU.c
+++ b/ComLib/Src/ModbusRTU.c
@@ -168,11 +168,18 @@
 				bitmask=1;
 				for (int j=0;j<8&&i*8+j<nCount;j++)
 				{
-					Addr1=(Addr&0xff0)>>4;
+					Addr1=(Addr&0xfff0)>>4;
 					bitAddr=Addr&0xf;
-					if (GetBitValue( KMem.WY[Addr1],bitAddr))
-					{
-						thisValue|=bitmask;
+					if (Addr < 2048) {
+						if (GetBitValue( KMem.WY[Addr1],bitAddr))
+						{
+							thisValue|=bitmask;
+						}
+					}else {
+						if (GetBitValue( KMem.WR[Addr1-128],bitAddr))
+						{
+							thisValue|=bitmask;
+						}
 					}
 					bitmask<<=1;
 					Addr++;
@@ -260,10 +267,13 @@
 				bitmask=1;
 				for (int j=0;j<8&&i*8+j<nCount;j++)
 				{
-					Addr1=(Addr&0xff0)>>4;
+					Addr1=(Addr&0xfff0)>>4;
 					bitAddr=Addr&0xf;
-					
-					SetBitValue( &KMem.WY[Addr1],bitAddr,bitmask&thisValue);
+					if (Addr < 2048) { 
+						SetBitValue( &KMem.WY[Addr1],bitAddr,bitmask&thisValue);
+					} else {
+						SetBitValue( &KMem.WR[Addr1 - 128],bitAddr,bitmask&thisValue);						
+					}
 					bitmask<<=1;
 					Addr++;
 				}

--
Gitblit v1.9.1