From 7534dda3b69026df6dc40b3d907b825a0078617b Mon Sep 17 00:00:00 2001
From: chenlh <2008get@163.com>
Date: 星期四, 21 八月 2025 20:14:01 +0800
Subject: [PATCH] Signed-off-by: chenlh <2008get@163.com>

---
 src/messageproc.cpp |   86 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 76 insertions(+), 10 deletions(-)

diff --git a/src/messageproc.cpp b/src/messageproc.cpp
index 38f0bd3..bc6d6a6 100644
--- a/src/messageproc.cpp
+++ b/src/messageproc.cpp
@@ -1,7 +1,7 @@
 /*
  * messageproc.c
  *
- *  Created on: 2021年11月1日
+ *  Created on: 2021骞�1鏈�鏃�  *      Author: graydon
  */
 #include <string.h>
@@ -10,7 +10,7 @@
 #include "messageproc.h"
 #include "../drv/spi.h"
 #include "../drv/gpio.h"
-#include "../drv/memory.h"
+
 #include "F2F.h"
 #include "ModuleProAPI.h"
 #include "tg/tg_adapter.h"
@@ -37,6 +37,41 @@
 	s32 size = dsp_status_q.get_device_status_ptr(pmsg->data,MSG_DATA_LEN);
 	if(size > 0) {
 		pmsg->Enc(MsgType::MSG_DSP_STATUS_REPORT, 0, size);
+		txQueue->Push(*pmsg);
+	}
+}
+
+uvoid Message::ReportLevel(MSG* pmsg)
+{
+	int i;
+	int data_len;
+
+	ToB* tob = ToB::GetInstance();
+	u16 LevelCnt = tob->GetLevels(Levels);
+	u32 msgLen = LevelCnt * sizeof(*Levels);
+
+	int Packegs = (LevelCnt+MSG_DATA_LEN-1)/MSG_DATA_LEN;
+
+	pmsg->magic = 0x5aa5;
+//	pmsg->dataLen = LevelCnt;
+	pmsg->totalPkts = Packegs;
+//	pmsg->pktNo = 1;
+	pmsg->msgType = MSG_GET_LEVEL;
+
+	// Split packeg
+	for(i=0; i<Packegs; i++){
+		if(i == Packegs-1){
+			data_len = msgLen - i * MSG_DATA_LEN;
+		}
+		else{
+			data_len = MSG_DATA_LEN;
+		}
+
+		memcpy(pmsg->data, Levels + i * MSG_DATA_LEN, data_len);
+		pmsg->dataLen = LevelCnt;
+		pmsg->pktNo = i;
+
+		pmsg->Enc(MsgType::MSG_GET_LEVEL, 0, msgLen);
 		txQueue->Push(*pmsg);
 	}
 }
@@ -70,6 +105,7 @@
 	return 0;
 }
 
+
 s32 Message::PresetProcess(MSG* pmsg)
 {
 	VarState& var = VarState::GetInstance();
@@ -79,12 +115,15 @@
 		sram_free(SRAM_DDR, bin);
 		bin = NULL;
 	}
+
 	if(pmsg->pktNo == 0 && bin == NULL) {
-		bin = (u8*)sram_malloc(SRAM_DDR, mem_any ,pmsg->totalPkts*MSG_DATA_LEN);
+		bin = (u8*)sram_malloc(SRAM_DDR, mem_any, pmsg->totalPkts*MSG_DATA_LEN);
 	}
 	if(bin == NULL) return -1;
+	printf("No:%d len %d\n", pmsg->pktNo,pmsg->dataLen);
 	var.TopoLoading = utrue;
 	memcpy(bin+pmsg->pktNo*MSG_DATA_LEN, pmsg->data , pmsg->dataLen);
+
 	if(pmsg->pktNo == pmsg->totalPkts -1) {
 		u32 size = (pmsg->totalPkts -1)*MSG_DATA_LEN+pmsg->dataLen;
 
@@ -100,25 +139,41 @@
 				var.TopoStatus = PRESET_STA::PRESET_ERR;
 			}
 			else if(tob){
-				s8* content = (s8*)sram_malloc(SRAM_DDR, mem_any ,16*1024);
+				u8* content = (u8*)sram_malloc(SRAM_DDR, mem_any, 45128);//45*1024);
 				s32 size ;
 
 				var.pscene->update_module();
 				size = var.pscene->convert_to_bin(content);
 
 				tob->toClear();
-				tob->toAnalysis(bin, size);
+				tob->toAnalysis(content, size);
 
 				sram_free(SRAM_DDR, content);
 				var.TopoStatus = PRESET_STA::PRESET_DONE;
 			}
 		}
 		sram_free(SRAM_DDR, bin); bin = NULL;
