*add new silent command

This commit is contained in:
Gatsby Van
2024-03-06 20:03:38 +08:00
parent c3e47b0fae
commit 10c72585de
+21 -9
View File
@@ -101,7 +101,8 @@
// -- Request // -- Request
#define WD_EN_CMD 0x02 #define WD_EN_CMD 0x02
#define EN_CMD_ON_HIGH_POWER 0x66 #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 WD_MODE_CMD 0x03
#define MODE_CMD_HEAD 0x11 #define MODE_CMD_HEAD 0x11
@@ -392,6 +393,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
{ {
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr; PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr; TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
bool reconfig = false;
if (data[WD_MODE_CMD] == MODE_CMD_HEAD) if (data[WD_MODE_CMD] == MODE_CMD_HEAD)
{ {
@@ -401,6 +403,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
// head node config // head node config
linkConfig.myType = L2_NODE_HEAD; linkConfig.myType = L2_NODE_HEAD;
linkConfig.myId = 1; linkConfig.myId = 1;
reconfig = true;
Linklayer_Reconfig(linkInstPtr, &linkConfig); Linklayer_Reconfig(linkInstPtr, &linkConfig);
} }
} }
@@ -412,15 +415,14 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
{ {
// member node config // member node config
linkConfig.myType = L2_NODE_MEMBER; linkConfig.myType = L2_NODE_MEMBER;
linkConfig.myId = 2; linkConfig.myId = 2
reconfig = true;
Linklayer_Reconfig(linkInstPtr, &linkConfig); Linklayer_Reconfig(linkInstPtr, &linkConfig);
} }
} }
else else
{ {
// FIXME: to confirm // Do not response
// Halt linklayer
Linklayer_Halt(linkInstPtr);
DBG_ERROR("Unexpected config command 0x%02X:0x%02X", DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
WD_MODE_CMD, data[WD_MODE_CMD]); WD_MODE_CMD, data[WD_MODE_CMD]);
Status = EPARAM; Status = EPARAM;
@@ -437,10 +439,9 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
// low power config // low power config
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER); Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER);
} }
else else if(data[WD_EN_CMD] == EN_CMD_SILENT)
{ {
// silence config // silence config
// FIXME: confirm
// TODO: better approach? // TODO: better approach?
Linklayer_Halt(linkInstPtr); Linklayer_Halt(linkInstPtr);
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT); 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); Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
break; break;
} }
else
Linklayer_Start(linkInstPtr); {
// 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[0] = data[WD_MODE_CMD];
instPtr->sysbusLog.lastConfig[1] = data[WD_EN_CMD]; instPtr->sysbusLog.lastConfig[1] = data[WD_EN_CMD];
Status = SUCCESS; Status = SUCCESS;