From 10c72585ded4037480338d863704eb8f8c402ac3 Mon Sep 17 00:00:00 2001 From: Gatsby Van Date: Wed, 6 Mar 2024 20:03:38 +0800 Subject: [PATCH] *add new silent command --- df_datalink_sp/src/systembus/systembus.c | 30 +++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/df_datalink_sp/src/systembus/systembus.c b/df_datalink_sp/src/systembus/systembus.c index 03fb884..7d55a3d 100644 --- a/df_datalink_sp/src/systembus/systembus.c +++ b/df_datalink_sp/src/systembus/systembus.c @@ -101,7 +101,8 @@ // -- Request #define WD_EN_CMD 0x02 #define EN_CMD_ON_HIGH_POWER 0x66 -#define EN_CMD_ON_LOW_POWER 0x88 +#define EN_CMD_ON_LOW_POWER 0x77 +#define EN_CMD_SILENT 0x88 #define WD_MODE_CMD 0x03 #define MODE_CMD_HEAD 0x11 @@ -392,6 +393,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr) { PHY_INST *phyRef = linkInstPtr->config.phyInstPtr; TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr; + bool reconfig = false; if (data[WD_MODE_CMD] == MODE_CMD_HEAD) { @@ -401,6 +403,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr) // head node config linkConfig.myType = L2_NODE_HEAD; linkConfig.myId = 1; + reconfig = true; Linklayer_Reconfig(linkInstPtr, &linkConfig); } } @@ -412,15 +415,14 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr) { // member node config linkConfig.myType = L2_NODE_MEMBER; - linkConfig.myId = 2; + linkConfig.myId = 2 + reconfig = true; Linklayer_Reconfig(linkInstPtr, &linkConfig); } } else { - // FIXME: to confirm - // Halt linklayer - Linklayer_Halt(linkInstPtr); + // Do not response DBG_ERROR("Unexpected config command 0x%02X:0x%02X", WD_MODE_CMD, data[WD_MODE_CMD]); Status = EPARAM; @@ -437,10 +439,9 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr) // low power config Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER); } - else + else if(data[WD_EN_CMD] == EN_CMD_SILENT) { // silence config - // FIXME: confirm // TODO: better approach? Linklayer_Halt(linkInstPtr); Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT); @@ -454,8 +455,19 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr) Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL); break; } - - Linklayer_Start(linkInstPtr); + else + { + // Do not response + DBG_ERROR("Unexpected config command 0x%02X:0x%02X", + WD_EN_CMD, data[WD_EN_CMD]); + Status = EPARAM; + break; + } + if (reconfig == true) + { + Linklayer_Reconfig(linkInstPtr, &linkConfig); + Linklayer_Start(linkInstPtr); + } instPtr->sysbusLog.lastConfig[0] = data[WD_MODE_CMD]; instPtr->sysbusLog.lastConfig[1] = data[WD_EN_CMD]; Status = SUCCESS;