*feature add: add systembus config command support
This commit is contained in:
@@ -77,14 +77,14 @@ struct callback_desc scutm_callback_desc = {
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
static L2_CONFIG linkConfig = {
|
||||
L2_CONFIG linkConfig = {
|
||||
.myType = L2_NODE_HEAD,
|
||||
.clustId = 1,
|
||||
.myId = 1,
|
||||
.headId = 1,
|
||||
.bkpHeadId = 0,
|
||||
.netScale = 2,
|
||||
.phyInstPtr = NULL, // pyhsical layer reference
|
||||
.phyInstPtr = NULL, // physical layer reference
|
||||
.tmcInstPtr = NULL
|
||||
};
|
||||
|
||||
@@ -124,7 +124,7 @@ static struct timer_desc *logTmPtr;
|
||||
static SYSBUS *sysbusDescPtr;
|
||||
static PHY_INST *phyInstPtr;
|
||||
static TMC_INST *tmcInstPtr = NULL;
|
||||
static L2_INST *linkInstPtr;
|
||||
L2_INST *linkInstPtr;
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
|
||||
@@ -73,14 +73,14 @@ struct callback_desc scutm_callback_desc = {
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
static L2_CONFIG linkConfig = {
|
||||
L2_CONFIG linkConfig = {
|
||||
.myType = L2_NODE_HEAD,
|
||||
.clustId = 1,
|
||||
.myId = 1,
|
||||
.headId = 1,
|
||||
.bkpHeadId = 0,
|
||||
.netScale = 2,
|
||||
.phyInstPtr = NULL, // pyhsical layer reference
|
||||
.phyInstPtr = NULL, // physical layer reference
|
||||
.tmcInstPtr = NULL
|
||||
};
|
||||
|
||||
@@ -120,7 +120,7 @@ static struct timer_desc *logTmPtr;
|
||||
static SYSBUS *sysbusDescPtr;
|
||||
static PHY_INST *phyInstPtr;
|
||||
static TMC_INST *tmcInstPtr = NULL;
|
||||
static L2_INST *linkInstPtr;
|
||||
L2_INST *linkInstPtr;
|
||||
|
||||
static struct hmc7044_dev *hmc7044_inst;
|
||||
static struct ad9361_reg_dev *ad9361_1_reg_inst;
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
// Common Field
|
||||
// -- Command word
|
||||
#define WD_CMD 0x00
|
||||
@@ -95,11 +96,12 @@
|
||||
#define CMD_CONFIG 0xE3
|
||||
// -- Request
|
||||
#define WD_EN_CMD 0x02
|
||||
#define EN_CMD_ON 0x66
|
||||
#define EN_CMD_ON_HIGH_POWER 0x66
|
||||
#define EN_CMD_ON_LOW_POWER 0x88
|
||||
|
||||
#define WD_MODE_CMD 0x03
|
||||
#define MODE_CMD_HEAD 0x11
|
||||
#define MODE_CMD_MEMBER 0x11
|
||||
#define MODE_CMD_MEMBER 0x00
|
||||
// -- Response
|
||||
// -- -- none response
|
||||
|
||||
@@ -165,6 +167,15 @@
|
||||
// My Production Type
|
||||
#define MY_PRD_ID PRD_DL_K
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/************************** Variable Definitions *****************************/
|
||||
// TODO: better approach?
|
||||
#include "../networking/link_layer/link_layer.h"
|
||||
#include "../networking/phy_layer/phy_layer.h"
|
||||
extern L2_INST *linkInstPtr;
|
||||
extern L2_CONFIG linkConfig;
|
||||
|
||||
inline bool SystemBus_IsReqPendding(SYSBUS *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -337,10 +348,63 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
break;
|
||||
}
|
||||
case CMD_CONFIG:
|
||||
{
|
||||
// FIXME: apply configurations
|
||||
// Power + Mode
|
||||
// -- No response
|
||||
{
|
||||
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
|
||||
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
|
||||
|
||||
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
|
||||
// TODO: better approach?
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT);
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
pullTime.int_part = TimeCtrl_GetIntCnt(tmcRef) + 1;
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 ".\n", Status);
|
||||
}
|
||||
Phy_SetupNextSlot(phyRef, PHY_TOR_TX, L1_10KBPS_10MS_FRAME, NULL);
|
||||
}
|
||||
|
||||
if (data[WD_MODE_CMD] == MODE_CMD_HEAD)
|
||||
{
|
||||
// head node config
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 1;
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
Linklayer_Start(linkInstPtr);
|
||||
}
|
||||
else if (data[WD_MODE_CMD] == MODE_CMD_MEMBER)
|
||||
{
|
||||
// member node config
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
Linklayer_Start(linkInstPtr);
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME:
|
||||
// Halt linklayer
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_MODE_CMD, data[WD_MODE_CMD]);
|
||||
}
|
||||
_nop_(); // for debug
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user