5 Commits
Author SHA1 Message Date
Gatsby Van f4175cd7b5 code simplify 2024-01-31 10:18:40 +08:00
Gatsby Van 678bb7f393 update error handling 2024-01-31 10:18:14 +08:00
Gatsby Van 085e5cea93 *bugfix: avoid unnecessary reconfiguration 2024-01-31 10:17:43 +08:00
Gatsby Van 3916b18a6f remove blank line 2024-01-31 10:10:24 +08:00
Gatsby Van 74d20c1010 omit redundant code 2024-01-31 10:10:05 +08:00
2 changed files with 10 additions and 23 deletions
+10 -19
View File
@@ -349,14 +349,16 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
if (data[WD_MODE_CMD] == MODE_CMD_HEAD)
if (data[WD_MODE_CMD] == MODE_CMD_HEAD
&& L2_GetNodeType(linkInstPtr) != L2_NODE_HEAD)
{
// head node config
linkConfig.myType = L2_NODE_HEAD;
linkConfig.myId = 1;
Linklayer_Reconfig(linkInstPtr, &linkConfig);
}
else if (data[WD_MODE_CMD] == MODE_CMD_MEMBER)
else if (data[WD_MODE_CMD] == MODE_CMD_MEMBER
&& L2_GetNodeType(linkInstPtr) != L2_NODE_MEMBER)
{
// member node config
linkConfig.myType = L2_NODE_MEMBER;
@@ -365,29 +367,29 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
}
else
{
// FIXME:
// FIXME: to confirm
// Halt linklayer
Linklayer_Halt(linkInstPtr);
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
WD_MODE_CMD, data[WD_MODE_CMD]);
Status = EPARAM;
break;
}
if(data[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
{
// high power config
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_HIGH_POWER);
Linklayer_Start(linkInstPtr);
}
else if(data[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
{
// low power config
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER);
Linklayer_Start(linkInstPtr);
}
else
{
// silence config
// FIXME: confirm
// TODO: better approach?
Linklayer_Halt(linkInstPtr);
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT);
@@ -399,9 +401,10 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 ".\n", Status);
}
Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
break;
}
_nop_(); // for debug
Linklayer_Start(linkInstPtr);
Status = SUCCESS;
break;
}
@@ -562,18 +565,6 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
return Status;
}
int32_t SystemBus_FLJ_PeriodUpdate(SYSBUS *instPtr)
{
// TODO
return SUCCESS;
}
int32_t SystemBus_LJ_PeriodUpdate(SYSBUS *instPtr)
{
// TODO
return SUCCESS;
}
/*****************************************************************************/
/**
* @brief This function send a repose frame from system bus tx queue.
-4
View File
@@ -47,10 +47,6 @@ typedef struct
int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config);
int32_t SystemBus_HandleCmd(SYSBUS *instPtr);
int32_t SystemBus_FLJ_PeriodUpdate(SYSBUS *instPtr);
int32_t SystemBus_LJ_PeriodUpdate(SYSBUS *instPtr);
int32_t SystemBus_MakeResp(SYSBUS *instPtr);
int32_t SystemBus_TxIntrHandler(SYSBUS *instPtr);