merged datalink814.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* LastEditTime: 2022-06-18 17:15
|
||||
* Revisions: Rev 0.0
|
||||
* History:
|
||||
* [2024-01-20]: New branch for duifei.
|
||||
* [2022-06-18]: Initial version.
|
||||
*
|
||||
* Copyright(c) 2022 Beijing Institute of Technology.
|
||||
@@ -18,7 +19,6 @@
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
#include "error.h"
|
||||
#include "../config//app_config.h"
|
||||
#include "phy_layer.h"
|
||||
|
||||
#define ANT_PI 3.14159265358979323846
|
||||
@@ -64,24 +64,19 @@ uint16_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS] =
|
||||
1500
|
||||
};
|
||||
|
||||
// uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] =
|
||||
// {
|
||||
// 0, 44, 88, 131, 175, 219, 263, 306,
|
||||
// 350, 394, 438, 481, 525, 569, 613, 656,
|
||||
// 700, 744, 788, 831, 875, 919, 963, 1006,
|
||||
// 1050, 1094, 1138, 1181, 1225, 1269, 1313, 1356,
|
||||
// 1400, 1444, 1488, 1531, 1575, 1619, 1663, 1706,
|
||||
// 1750, 1794, 1838, 1881, 1925, 1969, 2013, 2056,
|
||||
// 2100, 2144, 2188, 2231, 2275, 2319, 2363, 2406,
|
||||
// 2450, 2494, 2538, 2581, 2625, 2669, 2713, 2756,
|
||||
// 2800, 2844, 2888, 2931, 2975, 3019, 3063, 3106,
|
||||
// 3150, 3194, 3238, 3281, 3325, 3369, 3413, 3456,
|
||||
// 3500
|
||||
// };
|
||||
|
||||
uint16_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] =
|
||||
{
|
||||
1500
|
||||
0, 44, 88, 131, 175, 219, 263, 306,
|
||||
350, 394, 438, 481, 525, 569, 613, 656,
|
||||
700, 744, 788, 831, 875, 919, 963, 1006,
|
||||
1050, 1094, 1138, 1181, 1225, 1269, 1313, 1356,
|
||||
1400, 1444, 1488, 1531, 1575, 1619, 1663, 1706,
|
||||
1750, 1794, 1838, 1881, 1925, 1969, 2013, 2056,
|
||||
2100, 2144, 2188, 2231, 2275, 2319, 2363, 2406,
|
||||
2450, 2494, 2538, 2581, 2625, 2669, 2713, 2756,
|
||||
2800, 2844, 2888, 2931, 2975, 3019, 3063, 3106,
|
||||
3150, 3194, 3238, 3281, 3325, 3369, 3413, 3456,
|
||||
3500
|
||||
};
|
||||
|
||||
uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS] =
|
||||
@@ -95,6 +90,12 @@ uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS] =
|
||||
1700, 1800, 1900
|
||||
};
|
||||
|
||||
uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] =
|
||||
{
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
2400
|
||||
};
|
||||
|
||||
uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] =
|
||||
{
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
@@ -102,17 +103,13 @@ uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] =
|
||||
2400, 2400, 2400
|
||||
};
|
||||
|
||||
uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] =
|
||||
{
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
2400
|
||||
};
|
||||
uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS] =
|
||||
{
|
||||
500, 1600, 1700, 1800, 1900, 2000, 1500, 1600,
|
||||
1700, 1800, 1900, 2000, 1500, 1600, 1700, 1800,
|
||||
1900, 2000, 1500, 1500
|
||||
};
|
||||
|
||||
uint16_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] =
|
||||
{
|
||||
500, 600, 700, 800, 900, 1000, 500, 600,
|
||||
@@ -193,61 +190,60 @@ PHY_ANT_ANGLE antNrrwPattern[NUM_ANT_NRRW_PATTERN] =
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param antConfigPtr
|
||||
* @param antConfig
|
||||
*
|
||||
* @return
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_AntConfigInit(PHY_ANT_COINFO *antConfigPtr)
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
{
|
||||
ASSERT(antConfigPtr != NULL);
|
||||
ASSERT(antConfig != NULL);
|
||||
|
||||
antConfigPtr->ctrlWord = 0x00;
|
||||
antConfigPtr->antMode = ATN_MODE_DEFAULT;
|
||||
antConfig->ctrlWord = CTRL_WORD_DEFAULT;
|
||||
antConfig->antMode = ATN_MODE_DEFAULT;
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// off axis angle setting
|
||||
antConfigPtr->oaxis[0] = 0;
|
||||
antConfigPtr->oaxis[1] = 0;
|
||||
antConfig->oaxis[0] = 0;
|
||||
antConfig->oaxis[1] = 0;
|
||||
// round axis angle setting
|
||||
antConfigPtr->raxis[0] = 0;
|
||||
antConfigPtr->raxis[1] = 0;
|
||||
antConfig->raxis[0] = 0;
|
||||
antConfig->raxis[1] = 0;
|
||||
// ***********************
|
||||
|
||||
antConfigPtr->antFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfigPtr->antFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
antConfig->antFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfig->antFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// trSelect
|
||||
antConfigPtr->trSlect = 0;
|
||||
antConfig->trSlect = 0;
|
||||
// Antenna attenuation setting
|
||||
antConfigPtr->antAtt = 20;
|
||||
antConfig->antAtt = 20;
|
||||
// phase setting
|
||||
antConfigPtr->phase = 0;
|
||||
antConfig->phase = 0;
|
||||
// ***********************
|
||||
|
||||
antConfigPtr->rxtxMode = RXTXMODE_DEFAULT;
|
||||
antConfigPtr->calibrMode = CALIBRMODE_NORMAL;
|
||||
antConfigPtr->antReserved = 0x00;
|
||||
antConfig->rxtxMode = RXTXMODE_DEFAULT;
|
||||
antConfig->calibrMode = CALIBRMODE_NORMAL;
|
||||
antConfig->antReserved = 0x00;
|
||||
|
||||
// FIXME: Dummy default value.
|
||||
// RF mode control
|
||||
antConfigPtr->rfCtrl = RF_CTRL_DEFAULT;
|
||||
antConfig->rfCtrl = RF_CTRL_DEFAULT;
|
||||
// RF frequency
|
||||
antConfigPtr->rfFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfigPtr->rfFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
antConfig->rfFreq[0] = (uint8_t)(DEFAULT_CENTRTAL_FREQ);
|
||||
antConfig->rfFreq[1] = (uint8_t)(DEFAULT_CENTRTAL_FREQ >> 8);
|
||||
// RF MGC control
|
||||
antConfigPtr->rfTxMgc = 0;
|
||||
antConfig->rfTxMgc = 0;
|
||||
// RF channel 1&2 calibration mgc
|
||||
antConfigPtr->rf12CalMgc = 0;
|
||||
antConfig->rf12CalMgc = 0;
|
||||
// RF channel 2&3 calibration mgc
|
||||
antConfigPtr->rf34CalMgc = 0;
|
||||
antConfig->rf34CalMgc = 0;
|
||||
// Receive channel 1-4 MGC
|
||||
antConfigPtr->rcvMgc = 0;
|
||||
antConfigPtr->rfReserved0 = 0x00;
|
||||
antConfigPtr->rfReserved1 = 0x00;
|
||||
antConfig->rcvMgc = 0;
|
||||
antConfig->rfReserved0 = 0x00;
|
||||
antConfig->rfReserved1 = 0x00;
|
||||
// ***********************
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
@@ -261,10 +257,10 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
else
|
||||
{
|
||||
instPtr->beamNo.next = beamNo;
|
||||
instPtr->antConfigPtr.oaxis[1] = (uint8_t)(antNrrwPattern[beamNo].oaxis);
|
||||
instPtr->antConfigPtr.oaxis[0] = (uint8_t)((antNrrwPattern[beamNo].oaxis) >> 8);
|
||||
instPtr->antConfigPtr.raxis[1] = (uint8_t)(antNrrwPattern[beamNo].raxis);
|
||||
instPtr->antConfigPtr.raxis[0] = (uint8_t)((antNrrwPattern[beamNo].raxis) >> 8);
|
||||
instPtr->antConfig.oaxis[1] = (uint8_t)(antNrrwPattern[beamNo].oaxis);
|
||||
instPtr->antConfig.oaxis[0] = (uint8_t)((antNrrwPattern[beamNo].oaxis) >> 8);
|
||||
instPtr->antConfig.raxis[1] = (uint8_t)(antNrrwPattern[beamNo].raxis);
|
||||
instPtr->antConfig.raxis[0] = (uint8_t)((antNrrwPattern[beamNo].raxis) >> 8);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -277,10 +273,10 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
else
|
||||
{
|
||||
instPtr->beamNo.next = beamNo;
|
||||
instPtr->antConfigPtr.oaxis[1] = (uint8_t)(antSubnrrwPattern[beamNo].oaxis);
|
||||
instPtr->antConfigPtr.oaxis[0] = (uint8_t)((antSubnrrwPattern[beamNo].oaxis) >> 8);
|
||||
instPtr->antConfigPtr.raxis[1] = (uint8_t)(antSubnrrwPattern[beamNo].raxis);
|
||||
instPtr->antConfigPtr.raxis[0] = (uint8_t)((antSubnrrwPattern[beamNo].raxis) >> 8);
|
||||
instPtr->antConfig.oaxis[1] = (uint8_t)(antSubnrrwPattern[beamNo].oaxis);
|
||||
instPtr->antConfig.oaxis[0] = (uint8_t)((antSubnrrwPattern[beamNo].oaxis) >> 8);
|
||||
instPtr->antConfig.raxis[1] = (uint8_t)(antSubnrrwPattern[beamNo].raxis);
|
||||
instPtr->antConfig.raxis[0] = (uint8_t)((antSubnrrwPattern[beamNo].raxis) >> 8);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -289,10 +285,10 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
// Beam number assign not support.
|
||||
// Assign default angle (0,0)
|
||||
instPtr->beamNo.next = 0;
|
||||
instPtr->antConfigPtr.oaxis[1] = 0;
|
||||
instPtr->antConfigPtr.oaxis[0] = 0;
|
||||
instPtr->antConfigPtr.raxis[1] = 0;
|
||||
instPtr->antConfigPtr.raxis[0] = 0;
|
||||
instPtr->antConfig.oaxis[1] = 0;
|
||||
instPtr->antConfig.oaxis[0] = 0;
|
||||
instPtr->antConfig.raxis[1] = 0;
|
||||
instPtr->antConfig.raxis[0] = 0;
|
||||
DBG_WARNING("Using default beam number...\n");
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -300,7 +296,7 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
uint8_t beamConfig = instPtr->antConfigPtr.antMode & (~ANT_MODE_BEAM_MASK);
|
||||
uint8_t beamConfig = instPtr->antConfig.antMode & (~ANT_MODE_BEAM_MASK);
|
||||
switch (beamWidth)
|
||||
{
|
||||
case PHY_ANT_BEAM_120:
|
||||
@@ -320,13 +316,13 @@ int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
return EPARAM;
|
||||
break;
|
||||
}
|
||||
instPtr->antConfigPtr.antMode = beamConfig;
|
||||
instPtr->antConfig.antMode = beamConfig;
|
||||
instPtr->beamWd.next = beamWidth;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
// Common version radius double input
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx)
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *instPtr, double offAx, double rndAx)
|
||||
{
|
||||
uint16_t offAxDeg = 0;
|
||||
uint16_t rndAxDeg = 0;
|
||||
@@ -340,9 +336,9 @@ int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx)
|
||||
}
|
||||
offAxDeg = offAxDeg * 10;
|
||||
rndAxDeg = rndAxDeg * 10;
|
||||
phyInstPtr->antConfigPtr.oaxis[1] = (uint8_t)offAxDeg;
|
||||
phyInstPtr->antConfigPtr.oaxis[0] = (uint8_t)(offAxDeg >> 8);
|
||||
phyInstPtr->antConfigPtr.raxis[1] = (uint8_t)rndAxDeg;
|
||||
phyInstPtr->antConfigPtr.raxis[0] = (uint8_t)(rndAxDeg >> 8);
|
||||
instPtr->antConfig.oaxis[1] = (uint8_t)offAxDeg;
|
||||
instPtr->antConfig.oaxis[0] = (uint8_t)(offAxDeg >> 8);
|
||||
instPtr->antConfig.raxis[1] = (uint8_t)rndAxDeg;
|
||||
instPtr->antConfig.raxis[0] = (uint8_t)(rndAxDeg >> 8);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Description: Implementation of physical control functions
|
||||
*
|
||||
* Date: 2021-11-16 00:08
|
||||
* LastEditTime: 2023-04-23 17:48
|
||||
* LastEditTime: 2024-01-20 17:48
|
||||
* Revisions: Rev 0.2
|
||||
* History:
|
||||
* [2021-11-16]: Initial version.
|
||||
@@ -12,7 +12,9 @@
|
||||
* at specific time stamp.
|
||||
* -Add 61/37 beam switch
|
||||
* -Code simplification.
|
||||
* [2023-04-24]: Porting for DUIFEI.
|
||||
* [2023-04-24]: Feature add:
|
||||
* - Read frame type from PL status register.
|
||||
* [2024-01-20]: Porting for DUIFEI.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
@@ -22,81 +24,31 @@
|
||||
/***************************** Include Files *********************************/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "xbram.h"
|
||||
#include "xadcps.h"
|
||||
#include <math.h>
|
||||
#include "phy_layer.h"
|
||||
#include "util.h"
|
||||
#include "error.h"
|
||||
#include "../config/app_config.h"
|
||||
#ifndef EMULATION
|
||||
#include "xbram.h"
|
||||
#include "xadcps.h"
|
||||
#endif
|
||||
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define TOR_BUFF_MAX_SIZE 1024 // 8192bits
|
||||
#define TMWORD_FRAC_MAX 500000
|
||||
#define ANT_COINFO_LEN 32 // bytes
|
||||
#define ANTCONFIG_MAX_LEN (8192 / 2)
|
||||
#define PAYLOAD_MAX_LEN (4096 / 2)
|
||||
|
||||
#define INIT_BEAM_NO 0
|
||||
#define INIT_ANT_WD PHY_ANT_BEAM_120
|
||||
#define INIT_ANT_NO 0
|
||||
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
|
||||
#define L1_FRAME_2KBPS_100MS_LEN (240 / 8) // byte
|
||||
#define L1_FRAME_10KBPS_10MS_LEN 0 // byte
|
||||
#define L1_FRAME_10KBPS_20MS_LEN (240 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_20MS_LEN (2160 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_10MS_LEN (720 / 8) // byte
|
||||
#define L1_FRAME_200KBPS_5MS_LEN (2048 / 8) // byte
|
||||
#define L1_FRAME_1M2BPS_5MS_LEN (8184 / 8) // byte
|
||||
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns
|
||||
#define L1_FRAME_2KBPS_20MS_COMP 1622400 // *10ns
|
||||
#define L1_FRAME_2KBPS_100MS_COMP 1622400 // *10ns
|
||||
#define L1_FRAME_10KBPS_10MS_COMP 747366 // *10ns
|
||||
#define L1_FRAME_10KBPS_20MS_COMP 747366 // *10ns
|
||||
#define L1_FRAME_40KBPS_20MS_COMP 97066 // *10ns
|
||||
#define L1_FRAME_40KBPS_10MS_COMP 97066 // *10ns
|
||||
#define L1_FRAME_200KBPS_5MS_COMP 17067 // *10ns
|
||||
#define L1_FRAME_1M2BPS_5MS_COMP 17067 // *10ns
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
static void Phy_RcdShift(PHY_RCD *rcd, int32_t netxVal);
|
||||
static int32_t SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *buff);
|
||||
static int32_t Phy_SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *dataBuff);
|
||||
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get received data (base on PS Record), store it to data buffer.
|
||||
*
|
||||
* @param instPtr
|
||||
* rcvBuffPtr
|
||||
*
|
||||
* @return SUCCESS
|
||||
* FAILURE last frame type cannot be recognized.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *buff)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint32_t frameLen, recvBramAddr;
|
||||
frameLen = Phy_GetFrameLen(instPtr->frameType.last);
|
||||
if (frameLen == L1_FRAME_NONE_LEN)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ping-pong flow.
|
||||
recvBramAddr = instPtr->rxDataPtr + ((PhyRead(instPtr, RECV_DATA_SATE) & RECV_DATA_OFFSET_MASK) >> RECV_DATA_OFFSET_SHIFT);
|
||||
memcpy(buff, (uint8_t *)recvBramAddr, frameLen);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Setup data will be sent in next slot.
|
||||
@@ -107,26 +59,27 @@ int32_t Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *buff)
|
||||
* SUCCESS Setting data successful.
|
||||
*
|
||||
******************************************************************************/
|
||||
static int32_t SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *buff)
|
||||
static int32_t Phy_SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *dataBuff)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(dataBuff != NULL);
|
||||
uint32_t frameLen, sendCmd;
|
||||
|
||||
frameLen = Phy_GetFrameLen(frameType);
|
||||
|
||||
if (frameLen == L1_FRAME_NONE_LEN)
|
||||
{
|
||||
return FAILURE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Implement a ping-pong flow, offset always is 0 or half of buffer depth.
|
||||
instPtr->sendOffset = (instPtr->sendOffset == PAYLOAD_MAX_LEN) ? 0 : PAYLOAD_MAX_LEN;
|
||||
memcpy((uint8_t *)(instPtr->txDataPtr + instPtr->sendOffset), buff, frameLen);
|
||||
// Trigger Physical layer to start fetching data.
|
||||
sendCmd = frameLen & SEND_DATA_CMD_LEN_MASK;
|
||||
sendCmd |= (instPtr->sendOffset << SEND_DATA_CMD_OFFSET_SHIFT) & SEND_DATA_CMD_OFFSET_MASK;
|
||||
PhyWrite(instPtr, SEND_DATA_CMD, sendCmd);
|
||||
DBG_ERROR("Invalid frame length.\n");
|
||||
return EPARAM;
|
||||
}
|
||||
instPtr->sendDataOffset = (L1_TXRXDATA_MAX_LEN >> 1) - instPtr->sendDataOffset;
|
||||
memcpy((uint8_t *)(instPtr->sendDataAddr + instPtr->sendDataOffset), dataBuff, frameLen);
|
||||
|
||||
sendCmd = frameLen & SEND_DATA_CMD_LEN_MASK;
|
||||
sendCmd |= (instPtr->sendDataOffset << SEND_DATA_CMD_OFFSET_SHIFT) & SEND_DATA_CMD_OFFSET_MASK;
|
||||
|
||||
// Physical layer start fetching data.
|
||||
PhyWrite(instPtr, SEND_DATA_CMD, sendCmd);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -135,7 +88,7 @@ static int32_t SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *
|
||||
* @brief Check whether a frame was detected. (Do not check if the frame was
|
||||
* deoced.)
|
||||
*
|
||||
* @param instPtr
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return true
|
||||
* false
|
||||
@@ -144,7 +97,7 @@ static int32_t SetSendData(PHY_INST *instPtr, L1_FRAME_TYPE frameType, uint8_t *
|
||||
inline bool Phy_IsFrameDetected(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->TOR.last == PHY_TOR_RX && instPtr->isAcq && instPtr->isFrameSync)
|
||||
if (instPtr->isAcq && instPtr->isFrameSync)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -159,7 +112,7 @@ inline bool Phy_IsFrameDetected(PHY_INST *instPtr)
|
||||
* @brief Check whether a frame was received. (Do not check if the frame was
|
||||
* crashed.)
|
||||
*
|
||||
* @param instPtr
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return true
|
||||
* false
|
||||
@@ -168,7 +121,7 @@ inline bool Phy_IsFrameDetected(PHY_INST *instPtr)
|
||||
inline bool Phy_IsFrameReceived(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->TOR.last == PHY_TOR_RX && instPtr->isAcq && instPtr->isFrameSync && instPtr->isDecode)
|
||||
if (instPtr->isAcq && instPtr->isFrameSync && instPtr->isDecode)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -192,58 +145,30 @@ inline bool Phy_IsFrameReceived(PHY_INST *instPtr)
|
||||
inline bool Phy_IsFrameValid(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->TOR.last == PHY_TOR_RX && instPtr->isAcq && instPtr->isFrameSync && instPtr->isDecode && instPtr->isValid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return instPtr->isValid;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get frame type of the frame in receive data buffer (Base on PS Record).
|
||||
* @brief Get frame type of the frame in receive data buffer (Base on PL Record).
|
||||
*
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return Layer2 frame type. Refer "frame_def.h"
|
||||
*
|
||||
******************************************************************************/
|
||||
inline L1_FRAME_TYPE Phy_GetLastDetectedFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (Phy_IsFrameDetected(instPtr) == false)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
return instPtr->frameType.last;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get frame type of the frame in receive data buffer (Base on PS Record).
|
||||
*
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return Layer2 frame type. Refer "frame_def.h"
|
||||
*
|
||||
******************************************************************************/
|
||||
inline L1_FRAME_TYPE Phy_GetLastReceivedFrameType(PHY_INST *instPtr)
|
||||
inline L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (Phy_IsFrameReceived(instPtr) == false)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
int32_t frame_type = (PhyRead(instPtr, PHY_MODE_CTRL) & PHY_MODE_CTRL_FRAME_MASK) >> PHY_MODE_CTRL_FRAME_SHIFT;
|
||||
if (frame_type < L1_1M2BPS_5MS_FRAME)
|
||||
return frame_type;
|
||||
else
|
||||
{
|
||||
return instPtr->frameType.last;
|
||||
}
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -255,17 +180,14 @@ inline L1_FRAME_TYPE Phy_GetLastReceivedFrameType(PHY_INST *instPtr)
|
||||
* @return Layer2 frame type. Refer "frame_def.h"
|
||||
*
|
||||
******************************************************************************/
|
||||
inline L1_FRAME_TYPE Phy_GetLastSentFrameType(PHY_INST *instPtr)
|
||||
inline L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->TOR.last != PHY_TOR_TX)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
else
|
||||
{
|
||||
return instPtr->frameType.last;
|
||||
}
|
||||
return instPtr->frameType.last;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -300,9 +222,7 @@ uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType)
|
||||
switch (frameType)
|
||||
{
|
||||
case L1_2KBPS_20MS_FRAME:
|
||||
// FIXME: for DUIFEI net setup
|
||||
return L1_FRAME_2KBPS_100MS_LEN;
|
||||
// return L1_FRAME_2KBPS_20MS_LEN;
|
||||
return L1_FRAME_2KBPS_20MS_LEN;
|
||||
case L1_2KBPS_100MS_FRAME:
|
||||
return L1_FRAME_2KBPS_100MS_LEN;
|
||||
case L1_10KBPS_10MS_FRAME:
|
||||
@@ -324,38 +244,38 @@ uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update Physical Layer reception status.
|
||||
* @brief Update physical layer status cache.
|
||||
*
|
||||
* @param instPtr
|
||||
* @param instPtr A pointer to physical layer control instance.
|
||||
*
|
||||
* @return
|
||||
* @return NONE.
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_UpdateState(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
|
||||
Phy_RcdShift(&(instPtr->TOR), PHY_TOR_SUSPEND);
|
||||
Phy_RcdShift(&(instPtr->frameType), L1_NONE_FRAME);
|
||||
Phy_RcdShift(&(instPtr->antNo), INIT_ANT_NO);
|
||||
Phy_RcdShift(&(instPtr->beamNo), INIT_BEAM_NO);
|
||||
Phy_RcdShift(&(instPtr->beamWd), INIT_ANT_WD);
|
||||
/* Update Frame Sate. */
|
||||
uint32_t txrxSate = PhyRead(instPtr, TXRX_STATE);
|
||||
instPtr->isAcq = ((txrxSate & TXRX_STATE_ACQ_MASK) == TXRX_STATE_ACQ_SUCCESS) ? true : false;
|
||||
instPtr->isFrameSync = ((txrxSate & TXRX_STATE_FSYNC_MASK) == TXRX_STATE_FSYNC_SUCCESS) ? true : false;
|
||||
instPtr->isDecode = ((txrxSate & TXRX_STATE_DECODE_MASK) == TXRX_STATE_DECODE_SUCCESS) ? true : false;
|
||||
// instPtr->isAcq = ((txrxSate & TXRX_STATE_ACQ_MASK) == TXRX_STATE_ACQ_SUCCESS) ? true : false;
|
||||
// instPtr->isFrameSync = ((txrxSate & TXRX_STATE_FSYNC_MASK) == TXRX_STATE_FSYNC_SUCCESS) ? true : false;
|
||||
|
||||
// FIXME: using default value, since physical layer may provide unexpected error value.
|
||||
instPtr->isAcq = true;
|
||||
instPtr->isFrameSync = true;
|
||||
instPtr->isDecode = ((txrxSate & TXRX_STATE_DECODE_MASK) == TXRX_STATE_DECODE_SUCCESS) ? true : false;
|
||||
if (Phy_IsFrameReceived(instPtr))
|
||||
{
|
||||
DBG_INFO("Physical layer finished reception procedure, retrieving received data...\n");
|
||||
instPtr->isValid = true;
|
||||
instPtr->isValid = ((txrxSate & TXRX_STATE_CRC_MASK) == TXRX_STATE_CRC_OK) ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
instPtr->isValid = false;
|
||||
}
|
||||
return;
|
||||
instPtr->recvSlotTime.int_part = PhyRead(instPtr, TM_TARGET_H);
|
||||
instPtr->recvSlotTime.frac_part = PhyRead(instPtr, TM_TARGET_L);
|
||||
instPtr->recvFsTime.int_part = PhyRead(instPtr, FSTIME_H);
|
||||
instPtr->recvFsTime.frac_part = PhyRead(instPtr, FSTIME_L);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -363,17 +283,18 @@ void Phy_UpdateState(PHY_INST *instPtr)
|
||||
* @brief Initialize Physical Layer instance, allocate memory for buffers,
|
||||
* apply a self test.
|
||||
*
|
||||
* @param instPtr
|
||||
* phyConfig
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param phyConfig a pointer to configuration structure.
|
||||
*
|
||||
* @return
|
||||
* @return SUCCESS
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(phyConfig != NULL);
|
||||
int32_t Status = SUCCESS;
|
||||
int32_t Status;
|
||||
|
||||
*instPtr = (PHY_INST *)malloc(sizeof(PHY_INST));
|
||||
if ((*instPtr) == NULL)
|
||||
{
|
||||
@@ -387,26 +308,27 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
(*instPtr)->isDecode = false;
|
||||
(*instPtr)->isValid = false;
|
||||
(*instPtr)->isPresetHop = true;
|
||||
(*instPtr)->recvFsTime.int_part = UINT32_MAX;
|
||||
(*instPtr)->recvFsTime.frac_part = UINT32_MAX;
|
||||
(*instPtr)->recvSlotTime.int_part = UINT32_MAX;
|
||||
(*instPtr)->recvSlotTime.frac_part = UINT32_MAX;
|
||||
(*instPtr)->antConfigOffset = 0;
|
||||
(*instPtr)->sendOffset = 0;
|
||||
(*instPtr)->sendDataOffset = 0;
|
||||
Phy_AntConfigInit(&((*instPtr)->antConfig));
|
||||
|
||||
memset(&((*instPtr))->TOR, PHY_TOR_SUSPEND, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->frameType), L1_NONE_FRAME, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->antNo), (int32_t)INIT_BEAM_NO, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->beamNo), (int32_t)INIT_ANT_NO, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->beamWd), (int32_t)INIT_ANT_WD, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->antNo), (int32_t)L1_INIT_BEAM_NO, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->beamNo), (int32_t)L1_INIT_ANT_NO, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->beamWd), (int32_t)L1_INIT_ANT_WD, sizeof(PHY_RCD));
|
||||
memset(&((*instPtr)->hwSate), 0x00, sizeof(HWSTATE));
|
||||
|
||||
Status = Phy_AntConfigInit(&((*instPtr)->antConfigPtr));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
#ifndef EMULATION
|
||||
XBram_Config *bramConfigPtr;
|
||||
XBram antConfigBram;
|
||||
XBram txDataBram;
|
||||
XBram rxDataBram;
|
||||
|
||||
bramConfigPtr = XBram_LookupConfig(phyConfig->antBramId);
|
||||
if (bramConfigPtr == NULL)
|
||||
{
|
||||
@@ -470,9 +392,29 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
(*instPtr)->txDataPtr = txDataBram.Config.MemBaseAddress;
|
||||
(*instPtr)->rxDataPtr = rxDataBram.Config.MemBaseAddress;
|
||||
(*instPtr)->antConfigDataPtr = antConfigBram.Config.MemBaseAddress;
|
||||
(*instPtr)->antConfigAddr = antConfigBram.Config.MemBaseAddress;
|
||||
(*instPtr)->recvDataAddr = rxDataBram.Config.MemBaseAddress;
|
||||
(*instPtr)->sendDataAddr = txDataBram.Config.MemBaseAddress;
|
||||
#else
|
||||
(*instPtr)->antConfigAddr = (uintptr_t)calloc(L1_ANTCONFIG_MAX_LEN / sizeof(uint64_t), sizeof(uint64_t));
|
||||
if ((*instPtr)->antConfigAddr == (uintptr_t)NULL)
|
||||
{
|
||||
Status = EDCONF;
|
||||
goto init_error;
|
||||
}
|
||||
(*instPtr)->recvDataAddr = (uintptr_t)calloc(L1_TXRXDATA_MAX_LEN / sizeof(uint64_t), sizeof(uint64_t));
|
||||
if ((*instPtr)->recvDataAddr == (uintptr_t)NULL)
|
||||
{
|
||||
Status = EDCONF;
|
||||
goto init_error;
|
||||
}
|
||||
(*instPtr)->sendDataAddr = (uintptr_t)calloc(L1_TXRXDATA_MAX_LEN / sizeof(uint64_t), sizeof(uint64_t));
|
||||
if ((*instPtr)->sendDataAddr == (uintptr_t)NULL)
|
||||
{
|
||||
Status = EDCONF;
|
||||
goto init_error;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Initialize the XAdc driver. */
|
||||
XAdcPs_Config *xadcConfigPtr;
|
||||
@@ -497,10 +439,33 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
|
||||
return SUCCESS;
|
||||
init_error:
|
||||
free(*instPtr);
|
||||
Phy_Destroy(*instPtr);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Destroy physical layer inctance, free allocated memory.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_Destroy(PHY_INST *instPtr)
|
||||
{
|
||||
if (instPtr == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#ifdef EMULATION
|
||||
free((void *)instPtr->antConfigAddr);
|
||||
free((void *)instPtr->recvDataAddr);
|
||||
free((void *)instPtr->sendDataAddr);
|
||||
#endif
|
||||
free(instPtr);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Start physical layer
|
||||
@@ -546,17 +511,19 @@ void Phy_Halt(PHY_INST *instPtr)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Update Physical Layer mode.
|
||||
* @brief Set physical layer working mode.
|
||||
*
|
||||
* @param instPtr
|
||||
* modeCod
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param modeCod intened mode code
|
||||
*
|
||||
* @return
|
||||
* @return SUCCESS
|
||||
* other
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetMode(PHY_INST *instPtr, PHY_MODE modeCod)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
|
||||
uint32_t phyMainCtrl = PhyRead(instPtr, PHY_MAIN_CTRL) & ~PHY_MAIN_CTRL_MODE_MASK;
|
||||
switch (modeCod)
|
||||
{
|
||||
@@ -584,23 +551,24 @@ int32_t Phy_SetMode(PHY_INST *instPtr, PHY_MODE modeCod)
|
||||
/**
|
||||
* @brief Setup next slot operation.
|
||||
*
|
||||
* @param instPtr
|
||||
* txrxMode
|
||||
* l2FrameType
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param txrxMode tor type of next slot
|
||||
* @param frameType frame type of next slot
|
||||
*
|
||||
* @return
|
||||
* @return SUCCESS
|
||||
* other
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
L1_FRAME_TYPE frameType, uint8_t *buff)
|
||||
L1_FRAME_TYPE frameType, uint8_t *dataBuff)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
int32_t Status = SUCCESS;
|
||||
uint32_t phyModeCtrl, antConfigBramAddr, hopNum;
|
||||
int32_t Status;
|
||||
uint32_t phyModeCtrl, hopNum;
|
||||
uint16_t *hopPattern;
|
||||
// Implement a ping-pong flow, offset always is 0 or half of buffer depth.
|
||||
instPtr->antConfigOffset = (instPtr->antConfigOffset == ANTCONFIG_MAX_LEN) ? 0 : ANTCONFIG_MAX_LEN;
|
||||
antConfigBramAddr = instPtr->antConfigDataPtr + instPtr->antConfigOffset;
|
||||
instPtr->antConfigOffset = (L1_ANTCONFIG_MAX_LEN >> 1) - instPtr->antConfigOffset;
|
||||
uint32_t antConfigAddr = instPtr->antConfigAddr + instPtr->antConfigOffset;
|
||||
|
||||
instPtr->TOR.next = txrxMode;
|
||||
instPtr->frameType.next = frameType;
|
||||
@@ -625,84 +593,98 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (frameType)
|
||||
{
|
||||
case L1_2KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_20MS;
|
||||
hopNum = L1_FRAME_2KBPS_20MS_HOPS;
|
||||
// FIXME: For DUIFEI net setup.
|
||||
// hopPattern = (txrxMode == TOR_TX) ? hopPattern_2KBPS_20MS;
|
||||
hopPattern = hopPattern_2KBPS_100MS;
|
||||
break;
|
||||
case L1_2KBPS_100MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_100MS;
|
||||
hopNum = L1_FRAME_2KBPS_100MS_HOPS;
|
||||
hopPattern = hopPattern_2KBPS_100MS;
|
||||
break;
|
||||
case L1_10KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_10MS;
|
||||
hopNum = L1_FRAME_10KBPS_10MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_10MS;
|
||||
break;
|
||||
case L1_10KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_20MS;
|
||||
hopNum = L1_FRAME_10KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_20MS;
|
||||
break;
|
||||
case L1_40KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
break;
|
||||
case L1_40KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_10MS;
|
||||
hopNum = L1_FRAME_40KBPS_10MS_HOPS;
|
||||
hopPattern = hopPattern_40KBPS_10MS;
|
||||
break;
|
||||
case L1_200KBPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
break;
|
||||
case L1_1M2BPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_1M2BPS_5MS;
|
||||
hopNum = L1_FRAME_1M2BPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_1M2BPS_5MS;
|
||||
break;
|
||||
default:
|
||||
return EPARAM;
|
||||
break;
|
||||
}
|
||||
switch (frameType)
|
||||
{
|
||||
case L1_2KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_20MS;
|
||||
hopNum = L1_FRAME_2KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_10MS;
|
||||
break;
|
||||
case L1_2KBPS_100MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_100MS;
|
||||
hopNum = L1_FRAME_2KBPS_100MS_HOPS;
|
||||
hopPattern = hopPattern_2KBPS_100MS;
|
||||
break;
|
||||
case L1_10KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_10MS;
|
||||
hopNum = L1_FRAME_10KBPS_10MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_10MS;
|
||||
break;
|
||||
case L1_10KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_10KBPS_20MS;
|
||||
hopNum = L1_FRAME_10KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_20MS;
|
||||
break;
|
||||
case L1_40KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
break;
|
||||
case L1_40KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_10MS;
|
||||
hopNum = L1_FRAME_40KBPS_10MS_HOPS;
|
||||
hopPattern = hopPattern_40KBPS_10MS;
|
||||
break;
|
||||
case L1_200KBPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
break;
|
||||
case L1_1M2BPS_5MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_1M2BPS_5MS;
|
||||
hopNum = L1_FRAME_1M2BPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_1M2BPS_5MS;
|
||||
break;
|
||||
default:
|
||||
return EPARAM;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PhyWrite(instPtr, PHY_MODE_CTRL, phyModeCtrl);
|
||||
|
||||
// TODO: Set antenna stand by, when suspend.
|
||||
const uint8_t *dataSrcPtr = (uint8_t *)(&(instPtr->antConfigPtr));
|
||||
const uint8_t *dataSrcPtr = (uint8_t *)(&(instPtr->antConfig));
|
||||
for (int32_t i = 0; i < hopNum; i++)
|
||||
{
|
||||
instPtr->antConfigPtr.antFreq[1] = (uint8_t)(hopPattern[i] & 0x00FF);
|
||||
instPtr->antConfigPtr.antFreq[0] = (uint8_t)((hopPattern[i] >> 8) & 0x00FF);
|
||||
instPtr->antConfigPtr.rfFreq[1] = (uint8_t)(hopPattern[i] & 0x00FF);
|
||||
instPtr->antConfigPtr.rfFreq[0] = (uint8_t)((hopPattern[i] >> 8) & 0x00FF);
|
||||
memcpy((uint8_t *)(antConfigBramAddr + i * ANT_COINFO_LENGTH),
|
||||
dataSrcPtr, sizeof(PHY_ANT_COINFO));
|
||||
instPtr->antConfig.antFreq[1] = (uint8_t)(hopPattern[i] & 0x00FF);
|
||||
instPtr->antConfig.antFreq[0] = (uint8_t)((hopPattern[i] >> 8) & 0x00FF);
|
||||
instPtr->antConfig.rfFreq[1] = (uint8_t)(hopPattern[i] & 0x00FF);
|
||||
instPtr->antConfig.rfFreq[0] = (uint8_t)((hopPattern[i] >> 8) & 0x00FF);
|
||||
memcpy((uint8_t *)(antConfigAddr + i *ANT_COINFO_LEN),
|
||||
dataSrcPtr, sizeof(PHY_ANT_CONFIG));
|
||||
}
|
||||
uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_CMD_OFFSET_MASK) | ((hopNum << ANT_CONFIG_CMD_NUM_SHIFT) & ANT_CONFIG_CMD_NUM_MASK) | ((ANT_COINFO_LENGTH << ANT_CONFIG_CMD_LEN_SHIFT) & ANT_CONFIG_CMD_LEN_MASK);
|
||||
PhyWrite(instPtr, ANT_CONFIG_CMD, antCtrl);
|
||||
uint32_t antCtrl = (instPtr->antConfigOffset & ANT_CONFIG_OFFSET_MASK)
|
||||
| ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK)
|
||||
| ((ANT_COINFO_LEN << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK);
|
||||
|
||||
/*
|
||||
memcpy((uint8_t*)antConfigDataAddr, hopPattern, hopNum*sizeof(uint16_t));
|
||||
uint32_t antCtrl = (instPtr->antCoinfigOffset & ANT_CONFIG_OFFSET_MASK)
|
||||
| ((hopNum << ANT_CONFIG_NUM_SHIFT) & ANT_CONFIG_NUM_MASK)
|
||||
| ((sizeof(uint16_t) << ANT_CONFIG_LEN_SHIFT) & ANT_CONFIG_LEN_MASK);
|
||||
*/
|
||||
|
||||
PhyWrite(instPtr, ANT_CONFIG, antCtrl);
|
||||
|
||||
// FIXME: For DUIFEI network setup. Should only set send data in send slots.
|
||||
if (txrxMode == PHY_TOR_TX)
|
||||
{
|
||||
Status = SetSendData(instPtr, frameType, buff);
|
||||
Status = Phy_SetSendData(instPtr, frameType, dataBuff);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to apply send data.\n");
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
|
||||
// Trigger physical configuration.
|
||||
PhyWrite(instPtr, SLOT_CONFIG_CMD, SLOT_CONFIG_CMD_VAULE); // Phy start fetching data.
|
||||
// Indicate physical layer that all the configurations were done.
|
||||
PhyWrite(instPtr, SLOT_CMD, SLOT_CMD_KEY);
|
||||
|
||||
Phy_RcdShift(&(instPtr->TOR), txrxMode);
|
||||
Phy_RcdShift(&(instPtr->frameType), frameType);
|
||||
// TODO:
|
||||
Phy_RcdShift(&(instPtr->antNo), L1_INIT_ANT_NO);
|
||||
Phy_RcdShift(&(instPtr->beamNo), L1_INIT_BEAM_NO);
|
||||
Phy_RcdShift(&(instPtr->beamWd), L1_INIT_ANT_WD);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -744,11 +726,12 @@ uint32_t Phy_GetHopLength(L1_FRAME_TYPE frameType)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the time from frame sync to slot end of different type.
|
||||
* @brief Get the corresponding time compensation value (time interval from
|
||||
* frame start to frame sync)
|
||||
*
|
||||
* @param frameType
|
||||
* @param frameType a L1 frame type enumeration.
|
||||
*
|
||||
* @return 32bit unsigned integer (clock periods)
|
||||
* @return 32bit unsigned integer (10ns)
|
||||
*
|
||||
******************************************************************************/
|
||||
uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType)
|
||||
@@ -778,25 +761,44 @@ uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType)
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get latest frequency deviation estimation.
|
||||
* @brief Get coarse frequency estimation of last valid frame.
|
||||
*
|
||||
* @param instPtr
|
||||
* @param instPtr a pointer to physical instance
|
||||
*
|
||||
* @return 32bit signed integer (Hz)
|
||||
* @return frequency estimation
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_GetFreqEst(PHY_INST *instPtr)
|
||||
double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
|
||||
{
|
||||
uint32_t temp;
|
||||
int32_t acqCh, fsCh;
|
||||
ASSERT(instPtr != NULL);
|
||||
uint32_t regValue;
|
||||
uint8_t acqFreqIdx;
|
||||
int8_t syncFreqIdx;
|
||||
L1_FRAME_TYPE frameType;
|
||||
double freqEst;
|
||||
temp = PhyRead(instPtr, COASE_FREQEST);
|
||||
acqCh = temp & 0x000000FF;
|
||||
acqCh = 80 - acqCh;
|
||||
fsCh = (temp >> 8) & 0x000000FF;
|
||||
fsCh = fsCh - 128;
|
||||
freqEst = acqCh * (31.25e3 / 4) + fsCh * (31.25e3 / 256);
|
||||
return ((int32_t)freqEst);
|
||||
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType == L1_NONE_FRAME)
|
||||
{
|
||||
return INFINITY; // FIXME:
|
||||
}
|
||||
regValue = PhyRead(instPtr, COASE_FREQEST);
|
||||
acqFreqIdx = (regValue & COASE_FREQEST_ACQ_MASK) >> COASE_FREQEST_ACQ_SHIFT;
|
||||
syncFreqIdx = (regValue & COASE_FREQEST_SYNC_MASK) >> COASE_FREQEST_SYNC_SHIFT;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
{
|
||||
// 1.5M Rc
|
||||
freqEst = (double)(80 - acqFreqIdx) * (31.25e3 / 4);
|
||||
freqEst += (double)syncFreqIdx * 1.5e6 / 64 / 128;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 12M Rc
|
||||
freqEst = (double)(8 - acqFreqIdx) * (250e3 / 4);
|
||||
freqEst += (double)syncFreqIdx * 12e6 / 64 / 128;
|
||||
}
|
||||
|
||||
return freqEst;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -833,21 +835,22 @@ int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen)
|
||||
* FAILURE pattern length exceeds maximum length.
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, uint64_t tmWord, PHY_TIME_WORD_TYPE tmType)
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (tmWord->frac_part >= PHY_TIME_WORD_L_MAX)
|
||||
{
|
||||
return EPARAM;
|
||||
}
|
||||
switch (tmType)
|
||||
{
|
||||
case PHY_TIME_WORD_POLL:
|
||||
PhyWrite(instPtr, POLLTIME_L, (uint32_t)tmWord);
|
||||
PhyWrite(instPtr, POLLTIME_H, (uint32_t)(tmWord >> 32));
|
||||
PhyWrite(instPtr, POLLTIME_L, tmWord->frac_part);
|
||||
PhyWrite(instPtr, POLLTIME_H, tmWord->int_part);
|
||||
break;
|
||||
case PHY_TIME_WORD_LOCAL_ADJ:
|
||||
PhyWrite(instPtr, LOCALTM_ADJ_L, (uint32_t)tmWord);
|
||||
PhyWrite(instPtr, LOCALTM_ADJ_H, (uint32_t)(tmWord >> 32));
|
||||
break;
|
||||
case PHY_TIME_WORD_STEP:
|
||||
PhyWrite(instPtr, CNT_STEP_OPT, (uint32_t)tmWord);
|
||||
case PHY_TIME_WORD_LISTEN_TIMEOUT:
|
||||
PhyWrite(instPtr, LISTENTIMEOUT_L, tmWord->frac_part);
|
||||
PhyWrite(instPtr, LISTENTIMEOUT_H, tmWord->int_part);
|
||||
break;
|
||||
default:
|
||||
return EPARAM;
|
||||
@@ -855,6 +858,124 @@ int32_t Phy_SetTimeWord(PHY_INST *instPtr, uint64_t tmWord, PHY_TIME_WORD_TYPE t
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the frame sync time of last frame.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param frameSycT a pointer to the frame sync time data buffer.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_GetFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(frameSyncT != NULL);
|
||||
frameSyncT->int_part = PhyRead(instPtr, FSTIME_H);
|
||||
frameSyncT->frac_part = PhyRead(instPtr, FSTIME_L);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the frame sync time of last received frame.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param frameSycT a pointer to the frame sync time data buffer.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_GetLastReceivedFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(frameSyncT != NULL);
|
||||
memcpy(frameSyncT, &(instPtr->recvFsTime), sizeof(TIME_WORD));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the slot start time of last received frame.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param slotStart a pointer to the time data buffer.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_GetSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(slotStart != NULL);
|
||||
slotStart->int_part = PhyRead(instPtr, TM_TARGET_H);
|
||||
slotStart->frac_part = PhyRead(instPtr, TM_TARGET_L);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the slot start time of last frame.
|
||||
*
|
||||
* @param instPtr a pointer to physical instance
|
||||
* @param slotStart a pointer to the time data buffer.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_GetLastReceivedSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(slotStart != NULL);
|
||||
memcpy(slotStart, &(instPtr->recvSlotTime), sizeof(TIME_WORD));
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Copy ans store the received data, if received data valid.
|
||||
*
|
||||
* @param instPtr a pointer to physical layer control instance.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_PeekRecvData(PHY_INST *instPtr, uint8_t *dataBuff)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(dataBuff != NULL);
|
||||
if (instPtr->isValid == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
uint32_t frameLen, offset;
|
||||
|
||||
frameLen = (PhyRead(instPtr, RECVDATA_STATE) & RECVDATA_STATE_LEN_MASK) >> RECVDATA_STATE_LEN_SHIFT;
|
||||
offset = (PhyRead(instPtr, RECVDATA_STATE) & RECVDATA_STATE_OFFSET_MASK) >> RECVDATA_STATE_OFFSET_SHIFT;
|
||||
|
||||
memcpy(dataBuff, (uint8_t *)(instPtr->recvDataAddr + offset), frameLen);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Get the received data (if valid), store it to data buffer.
|
||||
* and clear data valid flag.
|
||||
*
|
||||
* @param instPtr a pointer to physical layer control instance.
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *dataBuff)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(dataBuff != NULL);
|
||||
if (instPtr->isValid == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Phy_PeekRecvData(instPtr, dataBuff);
|
||||
instPtr->isValid = false;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Setup a specific timer word register in physical controller.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Description: Physical layer control definitions and function prototypes.
|
||||
*
|
||||
* Date: 2021-12-04 16:32
|
||||
* LastEditTime: 2023-04-24 17:41
|
||||
* LastEditTime: 2024-01-20 17:41
|
||||
* Revisions: Rev 0.1
|
||||
* History:
|
||||
* [2021-12-08]: Initial version.
|
||||
@@ -12,7 +12,9 @@
|
||||
* at specific time stamp.
|
||||
* -Add 61/37 beam switch
|
||||
* -Code simplification.
|
||||
* [2023-04-24]: Porting for DUIFEI.
|
||||
* [2023-04-24]: Feature add:
|
||||
* - Read frame type from PL status register.
|
||||
* [2024-01-20]: New branch for DUIFEI.
|
||||
*
|
||||
* Copyright(c) 2021 Beijing Institute of Technology.
|
||||
* Lab of Communication and Networking
|
||||
@@ -29,7 +31,17 @@
|
||||
#include "xadcps.h"
|
||||
#include "phy_reg.h"
|
||||
#include "../../system_monitor.h"
|
||||
#include "../../time_ctrl/time_ctrl.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define L1_TMWORD_FRAC_MAX 500000
|
||||
#define L1_ANTCONFIG_MAX_LEN 8192
|
||||
#define L1_TXRXDATA_MAX_LEN 2048
|
||||
#define L1_NUM_ANT_SUBNRRW_PATTERN 37
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 61
|
||||
#define L1_INIT_BEAM_NO 0
|
||||
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120
|
||||
#define L1_INIT_ANT_NO 0
|
||||
|
||||
#define L1_FRAME_NONE_HOPS UINT32_MAX
|
||||
#define L1_FRAME_MAX_HOPS 81
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1
|
||||
@@ -41,10 +53,29 @@
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
|
||||
#define L1_NUM_ANT_SUBNRRW_PATTERN 37
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 61
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
|
||||
#define L1_FRAME_2KBPS_20MS_LEN 1 // byte
|
||||
#define L1_FRAME_2KBPS_100MS_LEN 312 / 8 // byte
|
||||
#define L1_FRAME_10KBPS_10MS_LEN 1 // byte
|
||||
#define L1_FRAME_10KBPS_20MS_LEN (232 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_20MS_LEN (2152 / 8) // byte
|
||||
#define L1_FRAME_40KBPS_10MS_LEN (712 / 8) // byte
|
||||
#define L1_FRAME_200KBPS_5MS_LEN (2040 / 8) // byte
|
||||
#define L1_FRAME_1M2BPS_5MS_LEN (8176 / 8) // byte
|
||||
|
||||
#define ANT_COINFO_LENGTH 32 // bytes
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_2KBPS_20MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_2KBPS_100MS_COMP 1841158 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_10MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_10KBPS_20MS_COMP 850950 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_20MS_COMP 110667 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_10MS_COMP 110667 // *10ns(Timer_L)
|
||||
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
|
||||
#define PHY_TIME_WORD_H_MAX UINT32_MAX
|
||||
#define PHY_TIME_WORD_L_MAX 0x0007A120 // 5ms/10ns
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
typedef enum
|
||||
@@ -113,7 +144,7 @@ typedef struct
|
||||
/* reserved for further use */
|
||||
uint8_t rfReserved0;
|
||||
uint8_t rfReserved1;
|
||||
} PHY_ANT_COINFO;
|
||||
} PHY_ANT_CONFIG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -129,9 +160,7 @@ typedef enum
|
||||
{
|
||||
PHY_TIME_WORD_NONE = 0,
|
||||
PHY_TIME_WORD_POLL = 1,
|
||||
PHY_TIME_WORD_LISTEN_TIMEOUT = 2,
|
||||
PHY_TIME_WORD_LOCAL_ADJ = 3,
|
||||
PHY_TIME_WORD_STEP = 4,
|
||||
PHY_TIME_WORD_LISTEN_TIMEOUT = 2
|
||||
} PHY_TIME_WORD_TYPE;
|
||||
|
||||
typedef enum
|
||||
@@ -177,24 +206,26 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PHY_CONFIG phyCofig; // Device address configs
|
||||
bool isPhyEn; // if physical layer running
|
||||
bool isAcq; // if last reception acquisition success
|
||||
bool isFrameSync; // if last reception frame sync success
|
||||
bool isDecode; // if last reception decode success
|
||||
bool isValid; // if last reception frame data valid (crc check pass)
|
||||
bool isPresetHop; // if using preset frequency hop
|
||||
PHY_RCD antNo; // antenna number record
|
||||
PHY_RCD beamNo; // beam number record
|
||||
PHY_RCD beamWd; // beam width record
|
||||
PHY_RCD TOR; // tx rx state record
|
||||
PHY_RCD frameType; // frame type record
|
||||
uint32_t antConfigOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
uint32_t sendOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
PHY_ANT_COINFO antConfigPtr; // antenna configuration pointer
|
||||
uintptr_t txDataPtr;
|
||||
uintptr_t rxDataPtr;
|
||||
uintptr_t antConfigDataPtr;
|
||||
PHY_CONFIG phyCofig; // Device address configs
|
||||
uintptr_t recvDataAddr;
|
||||
uintptr_t sendDataAddr;
|
||||
uintptr_t antConfigAddr;
|
||||
bool isPhyEn; // if physical layer running
|
||||
bool isAcq; // if last reception acquisition success
|
||||
bool isFrameSync; // if last reception frame sync success
|
||||
bool isDecode; // if last reception decode success
|
||||
bool isValid; // if last reception frame data valid (crc check pass)
|
||||
bool isPresetHop; // if using preset frequency hop
|
||||
TIME_WORD recvSlotTime; // last slot start time stamp
|
||||
TIME_WORD recvFsTime; // last frame sync time stamp
|
||||
PHY_RCD antNo; // antenna number record
|
||||
PHY_RCD beamNo; // beam number record
|
||||
PHY_RCD beamWd; // beam width record
|
||||
PHY_RCD TOR; // tx rx state record
|
||||
PHY_RCD frameType; // frame type record
|
||||
uint32_t sendDataOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
uint32_t antConfigOffset; // antenna configuration bram offset (to implement ping-pong data flow)
|
||||
PHY_ANT_CONFIG antConfig; // antenna configuration pointer
|
||||
XAdcPs hwXadc;
|
||||
HWSTATE hwSate;
|
||||
} PHY_INST;
|
||||
@@ -216,6 +247,8 @@ extern PHY_ANT_ANGLE antNrrwPattern[L1_NUM_ANT_NRRW_PATTERN];
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig);
|
||||
void Phy_Destroy(PHY_INST *instPtr);
|
||||
|
||||
void Phy_UpdateState(PHY_INST *instPtr);
|
||||
void Phy_UpdateHwSate(PHY_INST *instPtr);
|
||||
|
||||
@@ -223,27 +256,31 @@ void Phy_Start(PHY_INST *instPtr);
|
||||
void Phy_Halt(PHY_INST *instPtr);
|
||||
int32_t Phy_SetMode(PHY_INST *instPtr, PHY_MODE modeCod);
|
||||
|
||||
int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, L1_FRAME_TYPE frameType, uint8_t *buff);
|
||||
int32_t Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *buff);
|
||||
int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode, L1_FRAME_TYPE frameType, uint8_t *dataBuff);
|
||||
void Phy_PeekRecvData(PHY_INST *instPtr, uint8_t *dataBuff);
|
||||
void Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *dataBuff);
|
||||
|
||||
bool Phy_IsFrameDetected(PHY_INST *instPtr);
|
||||
bool Phy_IsFrameReceived(PHY_INST *instPtr);
|
||||
bool Phy_IsFrameValid(PHY_INST *instPtr);
|
||||
uint32_t Phy_GetFrameLen(L1_FRAME_TYPE frameType);
|
||||
|
||||
L1_FRAME_TYPE Phy_GetLastDetectedFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastReceivedFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastSentFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr);
|
||||
L1_FRAME_TYPE Phy_GetLastSendFrameType(PHY_INST *instPtr);
|
||||
|
||||
int32_t Phy_SetHopPattern(void *patternBuff, uint32_t patternLen);
|
||||
uint32_t Phy_GetHopLength(L1_FRAME_TYPE frameType);
|
||||
uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType);
|
||||
int32_t Phy_GetFreqEst(PHY_INST *instPtr);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, uint64_t tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
|
||||
int32_t Phy_AntConfigInit(PHY_ANT_COINFO *antCoinfoPtr);
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
int32_t Phy_SetTimeWord(PHY_INST *instPtr, const TIME_WORD *tmWord, PHY_TIME_WORD_TYPE tmType);
|
||||
|
||||
double Phy_GetCoarseFreqEst(PHY_INST *instPtr);
|
||||
void Phy_GetFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetLastReceivedFrameSyncTimeStamp(PHY_INST *instPtr, TIME_WORD *frameSyncT);
|
||||
void Phy_GetSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
void Phy_GetLastReceivedSlotStartTimeStamp(PHY_INST *instPtr, TIME_WORD *slotStart);
|
||||
#endif /* PHY_CTRL_H_ */
|
||||
|
||||
@@ -19,21 +19,17 @@
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef PHY_CTRLREG_H_
|
||||
#define PHY_CTRLREG_H_
|
||||
#ifndef PHY_REG_H_
|
||||
#define PHY_REG_H_
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "util.h"
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
|
||||
// Read Physical Layer register (0x00000000~0x000000FF)
|
||||
#define PhyRead(instPtr, addr) IO_In32(instPtr->phyCofig.baseAddr + addr)
|
||||
// Write Physical Layer register (0x000000100~0x00000200)
|
||||
#define PhyWrite(instPtr, addr, value) IO_Out32(instPtr->phyCofig.baseAddr + addr, value)
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/************************* Ps2Pl Regs PS Write Only ***************************/
|
||||
/**
|
||||
* Register: PHY_MAIN_CTRL
|
||||
*/
|
||||
@@ -57,11 +53,14 @@
|
||||
*/
|
||||
#define PHY_MODE_CTRL 0x00000004U
|
||||
#define PHY_MODE_CTRL_TOR_SHIFT 0
|
||||
#define PHY_MODE_CTRL_TOR_WIDTH 2
|
||||
#define PHY_MODE_CTRL_TOR_MASK 0x00000003U
|
||||
#define PHY_MODE_CTRL_FRAME_SHIFT 16
|
||||
#define PHY_MODE_CTRL_TOR_WIDTH 8
|
||||
#define PHY_MODE_CTRL_TOR_MASK 0x000000FFU
|
||||
#define PHY_MODE_CTRL_FRAME_SHIFT 8
|
||||
#define PHY_MODE_CTRL_FRAME_WIDTH 8
|
||||
#define PHY_MODE_CTRL_FRAME_MASK 0x00FF0000U
|
||||
#define PHY_MODE_CTRL_FRAME_MASK 0x0000FF00U
|
||||
#define PHY_MODE_CTRL_CRC_SHIFT 8
|
||||
#define PHY_MODE_CTRL_CRC_WIDTH 16
|
||||
#define PHY_MODE_CTRL_CRC_MASK 0x00FF0000U
|
||||
|
||||
#define PHY_MODE_CTRL_TOR_SUSPEND 0x00000000U
|
||||
#define PHY_MODE_CTRL_TOR_TX 0x00000001U
|
||||
@@ -77,6 +76,8 @@
|
||||
#define PHY_MODE_CTRL_FRAME_200KBPS_5MS 0x00000700U // 2-Way ACQ Frame, Management Frame, Service Frame
|
||||
#define PHY_MODE_CTRL_FRAME_1M2BPS_5MS 0x00000800U // Bistatic Synthetic Aperture Radar Frame
|
||||
|
||||
#define PHY_MODE_CTRL_CRC_EN 0x00010000U
|
||||
#define PHY_MODE_CTRL_CRC_DSBL 0x00000000U
|
||||
/**
|
||||
* Register: POLLTIME_L
|
||||
*/
|
||||
@@ -94,51 +95,43 @@
|
||||
#define POLLTIME_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: TM_ADJ_MODE
|
||||
* Register: TIMEOUT_L
|
||||
*/
|
||||
#define TM_ADJ_MODE 0x00000010U
|
||||
#define TM_ADJ_MODE_SHIFT 0
|
||||
#define TM_ADJ_MODE_WIDTH 8
|
||||
#define TM_ADJ_MODE_MASK 0x000000FFU
|
||||
#define TM_ADJ_MODE_NONE 0x00000000U
|
||||
#define TM_ADJ_MODE_ADD 0x00000001U
|
||||
#define TM_ADJ_MODE_SET 0x00000002U
|
||||
|
||||
#define TM_ADJ_MODE_LOCAL_SHIFT 8
|
||||
#define TM_ADJ_MODE_LOCAL_WIDTH 8
|
||||
#define TM_ADJ_MODE_LOCAL_MASK 0x0000FF00U
|
||||
#define TM_ADJ_MODE_LOCAL_NONE 0x00000000U
|
||||
#define TM_ADJ_MODE_LOCAL_ADD 0x00000100U
|
||||
#define TM_ADJ_MODE_LOCAL_SET 0x00000200U
|
||||
#define LISTENTIMEOUT_L 0x00000010U
|
||||
#define LISTENTIMEOUT_L_SHIFT 0
|
||||
#define LISTENTIMEOUT_L_WIDTH 32
|
||||
#define LISTENTIMEOUT_L_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: LOCALTM_ADJ_L
|
||||
* Register: TIMEOUT_H
|
||||
*/
|
||||
#define LOCALTM_ADJ_L 0x00000014U
|
||||
#define LOCALTM_ADJ_L_SHIFT 0
|
||||
#define LOCALTM_ADJ_L_WIDTH 32
|
||||
#define LOCALTM_ADJ_L_MASK 0xFFFFFFFFU
|
||||
#define LISTENTIMEOUT_H 0x00000014U
|
||||
#define LISTENTIMEOUT_H_SHIFT 0
|
||||
#define LISTENTIMEOUT_H_WIDTH 32
|
||||
#define LISTENTIMEOUT_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: LOCALTM_ADJ_H
|
||||
* Register: ANT_CTRL
|
||||
*/
|
||||
#define LOCALTM_ADJ_H 0x00000018U
|
||||
#define LOCALTM_ADJ_H_SHIFT 0
|
||||
#define LOCALTM_ADJ_H_WIDTH 32
|
||||
#define LOCALTM_ADJ_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: CNT_STEP_TOPT
|
||||
*/
|
||||
#define CNT_STEP_OPT 0x0000001CU
|
||||
#define CNT_STEP_OPT_SHIFT 0
|
||||
#define CNT_STEP_OPT_WIDTH 32
|
||||
#define CNT_STEP_OPT_MASK 0xFFFFFFFFU
|
||||
#define ANT_CONFIG 0x00000018U
|
||||
#define ANT_CONFIG_OFFSET_SHIFT 0
|
||||
#define ANT_CONFIG_OFFSET_WIDTH 16
|
||||
#define ANT_CONFIG_OFFSET_MASK 0x0000FFFFU
|
||||
#define ANT_CONFIG_LEN_SHIFT 16
|
||||
#define ANT_CONFIG_LEN_WIDTH 8
|
||||
#define ANT_CONFIG_LEN_MASK 0x00FF0000U
|
||||
#define ANT_CONFIG_NUM_SHIFT 24
|
||||
#define ANT_CONFIG_NUM_WIDTH 8
|
||||
#define ANT_CONFIG_NUM_MASK 0xFF000000U
|
||||
|
||||
/**
|
||||
* Register: SEND_DATA_CMD
|
||||
*/
|
||||
#define SEND_DATA_CMD 0x00000020U
|
||||
#define SEND_DATA_CMD 0x0000001CU
|
||||
#define SEND_DATA_CMD_SHIFT 0
|
||||
#define SEND_DATA_CMD_WIDTH 32
|
||||
#define SEND_DATA_CMD_MASK 0xFFFFFFFFU
|
||||
|
||||
#define SEND_DATA_CMD_LEN_SHIFT 0
|
||||
#define SEND_DATA_CMD_LEN_WIDTH 16
|
||||
#define SEND_DATA_CMD_LEN_MASK 0x0000FFFFU
|
||||
@@ -146,34 +139,19 @@
|
||||
#define SEND_DATA_CMD_OFFSET_WIDTH 16
|
||||
#define SEND_DATA_CMD_OFFSET_MASK 0xFFFF0000U
|
||||
|
||||
/**
|
||||
* Register: ANT_CONFIG_CMD
|
||||
*/
|
||||
#define ANT_CONFIG_CMD 0x00000024U
|
||||
#define ANT_CONFIG_CMD_OFFSET_SHIFT 0
|
||||
#define ANT_CONFIG_CMD_OFFSET_WIDTH 16
|
||||
#define ANT_CONFIG_CMD_OFFSET_MASK 0x0000FFFFU
|
||||
#define ANT_CONFIG_CMD_LEN_SHIFT 16
|
||||
#define ANT_CONFIG_CMD_LEN_WIDTH 8
|
||||
#define ANT_CONFIG_CMD_LEN_MASK 0x00FF0000U
|
||||
#define ANT_CONFIG_CMD_NUM_SHIFT 24
|
||||
#define ANT_CONFIG_CMD_NUM_WIDTH 8
|
||||
#define ANT_CONFIG_CMD_NUM_MASK 0xFF000000U
|
||||
|
||||
/**
|
||||
* Register: SLOT_CONFIG_CMD
|
||||
*/
|
||||
#define SLOT_CONFIG_CMD 0x00000028U
|
||||
#define SLOT_CONFIG_CMD_SHIFT 0
|
||||
#define SLOT_CONFIG_CMD_WIDTH 32
|
||||
#define SLOT_CONFIG_CMD_MASK 0xFFFFFFFFU
|
||||
#define SLOT_CONFIG_CMD_VAULE 0x4846414E
|
||||
#define SLOT_CMD 0x00000020U
|
||||
#define SLOT_CMD_SHIFT 0
|
||||
#define SLOT_CMD_WIDTH 32
|
||||
#define SLOT_CMD_MASK 0xFFFFFFFFU
|
||||
#define SLOT_CMD_KEY 0x434D442EU
|
||||
|
||||
/************************* Ps2Pl Regs PS Read Only ***************************/
|
||||
/**
|
||||
* Register: TXRX_STATE
|
||||
*/
|
||||
#define TXRX_STATE 0x00000100U
|
||||
#define TXRX_STATE 0x00000024U
|
||||
#define TXRX_STATE_ACQ_SHIFT 0
|
||||
#define TXRX_STATE_ACQ_WIDTH 8
|
||||
#define TXRX_STATE_ACQ_MASK 0x000000FFU
|
||||
@@ -192,21 +170,28 @@
|
||||
#define TXRX_STATE_DECODE_SUCCESS 0x00010000U
|
||||
#define TXRX_STATE_DECODE_FAIL 0x00020000U
|
||||
|
||||
#define TXRX_STATE_CRC_SHIFT 24
|
||||
#define TXRX_STATE_CRC_WIDTH 8
|
||||
#define TXRX_STATE_CRC_MASK 0xFF000000U
|
||||
#define TXRX_STATE_CRC_OK 0x01000000U
|
||||
#define TXRX_STATE_CRC_ERROR 0x02000000U
|
||||
|
||||
/**
|
||||
* Register: RECV_SATE
|
||||
* Register: RECVDATA_STATE
|
||||
*/
|
||||
#define RECV_DATA_SATE 0x00000104U
|
||||
#define RECV_DATA_LEN_SHIFT 0
|
||||
#define RECV_DATA_LEN_WIDTH 16
|
||||
#define RECV_DATA_LEN_MASK 0x0000FFFFU
|
||||
#define RECV_DATA_OFFSET_SHIFT 16
|
||||
#define RECV_DATA_OFFSET_WIDTH 16
|
||||
#define RECV_DATA_OFFSET_MASK 0xFFFFF0000U
|
||||
#define RECVDATA_STATE 0x00000028U
|
||||
#define RECVDATA_STATE_LEN_SHIFT 0
|
||||
#define RECVDATA_STATE_LEN_WIDTH 16
|
||||
#define RECVDATA_STATE_LEN_MASK 0x0000FFFFU
|
||||
|
||||
#define RECVDATA_STATE_OFFSET_SHIFT 16
|
||||
#define RECVDATA_STATE_OFFSET_WIDTH 16
|
||||
#define RECVDATA_STATE_OFFSET_MASK 0xFFFF0000U
|
||||
|
||||
/**
|
||||
* Register: FSTIME_L
|
||||
*/
|
||||
#define FSTIME_L 0x00000108U
|
||||
#define FSTIME_L 0x0000002CU
|
||||
#define FSTIME_L_SHIFT 0
|
||||
#define FSTIME_L_WIDTH 32
|
||||
#define FSTIME_L_MASK 0xFFFFFFFFU
|
||||
@@ -214,7 +199,7 @@
|
||||
/**
|
||||
* Register: FSTIME_INT1
|
||||
*/
|
||||
#define FSTIME_H 0x0000010CU
|
||||
#define FSTIME_H 0x00000030U
|
||||
#define FSTIME_H_SHIFT 0
|
||||
#define FSTIME_H_WIDTH 32
|
||||
#define FSTIME_H_MASK 0xFFFFFFFFU
|
||||
@@ -222,7 +207,7 @@
|
||||
/**
|
||||
* Register: TM_TARGET_L
|
||||
*/
|
||||
#define TM_TARGET_L 0x00000110U
|
||||
#define TM_TARGET_L 0x00000064U
|
||||
#define TM_TARGET_L_SHIFT 0
|
||||
#define TM_TARGET_L_WIDTH 32
|
||||
#define TM_TARGET_L_MASK 0xFFFFFFFFU
|
||||
@@ -230,44 +215,53 @@
|
||||
/**
|
||||
* Register: TM_TARGET_H
|
||||
*/
|
||||
#define TM_TARGET_H 0x00000114U
|
||||
#define TM_TARGET_H 0x00000038U
|
||||
#define TM_TARGET_H_SHIFT 0
|
||||
#define TM_TARGET_H_WIDTH 32
|
||||
#define TM_TARGET_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: LOCALTM_L
|
||||
*/
|
||||
#define TM_LOCAL_L 0x00000118U
|
||||
#define TM_LOCAL_L_SHIFT 0
|
||||
#define TM_LOCAL_L_WIDTH 32
|
||||
#define TM_LOCAL_L_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: LOCALTM_H
|
||||
*/
|
||||
#define TM_LOCAL_H 0x0000011CU
|
||||
#define TM_LOCAL_H_SHIFT 0
|
||||
#define TM_LOCAL_H_WIDTH 32
|
||||
#define TM_LOCAL_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: COASEFREQEST
|
||||
*/
|
||||
#define COASE_FREQEST 0x00000120U
|
||||
#define COASE_FREQEST_SHIFT 0
|
||||
#define COASE_FREQEST_WIDTH 32
|
||||
#define COASE_FREQEST_MASK 0xFFFFFFFFU
|
||||
#define COASE_FREQEST 0x0000003CU
|
||||
#define COASE_FREQEST_ACQ_SHIFT 0
|
||||
#define COASE_FREQEST_ACQ_WIDTH 8
|
||||
#define COASE_FREQEST_ACQ_MASK 0x000000FFU
|
||||
#define COASE_FREQEST_SYNC_SHIFT 8
|
||||
#define COASE_FREQEST_SYNC_WIDTH 8
|
||||
#define COASE_FREQEST_SYNC_MASK 0x000FF00U
|
||||
|
||||
/**
|
||||
* Register: INTR_TYPE
|
||||
* Register: FINE_FREQEST
|
||||
*/
|
||||
#define INTR_TYPE 0x00000124U
|
||||
#define FINE_FREQEST 0x00000040U
|
||||
#define FINE_FREQEST_SHIFT 0
|
||||
#define FINE_FREQEST_WIDTH 32
|
||||
#define FINE_FREQEST_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: BEAM_SELECT
|
||||
*/
|
||||
#define BEAM_SELECT_INDEX 0x00000044U
|
||||
#define BEAM_SELECT_INDEX_SHIFT 0
|
||||
#define BEAM_SELECT_INDEX_WIDTH 32
|
||||
#define BEAM_SELECT_INDEX_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: BEAM_AXIS
|
||||
*/
|
||||
#define BEAM_AXIS 0x00000044U
|
||||
#define BEAM_AXIS_EL_SHIFT 0
|
||||
#define BEAM_AXIS_EL_WIDTH 16
|
||||
#define BEAM_AXIS_EL_MASK 0x0000FFFFU
|
||||
#define BEAM_AXIS_AZ_SHIFT 16
|
||||
#define BEAM_AXIS_AZ_WIDTH 16
|
||||
#define BEAM_AXIS_AZ_MASK 0xFFFF0000U
|
||||
|
||||
/**
|
||||
* Register: ANT_STATUS_0
|
||||
*/
|
||||
#define ANT_STATUS 0x00000128U
|
||||
#define ANT_STATUS 0x00000100U
|
||||
#define ANT_STATUS_CODE_SHIFT 0
|
||||
#define ANT_STATUS_CODE_WIDTH 8
|
||||
#define ANT_STATUS_CODE_MASK 0x000000FFU
|
||||
@@ -284,7 +278,7 @@
|
||||
/**
|
||||
* Register: ANT_FRAME_CNT
|
||||
*/
|
||||
#define ANT_FRAME_CNT 0x0000012CU
|
||||
#define ANT_FRAME_CNT 0x00000104U
|
||||
#define ANT_FRAME_CNT_SHIFT 0
|
||||
#define ANT_FRAME_CNT_WIDTH 32
|
||||
#define ANT_FRAME_CNT_MASK 0xFFFFFFFFU
|
||||
@@ -292,7 +286,7 @@
|
||||
/**
|
||||
* Register: RF_STATUS
|
||||
*/
|
||||
#define RF_STATUS 0x00000130U
|
||||
#define RF_STATUS 0x00000108U
|
||||
#define RF_STATUS_TEMP_SHIFT 0
|
||||
#define RF_STATUS_TEMP_WIDTH 8
|
||||
#define RF_STATUS_TEMP_MASK 0x000000FFU
|
||||
@@ -309,7 +303,7 @@
|
||||
/**
|
||||
* Register: RF_MGC
|
||||
*/
|
||||
#define RF_MGC 0x00000134U
|
||||
#define RF_MGC 0x0000010CU
|
||||
#define RF_MGC_CH1_SHIFT 0
|
||||
#define RF_MGC_CH1_WIDTH 4
|
||||
#define RF_MGC_CH1_MASK 0x0000000FU
|
||||
@@ -326,9 +320,9 @@
|
||||
/**
|
||||
* Register: RF_FRAME_CNT
|
||||
*/
|
||||
#define RF_FRAME_CNT 0x00000138U
|
||||
#define RF_FRAME_CNT 0x00000110U
|
||||
#define RF_FRAME_CNT_SHIFT 0
|
||||
#define RF_FRAME_CNT_WIDTH 32
|
||||
#define RF_FRAME_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
#endif /* PHY_CTRLREG_H_ */
|
||||
#endif /* PHY_REG_H_ */
|
||||
|
||||
Reference in New Issue
Block a user