add power mode switch
This commit is contained in:
@@ -242,6 +242,35 @@ static int32_t EvalPhyConfig(INTER_COMM_INST* instPtr, uint8_t* msgPtr){
|
||||
}
|
||||
}
|
||||
|
||||
// Power Mode and Attenuation control
|
||||
if (msgPtr[INTER_MSG_CTRL_POWER_OFFSET] == CTRL_POWER_LOW)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
}
|
||||
else if (msgPtr[INTER_MSG_CTRL_POWER_OFFSET] == CTRL_POWER_FULL)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Unsupported power mode [0x%02X]\n",
|
||||
msgPtr[INTER_MSG_CTRL_POWER_OFFSET]);
|
||||
return FAILURE;
|
||||
}
|
||||
if(msgPtr[INTER_MSG_CTRL_RXATT_OFFSET] <= INTER_MSG_CTRL_RXATT_MAX
|
||||
&& msgPtr[INTER_MSG_CTRL_TXATT_OFFSET] <= INTER_MSG_CTRL_TXATT_MAX)
|
||||
{
|
||||
Phy_AntConfigAttenuation(phyRef,
|
||||
msgPtr[INTER_MSG_CTRL_RXATT_OFFSET],
|
||||
msgPtr[INTER_MSG_CTRL_TXATT_OFFSET]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Attenuation exceeds max range.\n");
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
TIME_WORD tmWord = {0};
|
||||
tmWord.int_part = (uint32_t)(instPtr->lastCtrlTimeTag >> 32);
|
||||
tmWord.frac_part = (uint32_t)(instPtr->lastCtrlTimeTag);
|
||||
@@ -499,16 +528,42 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
break;
|
||||
}
|
||||
case INTER_MSG_MODESW_CODE:{
|
||||
if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NORMAL){
|
||||
if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NORMAL)
|
||||
{
|
||||
Phy_SetMode(instPtr->phyInstPtr, PHY_MODE_PULL);
|
||||
}
|
||||
else if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NETSET){
|
||||
else if(msgRecvPtr[MODESW_MODE_OFFSET] == MODESW_MODE_NETSET)
|
||||
{
|
||||
PHY_INST* phyRef = instPtr->phyInstPtr;
|
||||
// Power Mode and Attenuation control
|
||||
if (msgRecvPtr[MODESW_POWER_OFFSET] == CTRL_POWER_LOW)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_LOW);
|
||||
}
|
||||
else if (msgRecvPtr[MODESW_POWER_OFFSET] == CTRL_POWER_FULL)
|
||||
{
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_POWER_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Unsupported power mode [0x%02X]\n",
|
||||
msgRecvPtr[MODESW_POWER_OFFSET]);
|
||||
break;
|
||||
}
|
||||
if(msgRecvPtr[MODESW_RXATT_OFFSET] <= MODESW_RXATT_MAX)
|
||||
{
|
||||
Phy_AntConfigAttenuation(phyRef, msgRecvPtr[MODESW_RXATT_OFFSET], MODESW_TXATT_SKIP);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("[PHY Control] Attenuation exceeds max range.\n");
|
||||
}
|
||||
uint64_t timeTemp;
|
||||
TIME_WORD tmWord;
|
||||
timeTemp = GetTimeWord(msgRecvPtr + MODESW_START_TIME_OFFSET);
|
||||
tmWord.int_part = (uint32_t)(timeTemp>>32);;
|
||||
tmWord.frac_part = (uint32_t)(timeTemp);
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_POLL);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_POLL);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
@@ -516,7 +571,7 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
if(timeTemp == 0){
|
||||
tmWord.frac_part = 0;
|
||||
tmWord.int_part = 0;
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
@@ -526,14 +581,14 @@ int32_t InterComm_MsgHandler(INTER_COMM_INST* instPtr){
|
||||
tmWord.int_part += (uint32_t)(timeTemp>>32);
|
||||
tmWord.int_part = (tmWord.frac_part >= TIME_FRAC_MAX) ? tmWord.int_part + 1:tmWord.int_part;
|
||||
tmWord.frac_part %= TIME_FRAC_MAX;
|
||||
Status = Phy_SetTimeWord(instPtr->phyInstPtr, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
Status = Phy_SetTimeWord(phyRef, &tmWord, PHY_TIME_WORD_LISTEN_TIMEOUT);
|
||||
if(Status != SUCCESS){
|
||||
return EPARAM;
|
||||
}
|
||||
}
|
||||
instPtr->phyInstPtr->isPresetHop = true ;
|
||||
Status = Phy_SetMode(instPtr->phyInstPtr, PHY_MODE_LISTEN);
|
||||
Status = Phy_SetupNextSlot(instPtr->phyInstPtr, PHY_TOR_RX, L1_10KBPS_20MS_FRAME, NULL);
|
||||
phyRef->isPresetHop = true ;
|
||||
Status = Phy_SetMode(phyRef, PHY_MODE_LISTEN);
|
||||
Status = Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_20MS_FRAME, NULL);
|
||||
}
|
||||
else{
|
||||
return EPARAM;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
#define WAKE_CMD_LPW_UP 0xCCCC
|
||||
|
||||
// mode swicth command
|
||||
#define INTER_MSG_MODESW_LEN 0x0016 // 20byte + crc
|
||||
#define INTER_MSG_MODESW_LEN 0x0018 // 22byte + crc
|
||||
#define INTER_MSG_MODESW_CODE 0x0041
|
||||
#define MODESW_START_TIME_OFFSET 0x0002
|
||||
#define MODESW_START_TIME_LEN 0x0008
|
||||
@@ -75,6 +75,14 @@
|
||||
#define MODESW_MODE_LEN 0x0002
|
||||
#define MODESW_MODE_NORMAL 0x0001
|
||||
#define MODESW_MODE_NETSET 0x0002
|
||||
#define MODESW_POWER_OFFSET 0x0014
|
||||
#define MODESW_POWER_LEN 0x0001
|
||||
#define MODESW_POWER_LOW 0xAA
|
||||
#define MODESW_POWER_FULL 0xCC
|
||||
#define MODESW_RXATT_OFFSET 0x0015
|
||||
#define MODESW_RXATT_LEN 0x0001
|
||||
#define MODESW_RXATT_MAX 0x1F
|
||||
#define MODESW_TXATT_SKIP 0xFF
|
||||
|
||||
// physical layer control
|
||||
#define INTER_MSG_CTRL_LEN 0x00BC // 186byte + 2byte crc
|
||||
@@ -108,11 +116,10 @@
|
||||
#define CTRL_TOR_TX 0xAA
|
||||
#define CTRL_TOR_RX 0xCC
|
||||
|
||||
#define INTER_MSG_CTRL_SW_OFFSET 0x000D
|
||||
#define INTER_MSG_CTRL_SW_LEN 0x0001
|
||||
#define CTRL_SW_PW BIT(0)
|
||||
#define CTRL_SW_TR BIT(1)
|
||||
#define CTRL_SW_TOR BIT(2)
|
||||
#define INTER_MSG_CTRL_POWER_OFFSET 0x000D
|
||||
#define INTER_MSG_CTRL_POWER_LEN 0x0001
|
||||
#define CTRL_POWER_LOW 0xAA
|
||||
#define CTRL_POWER_FULL 0xCC
|
||||
|
||||
#define INTER_MSG_CTRL_HOP_MODE_OFFSET 0x000E
|
||||
#define INTER_MSG_CTRL_HOP_MODE_LEN 0x0002
|
||||
@@ -132,8 +139,12 @@
|
||||
#define INTER_MSG_CTRL_BEAM_NO_OFFSET 0x00B3
|
||||
#define INTER_MSG_CTRL_BEAM_NO_LEN 0x0001
|
||||
|
||||
#define INTER_MSG_CTRL_AMP_WT_OFFSET 0x00B4
|
||||
#define INTER_MSG_CTRL_AMP_WT_LEN 0x0002
|
||||
#define INTER_MSG_CTRL_RXATT_OFFSET 0x00B4
|
||||
#define INTER_MSG_CTRL_RXATT_LEN 0x0001
|
||||
#define INTER_MSG_CTRL_RXATT_MAX 0x1F
|
||||
#define INTER_MSG_CTRL_TXATT_OFFSET 0x00B5
|
||||
#define INTER_MSG_CTRL_TXATT_LEN 0x0001
|
||||
#define INTER_MSG_CTRL_TXATT_MAX 0x1F
|
||||
|
||||
#define INTER_MSG_CTRL_OFFAX_OFFSET 0x00B6
|
||||
#define INTER_MSG_CTRL_OFFAX_LEN 0x0002
|
||||
|
||||
Reference in New Issue
Block a user