forked from gatsby/df_datalink
*feature add: add systembus config command support
This commit is contained in:
@@ -77,14 +77,14 @@ struct callback_desc scutm_callback_desc = {
|
|||||||
.ctx = NULL
|
.ctx = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static L2_CONFIG linkConfig = {
|
L2_CONFIG linkConfig = {
|
||||||
.myType = L2_NODE_HEAD,
|
.myType = L2_NODE_HEAD,
|
||||||
.clustId = 1,
|
.clustId = 1,
|
||||||
.myId = 1,
|
.myId = 1,
|
||||||
.headId = 1,
|
.headId = 1,
|
||||||
.bkpHeadId = 0,
|
.bkpHeadId = 0,
|
||||||
.netScale = 2,
|
.netScale = 2,
|
||||||
.phyInstPtr = NULL, // pyhsical layer reference
|
.phyInstPtr = NULL, // physical layer reference
|
||||||
.tmcInstPtr = NULL
|
.tmcInstPtr = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ static struct timer_desc *logTmPtr;
|
|||||||
static SYSBUS *sysbusDescPtr;
|
static SYSBUS *sysbusDescPtr;
|
||||||
static PHY_INST *phyInstPtr;
|
static PHY_INST *phyInstPtr;
|
||||||
static TMC_INST *tmcInstPtr = NULL;
|
static TMC_INST *tmcInstPtr = NULL;
|
||||||
static L2_INST *linkInstPtr;
|
L2_INST *linkInstPtr;
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -73,14 +73,14 @@ struct callback_desc scutm_callback_desc = {
|
|||||||
.ctx = NULL
|
.ctx = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
static L2_CONFIG linkConfig = {
|
L2_CONFIG linkConfig = {
|
||||||
.myType = L2_NODE_HEAD,
|
.myType = L2_NODE_HEAD,
|
||||||
.clustId = 1,
|
.clustId = 1,
|
||||||
.myId = 1,
|
.myId = 1,
|
||||||
.headId = 1,
|
.headId = 1,
|
||||||
.bkpHeadId = 0,
|
.bkpHeadId = 0,
|
||||||
.netScale = 2,
|
.netScale = 2,
|
||||||
.phyInstPtr = NULL, // pyhsical layer reference
|
.phyInstPtr = NULL, // physical layer reference
|
||||||
.tmcInstPtr = NULL
|
.tmcInstPtr = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ static struct timer_desc *logTmPtr;
|
|||||||
static SYSBUS *sysbusDescPtr;
|
static SYSBUS *sysbusDescPtr;
|
||||||
static PHY_INST *phyInstPtr;
|
static PHY_INST *phyInstPtr;
|
||||||
static TMC_INST *tmcInstPtr = NULL;
|
static TMC_INST *tmcInstPtr = NULL;
|
||||||
static L2_INST *linkInstPtr;
|
L2_INST *linkInstPtr;
|
||||||
|
|
||||||
static struct hmc7044_dev *hmc7044_inst;
|
static struct hmc7044_dev *hmc7044_inst;
|
||||||
static struct ad9361_reg_dev *ad9361_1_reg_inst;
|
static struct ad9361_reg_dev *ad9361_1_reg_inst;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "../system_monitor.h"
|
#include "../system_monitor.h"
|
||||||
|
|
||||||
|
/************************** Constant Definitions *****************************/
|
||||||
// Common Field
|
// Common Field
|
||||||
// -- Command word
|
// -- Command word
|
||||||
#define WD_CMD 0x00
|
#define WD_CMD 0x00
|
||||||
@@ -95,11 +96,12 @@
|
|||||||
#define CMD_CONFIG 0xE3
|
#define CMD_CONFIG 0xE3
|
||||||
// -- Request
|
// -- Request
|
||||||
#define WD_EN_CMD 0x02
|
#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 WD_MODE_CMD 0x03
|
||||||
#define MODE_CMD_HEAD 0x11
|
#define MODE_CMD_HEAD 0x11
|
||||||
#define MODE_CMD_MEMBER 0x11
|
#define MODE_CMD_MEMBER 0x00
|
||||||
// -- Response
|
// -- Response
|
||||||
// -- -- none response
|
// -- -- none response
|
||||||
|
|
||||||
@@ -165,6 +167,15 @@
|
|||||||
// My Production Type
|
// My Production Type
|
||||||
#define MY_PRD_ID PRD_DL_K
|
#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)
|
inline bool SystemBus_IsReqPendding(SYSBUS *instPtr)
|
||||||
{
|
{
|
||||||
ASSERT(instPtr != NULL);
|
ASSERT(instPtr != NULL);
|
||||||
@@ -338,9 +349,62 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
|||||||
}
|
}
|
||||||
case CMD_CONFIG:
|
case CMD_CONFIG:
|
||||||
{
|
{
|
||||||
// FIXME: apply configurations
|
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
|
||||||
// Power + Mode
|
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
|
||||||
// -- No response
|
|
||||||
|
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
|
_nop_(); // for debug
|
||||||
Status = SUCCESS;
|
Status = SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user