-		var.TopoLoading =0 ;
+		var.TopoLoading = ufalse ;
 	}
 
 	return 0;
 }
+
+/*void Message::param_init(ptag_device_config pDevCfg)
+{
+	pDevCfg->dual_dsp = 0;
+	pDevCfg->dsp_index = 0;
+	pDevCfg->local_rx_num = 16;
+	pDevCfg->local_tx_num = 16;
+	pDevCfg->dante_rx_num = 16;
+	pDevCfg->dante_tx_num = 16;
+	pDevCfg->external_clock = 1;
+	pDevCfg->scene_size = 1000;
+	pDevCfg->level_num = 10;
+	pDevCfg->modulelist = 9;
+	pDevCfg->hardware_type = 1;
+
+}*/
 
 s32 Message::HandshakeMessageProcess(MSG* pmsg)
 {
@@ -128,18 +183,20 @@
 	struct DSPConfig dspconfig ;
 
 	if(var.HandShakeSuccesful == ufalse) {
-		//可以根据ptag_device_config.hardware_type动态适配型号.
+		//鍙互鏍规嵁ptag_device_config.hardware_type鍔ㄦ�閫傞厤鍨嬪彿.
 		if(var.pscene){
 			delete var.pscene;
 			var.pscene = NULL;
 		}
 
+//		param_init(device_config);
 		hw_adapter_t* _adapter = new tg_hw_adapter_t(device_config->dual_dsp,device_config->dsp_index
 							,device_config->local_rx_num,device_config->local_tx_num
 							,device_config->dante_rx_num,device_config->dante_tx_num);
-		var.pscene = new tgScene(_adapter);
+		var.pscene = new(SRAM_DDR) tgScene(_adapter);
 
 		_adapter->config_board(&dspconfig);
+		new(SRAM_DDR) ToB(device_config->dual_dsp, device_config->dsp_index);
 
 		SAMPLE_NUM = dspconfig.mSampleNum;
 		var.master_intr = dspconfig.mIntrNo;
@@ -147,7 +204,7 @@
 
 		ModuleLeveldBUSetting(dspconfig.mConvertUnit);
 		//Config(conf);
-		RouteConfig(dspconfig.routes,dspconfig.mRouteNum);
+		RouteConfig(dspconfig.routes, dspconfig.mRouteNum);
 		SRCsConfig(0 , &dspconfig.srcs[0]);
 		SRCsConfig(1 , &dspconfig.srcs[4]);
 		PCGsConfig(dspconfig.pcgs);
@@ -175,6 +232,7 @@
 		ParamCtrl(pmsg);
 		break;
 	case MsgType::MSG_GET_LEVEL:
+		//ReportLevel(pmsg);
 		break;
 	case MsgType::MSG_PARAM_CONFIG:
 	case MsgType::MSG_PARAM_COMPLETED:
@@ -195,6 +253,14 @@
 uvoid Message::Proc()
 {
 	u32 status = 0;
+//	static bool bSetOk = 0;
+
+//	MSG* p = (MSG*)SPI_Rx_BUFFER;
+//	if (0 == bSetOk) {
+//		HandshakeMessageProcess(p);	//virtual communication
+//		PresetProcess(p);
+//		bSetOk = 1;
+//	}
 
 	if(SPIRxDone) {
 		RxMessageHandler((MSG*)SPI_Rx_BUFFER);
@@ -207,6 +273,6 @@
 			GPIO_SetOutPut(GPIOA, GPIO_Pin12, GPIO_HIGH);
 		}
 		SPI2_SetTransMode(SPIStatus::SPI_TRX);
-		GPIO_SetOutPut(GPIOA, GPIO_Pin13, GPIO_HIGH);
+		GPIO_SetOutPut(GPIOB, GPIO_Pin5, GPIO_HIGH);
 	}
 }

--
Gitblit v1.9.3