Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ba32bf8db | ||
|
|
fa2623130e | ||
|
|
6462daabdf | ||
|
|
85117688e1 | ||
|
|
347c0c1f74 | ||
|
|
831395d236 | ||
|
|
b9d7950b3a | ||
|
|
a24d8e8d35 | ||
|
|
3e7060965e |
+4
-1
@@ -54,4 +54,7 @@ dkms.conf
|
||||
|
||||
# MacOS .DS_Store file
|
||||
**/.DS_Store
|
||||
**/._.DS_Store
|
||||
**/._.DS_Store
|
||||
|
||||
# Ignore handout files
|
||||
handout/
|
||||
@@ -1,10 +1,14 @@
|
||||
DIR := $(shell pwd)
|
||||
|
||||
compile_test:
|
||||
cd $(DIR)/df_datalink_sp/bsp && make all
|
||||
cd $(DIR)/df_datalink_sp/build && make all
|
||||
cd $(DIR)/df_datalink_ge/bsp && make all
|
||||
cd $(DIR)/df_datalink_ge/build && make all
|
||||
|
||||
clean:
|
||||
cd $(DIR)/df_datalink_sp/bsp && make clean
|
||||
cd $(DIR)/df_datalink_sp/build && make clean
|
||||
cd $(DIR)/df_datalink_ge/bsp && make clean
|
||||
cd $(DIR)/df_datalink_ge/build && make clean
|
||||
.PHONY: clean compile_test
|
||||
@@ -39,7 +39,7 @@
|
||||
#define APP_EMULATE_DATA
|
||||
#define DATALINK_ENABLE_AUTORECONNECT
|
||||
#define DATALINK_ENABLE_AUTOTIMESYNC
|
||||
//#define DATALINK_ENABLE_BERTEST
|
||||
#define DATALINK_ENABLE_BERTEST 10
|
||||
|
||||
|
||||
/************ Hardware Configs ************/
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
#define DATALINK_ENABLE_AUTORECONNECT
|
||||
#define DATALINK_ENABLE_AUTOTIMESYNC
|
||||
// #define DATALINK_ENABLE_BERTEST
|
||||
#define DATALINK_ENABLE_BERTEST 10
|
||||
|
||||
/************ Hardware Configs ************/
|
||||
#define CPU_CLK_HZ XPAR_CPU_CORTEXA9_0_CPU_CLK_FREQ_HZ
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
/*********************** Driver Instance Definitions **************************/
|
||||
static struct hmc7044_dev *hmc7044_inst;
|
||||
static struct ad9361_reg_dev *ad9361_1_reg_inst;
|
||||
static struct ad9361_reg_dev *ad9361_2_reg_inst;
|
||||
static struct hmc7044_dev *hmc7044_inst = NULL;
|
||||
static struct ad9361_reg_dev *ad9361_1_reg_inst = NULL;
|
||||
static struct ad9361_reg_dev *ad9361_2_reg_inst = NULL;
|
||||
// static struct ad9361_rf_phy *ad9361_phy;
|
||||
// static struct ad9361_rf_phy *ad9361_2_phy;
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef HWCONFIG_H_
|
||||
#define HWCONFIG_H_
|
||||
/***************************** Include Files *********************************/
|
||||
// Standard
|
||||
#include <stdint.h>
|
||||
@@ -29,4 +30,4 @@ int8_t Hardware_GetAD9361Temp_2(void);
|
||||
uint8_t Hardware_GetAD9361LockStatus(void);
|
||||
uint8_t Hardware_GetHMC7044LockStatus(void);
|
||||
|
||||
|
||||
#endif // HWCONFIG_H_
|
||||
|
||||
+17
-17
@@ -72,20 +72,20 @@ struct callback_desc scutm_callback_desc = {
|
||||
|
||||
L2_CONFIG linkConfig = {
|
||||
.myType = L2_NODE_HEAD,
|
||||
.clustId = 1,
|
||||
.myId = 1,
|
||||
.headId = 1,
|
||||
.netScale = 2,
|
||||
.clustId = 1U,
|
||||
.myId = 1U,
|
||||
.headId = 1U,
|
||||
.netScale = 2U,
|
||||
.phyInstPtr = NULL, // physical layer reference
|
||||
.tmcInstPtr = NULL
|
||||
};
|
||||
|
||||
// L2_CONFIG linkConfig = {
|
||||
// .myType = L2_NODE_MEMBER,
|
||||
// .clustId = 1,
|
||||
// .myId = 2,
|
||||
// .headId = 1,
|
||||
// .netScale = 2,
|
||||
// .clustId = 1U,
|
||||
// .myId = 2U,
|
||||
// .headId = 1U,
|
||||
// .netScale = 2U,
|
||||
// .phyInstPtr = NULL, // physical layer reference
|
||||
// .tmcInstPtr = NULL
|
||||
// };
|
||||
@@ -106,21 +106,21 @@ static PHY_CONFIG phyConfig = {
|
||||
|
||||
TMC_CONFIG tmcConfig = {
|
||||
.baseAddr = TIME_CONTROLLER_BASEADDR,
|
||||
.reset = 10
|
||||
.reset = 10U
|
||||
};
|
||||
|
||||
static SYSBUS_CONFIG sysbusConfig = {
|
||||
.baseAddr = SYSBUS_BASE_ADDR,
|
||||
.txQueueMax = 16,
|
||||
.rxQueueMax = 16
|
||||
.txQueueMax = 16U,
|
||||
.rxQueueMax = 16U
|
||||
};
|
||||
/*********************** Driver Instance Definitions **************************/
|
||||
static struct irq_ctrl_desc *intcDescPtr; // General interrupt controller descriptor
|
||||
static struct timer_desc *logTmPtr;
|
||||
static SYSBUS *sysbusDescPtr;
|
||||
static PHY_INST *phyInstPtr;
|
||||
static struct irq_ctrl_desc *intcDescPtr = NULL; // General interrupt controller descriptor
|
||||
static struct timer_desc *logTmPtr = NULL;
|
||||
static SYSBUS *sysbusDescPtr = NULL;
|
||||
static PHY_INST *phyInstPtr = NULL;
|
||||
static TMC_INST *tmcInstPtr = NULL;
|
||||
L2_INST *linkInstPtr;
|
||||
L2_INST *linkInstPtr = NULL;
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
@@ -482,7 +482,7 @@ int main(void)
|
||||
DBG_PRINT("Physical started...\n");
|
||||
Phy_Start(phyInstPtr);
|
||||
|
||||
// Linklayer_Start(linkInstPtr);
|
||||
Linklayer_Start(linkInstPtr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -165,7 +165,7 @@ bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType)
|
||||
ASSERT(dataBuff != NULL);
|
||||
int32_t Status;
|
||||
uint32_t crcVal;
|
||||
crcVal = 0;
|
||||
crcVal = 0U;
|
||||
Status = L2_CrcGen(dataBuff, dataLen, crcType, &crcVal);
|
||||
if (Status == SUCCESS)
|
||||
{
|
||||
|
||||
@@ -75,6 +75,10 @@ COORD Coord_GetScalarMult(COORD a, double t)
|
||||
/** @brief Divides a coordinate vector by a real number. */
|
||||
void Coord_ScalarDiv(COORD *a, double t)
|
||||
{
|
||||
if (t == 0.0) {
|
||||
*a = COORD_NIL;
|
||||
return;
|
||||
}
|
||||
a->x /= t;
|
||||
a->y /= t;
|
||||
a->z /= t;
|
||||
@@ -83,6 +87,9 @@ void Coord_ScalarDiv(COORD *a, double t)
|
||||
/** @brief Divides a coordinate vector by a real number. */
|
||||
COORD Coord_GetScalarDiv(COORD a, double t)
|
||||
{
|
||||
if (t == 0.0) {
|
||||
return COORD_NIL;
|
||||
}
|
||||
COORD ret;
|
||||
ret.x = a.x / t;
|
||||
ret.y = a.y / t;
|
||||
|
||||
@@ -69,9 +69,9 @@ EULERANGLES EulerAngles_GetScalarMult(EULERANGLES e, double f)
|
||||
/** @brief Normalize EulerAngles. */
|
||||
void EulerAngles_Normalize(EULERANGLES *e)
|
||||
{
|
||||
e->alpha = fmod(e->alpha, 2 * EUL_PI);
|
||||
e->beta = fmod(e->beta, 2 * EUL_PI);
|
||||
e->gamma = fmod(e->gamma, 2 * EUL_PI);
|
||||
e->alpha = fmod(e->alpha, 2.0 * EUL_PI);
|
||||
e->beta = fmod(e->beta, 2.0 * EUL_PI);
|
||||
e->gamma = fmod(e->gamma, 2.0 * EUL_PI);
|
||||
}
|
||||
|
||||
/** @brief Normalize EulerAngles. */
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
|
||||
#define EUL_PI 3.14159265358979323846
|
||||
|
||||
#define DEG2RAD(d) ((EUL_PI / 180.0) * d)
|
||||
#define RAD2DEG(r) ((180.0 / EUL_PI) * r)
|
||||
#define DEG2RAD(d) ((EUL_PI / 180.0) * (d))
|
||||
#define RAD2DEG(r) ((180.0 / EUL_PI) * (r))
|
||||
|
||||
/**
|
||||
* Orientations are represented by 3D double precision Tait-Bryan (Euler) tuples
|
||||
|
||||
@@ -91,6 +91,10 @@ QUATERNION Quaternion_GetScalarMult(QUATERNION a, double t)
|
||||
/** @brief Divides a quaternion by a real number. */
|
||||
void Quaternion_ScalarDiv(QUATERNION *q, double t)
|
||||
{
|
||||
if (t == 0.0) {
|
||||
*q = QUATERNION_NIL;
|
||||
return;
|
||||
}
|
||||
q->s /= t;
|
||||
q->i /= t;
|
||||
q->j /= t;
|
||||
@@ -190,6 +194,9 @@ inline double Quaternion_GetRotationAngle(QUATERNION q)
|
||||
/** @brief Get axis of quaternion. */
|
||||
COORD Quaternion_GetRotationAxis(QUATERNION q)
|
||||
{
|
||||
if ((q.s > 1.0) || (q.s < -1.0)) {
|
||||
return COORD_NIL;
|
||||
}
|
||||
double sin_theta_inv;
|
||||
COORD ret;
|
||||
sin_theta_inv = 1.0 / sin(acos(q.s));
|
||||
@@ -202,6 +209,12 @@ COORD Quaternion_GetRotationAxis(QUATERNION q)
|
||||
/** @brief Get the axis and rotate angle of a unit Quaternion */
|
||||
void Quaternion_GetRotationAxisAndAngle(QUATERNION q, COORD *axis, double *angle)
|
||||
{
|
||||
if ((q.s > 1.0) || (q.s < -1.0)) {
|
||||
*axis = COORD_NIL;
|
||||
*angle = NAN;
|
||||
return;
|
||||
}
|
||||
|
||||
double sin_theta_inv;
|
||||
*angle = acos(q.s);
|
||||
|
||||
@@ -218,6 +231,11 @@ void Quaternion_GetRotationAxisAndAngle(QUATERNION q, COORD *axis, double *angle
|
||||
/** @brief Decompose the rotation on to 2 parts. */
|
||||
void Quaternion_GetSwingAndTwist(QUATERNION q, COORD axis, QUATERNION *swing, QUATERNION *twist)
|
||||
{
|
||||
if ((swing == NULL) || (twist == NULL))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double p;
|
||||
COORD v;
|
||||
v.x = q.i;
|
||||
@@ -326,7 +344,7 @@ EULERANGLES Quaternion_ToEulerAngles(QUATERNION q, EULERANGLES_TYPE type)
|
||||
if (mask1 || mask2)
|
||||
{
|
||||
ret.alpha = 0;
|
||||
ret.gamma = (asinValue > 0) ? (2.0 * atan2(q.i, q.s)) : (-2.0 * atan2(q.i, q.s));
|
||||
ret.gamma = (asinValue > 0.0) ? (2.0 * atan2(q.i, q.s)) : (-2.0 * atan2(q.i, q.s));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -339,6 +357,7 @@ EULERANGLES Quaternion_ToEulerAngles(QUATERNION q, EULERANGLES_TYPE type)
|
||||
|
||||
default:
|
||||
ret = EULERANGLES_NIL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -428,7 +447,7 @@ QUATERNION Quaternion_RotationFromTo(COORD from, COORD to)
|
||||
QUATERNION Quaternion_Lerp(QUATERNION q1, QUATERNION q2, double t)
|
||||
{
|
||||
QUATERNION ret;
|
||||
Quaternion_ScalarMult(&q1, 1 - t);
|
||||
Quaternion_ScalarMult(&q1, 1.0 - t);
|
||||
Quaternion_ScalarMult(&q1, t);
|
||||
ret = Quaternion_Add(q1, q2);
|
||||
Quaternion_Normalize(&ret);
|
||||
|
||||
@@ -56,13 +56,13 @@ QUATERNION Quaternion_Add(QUATERNION q1, QUATERNION q2);
|
||||
void Quaternion_ScalarMult(QUATERNION *q, double t);
|
||||
|
||||
/** @brief Multiplies a quaternion by a real number. */
|
||||
QUATERNION Quaternion_GetScalarMult(QUATERNION a, double t);
|
||||
QUATERNION Quaternion_GetScalarMult(QUATERNION q, double t);
|
||||
|
||||
/** @brief Divides a quaternion by a real number. */
|
||||
void Quaternion_ScalarDiv(QUATERNION *q, double t);
|
||||
|
||||
/** @brief Divides a quaternion by a real number. */
|
||||
QUATERNION Quaternion_GetScalarDiv(QUATERNION a, double t);
|
||||
QUATERNION Quaternion_GetScalarDiv(QUATERNION q, double t);
|
||||
|
||||
/** @brief Multiplies two quaternions. */
|
||||
QUATERNION Quaternion_Mult(QUATERNION q1, QUATERNION q2);
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
static void L2_RcdShift(L2_RCD *rcd, int32_t netxVal);
|
||||
static void L2_RcdShift(L2_RCD *rcd, uint32_t netxVal);
|
||||
static void UpdateMainSate(L2_INST *instPtr, L2_NODE_STATE newSate);
|
||||
static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum);
|
||||
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum);
|
||||
@@ -50,7 +50,7 @@ static void L2_FrameStateUpdate(L2_INST *instPtr);
|
||||
/**
|
||||
* @brief Shift L2 status record.(newval->next->curr->last)
|
||||
*/
|
||||
inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
|
||||
inline void L2_RcdShift(L2_RCD *rcd, uint32_t netxVal)
|
||||
{
|
||||
ASSERT(rcd != NULL);
|
||||
rcd->last = rcd->curr;
|
||||
@@ -132,6 +132,7 @@ static void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
bool isValid;
|
||||
L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr);
|
||||
isValid = false;
|
||||
// Update frame state.
|
||||
if (Phy_IsFrameValid(phyRef) == false)
|
||||
{
|
||||
@@ -162,7 +163,7 @@ static void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_SVC_PACK_LEN, L2_CRC16_1021);
|
||||
#else
|
||||
isValid = true;
|
||||
isValid = L2_Service_PktCheck(instPtr, instPtr->recvPktData);
|
||||
#endif
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
@@ -419,10 +420,14 @@ L1_FRAME_TYPE L2_L2frame2L1frame(L2_FRAME_TYPE l2Frame)
|
||||
case L2_SCAN_FRAME:
|
||||
return L1_10KBPS_10MS_FRAME;
|
||||
case L2_ADV_FRAME:
|
||||
return L1_10KBPS_20MS_FRAME;
|
||||
case L2_CFM_FRAME:
|
||||
return L1_10KBPS_20MS_FRAME;
|
||||
case L2_SVC_FRAME:
|
||||
#if DATALINK_ENABLE_BERTEST == 10
|
||||
return L1_10KBPS_20MS_FRAME;
|
||||
#else
|
||||
return L1_40KBPS_20MS_FRAME;
|
||||
#endif
|
||||
default:
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "../../system_monitor.h"
|
||||
/************************** Constant Definitions *****************************/
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#define AssertL2Event(instPtr, event) Linklayer_EventHandler(instPtr, event)
|
||||
#define AssertL2Event(instPtr, event) (Linklayer_EventHandler((instPtr), (event)))
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/**
|
||||
@@ -173,6 +173,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry)
|
||||
int32_t L2_Service_Init(L2_SVC_FSM **svcFSMPtr);
|
||||
void L2_Service_Reset(L2_SVC_FSM *svcFSMPtr);
|
||||
void L2_Service_Destroy(L2_SVC_FSM *svcFSMPtr);
|
||||
bool L2_Service_PktCheck(L2_INST *instPtr, uint8_t *msg);
|
||||
int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg);
|
||||
int32_t L2_Service_Proc(L2_INST *instPtr);
|
||||
int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *schedEntry);
|
||||
|
||||
@@ -145,7 +145,7 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
L2_EVENT_TYPE event; ///< event type
|
||||
void *msg; ///< event message
|
||||
void *msg; ///< event message (MUST be a heap item)
|
||||
} L2_EVENT;
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#define L2_PACK_LEN_MAX 512 // bytes
|
||||
|
||||
#define L2_ADV_PACK_LEN 28 // bytes
|
||||
#define L2_CMF_PACK_LEN 268 // bytes
|
||||
#define L2_CMF_PACK_LEN 28 // bytes
|
||||
#define L2_SVC_PACK_LEN 268 // bytes
|
||||
|
||||
// Common structure:
|
||||
@@ -81,17 +81,7 @@
|
||||
#define L2_MSG_CFM_SRC_POSY_LEN 4
|
||||
#define L2_MSG_CFM_SRC_POSZ 16
|
||||
#define L2_MSG_CFM_SRC_POSZ_LEN 4
|
||||
#define L2_MSG_CFM_SRC_SPEEDX 20
|
||||
#define L2_MSG_CFM_SRC_SPEEDX_LEN 4
|
||||
#define L2_MSG_CFM_SRC_SPEEDY 24
|
||||
#define L2_MSG_CFM_SRC_SPEEDY_LEN 4
|
||||
#define L2_MSG_CFM_SRC_SPEEDZ 28
|
||||
#define L2_MSG_CFM_SRC_SPEEDZ_LEN 4
|
||||
#define L2_MSG_CFM_PAYLOAD_ID 32
|
||||
#define L2_MSG_CFM_PAYLOAD_ID_LEN 4
|
||||
#define L2_MSG_CFM_PAYLOAD 36
|
||||
#define L2_MSG_CFM_PAYLOAD_LEN 230
|
||||
#define L2_MSG_CFM_CRC 266
|
||||
#define L2_MSG_CFM_CRC 26
|
||||
#define L2_MSG_CFM_CRC_LEN 2
|
||||
|
||||
// service payload structure:
|
||||
@@ -127,4 +117,4 @@
|
||||
|
||||
/** @} LinkLayer_MSG_Constants*/
|
||||
|
||||
/** @} LinkLayer*/
|
||||
/** @} LinkLayer*/
|
||||
|
||||
@@ -44,7 +44,7 @@ inline uint32_t L2_GetNodeListLen(NODE_LIST *list)
|
||||
/**************************** Type Definitions *******************************/
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
static NODE_ENTRY util_entry;
|
||||
static NODE_ENTRY util_entry = { 0 };
|
||||
/************************** Function Prototypes ******************************/
|
||||
/**
|
||||
* @brief helper function to free node entry.
|
||||
|
||||
@@ -182,7 +182,7 @@ static void PendCfmAck(L2_SCAN_FSM *scanFsmPtr)
|
||||
******************************************************************************/
|
||||
static void StageUpdate(L2_SCAN_FSM *scanFsmPtr, SCAN_STAGE newStage)
|
||||
{
|
||||
ASSERT(newStage >= L2_SCAN_NONE_STAGE && newStage <= L2_SCAN_CFM_STAGE);
|
||||
ASSERT((newStage >= L2_SCAN_NONE_STAGE) && (newStage <= L2_SCAN_CFM_STAGE));
|
||||
DBG_INFO("ScanNet current stage: %" PRIu8 " -> ScanNet new stage: %" PRIu8 " \n",
|
||||
scanFsmPtr->scanStage, newStage);
|
||||
scanFsmPtr->scanStage = newStage;
|
||||
@@ -270,10 +270,10 @@ static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
{
|
||||
// using pull mode to receive confirm frame
|
||||
// since first time sync procedure is accomplished in ADV stage.
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
|
||||
(void)Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
(void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
(void)Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
|
||||
scanFsmPtr->cfmTimeout++; // increase counter.
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
@@ -287,17 +287,17 @@ static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
if (scanFsmPtr->advTimeout > ADV_LISTEN_TIMEOUT)
|
||||
{
|
||||
/* Antenna steering (reserved, automatically accomplished by physical layer) */
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME);
|
||||
(void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME);
|
||||
DBG_WARNING("Adv timeout, restart net scan from L2_SCAN_INIT_STAGE.\n");
|
||||
L2_Scan_Reset(scanFsmPtr);
|
||||
(void)L2_Scan_Reset(scanFsmPtr);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Antenna steering (reserved, automatically accomplished by physical layer) */
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME);
|
||||
(void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME);
|
||||
scanFsmPtr->advTimeout++;
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
@@ -332,10 +332,10 @@ static int32_t Scan_CfmHandler(L2_INST *instPtr)
|
||||
{
|
||||
// using pull mode to receive confirm frame
|
||||
// since first time sync procedure is accomplished in ADV stage.
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
|
||||
(void)Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
|
||||
(void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
|
||||
(void)Phy_SetMode(phyRef, PHY_MODE_PULL);
|
||||
(void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
|
||||
scanFsmPtr->cfmTimeout++; // increase counter.
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
}
|
||||
@@ -359,7 +359,7 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
int32_t Status;
|
||||
uint32_t dataChunk;
|
||||
uint8_t *buff = instPtr->sendPktData;
|
||||
if (type < L2_ADV_FRAME || type > L2_CFM_FRAME)
|
||||
if ((type < L2_ADV_FRAME) || (type > L2_CFM_FRAME))
|
||||
{
|
||||
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
||||
return EPARAM;
|
||||
@@ -409,27 +409,6 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSX, L2_MSG_CFM_SRC_POSX_LEN, &(instPtr->sysInfo.posX));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSY, L2_MSG_CFM_SRC_POSY_LEN, &(instPtr->sysInfo.posY));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_POSZ, L2_MSG_CFM_SRC_POSZ_LEN, &(instPtr->sysInfo.posZ));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDX, L2_MSG_CFM_SRC_SPEEDX_LEN, &(instPtr->sysInfo.vX));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDY, L2_MSG_CFM_SRC_SPEEDY_LEN, &(instPtr->sysInfo.vY));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_SRC_SPEEDZ, L2_MSG_CFM_SRC_SPEEDZ_LEN, &(instPtr->sysInfo.vZ));
|
||||
|
||||
// Packing extra payload
|
||||
uint32_t dataId;
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_CFM_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_CFM_PAYLOAD, &dataId, PAYLOAD_LEN_LJ_TX);
|
||||
}
|
||||
|
||||
L2_FrameInsertChunk(buff, L2_MSG_CFM_PAYLOAD_ID, L2_MSG_CFM_PAYLOAD_ID_LEN, &dataId);
|
||||
if (dataId == DATA_ID_NONE)
|
||||
{
|
||||
memset(buff + L2_MSG_CFM_PAYLOAD, 0xAA, L2_MSG_CFM_PAYLOAD_LEN);
|
||||
}
|
||||
|
||||
// Append CRC
|
||||
Status = L2_CrcAppend(buff, L2_CMF_PACK_LEN - L2_MSG_CFM_CRC_LEN, L2_MSG_CFM_CRC, L2_CRC16_1021);
|
||||
if (Status != SUCCESS)
|
||||
@@ -437,10 +416,6 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
// Logging...
|
||||
memcpy(instPtr->log.txLog.data, buff, L2_CMF_PACK_LEN);
|
||||
instPtr->log.txLog.dataId = dataId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -564,13 +539,6 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
node->nodeInfo.pos.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_POSZ, L2_MSG_CFM_SRC_POSZ_LEN, &nodePos);
|
||||
node->nodeInfo.pos.z = (double)nodePos;
|
||||
float nodeSpeed;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDX, L2_MSG_CFM_SRC_SPEEDX_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.x = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDY, L2_MSG_CFM_SRC_SPEEDY_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.y = (double)nodePos;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_SRC_SPEEDZ, L2_MSG_CFM_SRC_SPEEDZ_LEN, &nodeSpeed);
|
||||
node->nodeInfo.speed.z = (double)nodePos;
|
||||
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
@@ -606,7 +574,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
};
|
||||
newRtneConfig.rtneTable = initTable;
|
||||
newRtneConfig.rtnePrd = ARRAY_SIZE(initTable);
|
||||
AssertL2Event(instPtr, &rtneUpEvent);
|
||||
(void)AssertL2Event(instPtr, &rtneUpEvent);
|
||||
}
|
||||
PendCfmAck(instPtr->scanFSM);
|
||||
// Time sync.
|
||||
@@ -622,27 +590,10 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
L2_NODE_STATE newState = L2_NORMAL_STATE;
|
||||
l2Event.event = L2_EV_MAIN_STATE_UPDATE;
|
||||
l2Event.msg = &newState;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
(void)AssertL2Event(instPtr, &l2Event);
|
||||
}
|
||||
}
|
||||
|
||||
// Get data payload
|
||||
uint32_t dataId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_CFM_PAYLOAD_ID, L2_MSG_CFM_PAYLOAD_ID_LEN, &dataId);
|
||||
|
||||
if (L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_CFM_PAYLOAD, dataId, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg + L2_MSG_CFM_PAYLOAD, dataId, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
|
||||
// Logging...
|
||||
memcpy(instPtr->log.rxLog.data, msg, L2_CMF_PACK_LEN);
|
||||
instPtr->log.rxLog.dataId = dataId;
|
||||
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
@@ -827,7 +778,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
|
||||
if (commNode != NULL)
|
||||
{
|
||||
Phy_SetBeamNo(phyRef, commNode->nodeInfo.beamNo, PHY_ANT_BEAM_16);
|
||||
(void)Phy_SetBeamNo(phyRef, commNode->nodeInfo.beamNo, PHY_ANT_BEAM_16);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -845,7 +796,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
torState = L2_TOR_SUSPEND;
|
||||
}
|
||||
// Setup antenna beam
|
||||
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_120);
|
||||
(void)Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_120);
|
||||
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_120;
|
||||
}
|
||||
|
||||
@@ -857,7 +808,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
DBG_ERROR("Only head node can send init-scan Frame.\n");
|
||||
return FAILURE;
|
||||
}
|
||||
L2_SetupNextSlot(instPtr, torState, L2_SCAN_FRAME);
|
||||
(void)L2_SetupNextSlot(instPtr, torState, L2_SCAN_FRAME);
|
||||
break;
|
||||
|
||||
case L2_SLOT_ADVERTISE:
|
||||
@@ -875,7 +826,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
}
|
||||
}
|
||||
/* Antenna setting (reserved.) */
|
||||
L2_SetupNextSlot(instPtr, torState, L2_ADV_FRAME);
|
||||
(void)L2_SetupNextSlot(instPtr, torState, L2_ADV_FRAME);
|
||||
break;
|
||||
|
||||
case L2_SLOT_CONFIRM:
|
||||
@@ -896,7 +847,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
}
|
||||
}
|
||||
/* Antenna setting (reserved.) */
|
||||
L2_SetupNextSlot(instPtr, torState, L2_CFM_FRAME);
|
||||
(void)L2_SetupNextSlot(instPtr, torState, L2_CFM_FRAME);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Cannot start a routine for slot type [%" PRId8 "] properly.\n", rtneEntry->slotType);
|
||||
|
||||
@@ -365,7 +365,7 @@ void L2_EventPoolHandler(L2_INST *instPtr)
|
||||
if (event->schdFrame == L2_GetCurrentFrameNum(instPtr) && event->schdSlot == L2_GetCurrentSlotNum(instPtr))
|
||||
{
|
||||
DBG_INFO("Asserting scheduled event [%" PRIu32 "].\n", event->eventId);
|
||||
AssertL2Event(instPtr, &(event->l2Event));
|
||||
(void)AssertL2Event(instPtr, &(event->l2Event));
|
||||
if (event->isVolatile == true)
|
||||
{
|
||||
DBG_INFO("Deleting scheduled event [%" PRIu32 "], since it is volatile.\n", event->eventId);
|
||||
|
||||
@@ -155,8 +155,9 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
}
|
||||
return SUCCESS;
|
||||
#else
|
||||
DBG_ERROR("Unexpected call of Service_Packing in BER test mode.\n");
|
||||
return EUNEXP;
|
||||
size_t packLen = Phy_GetFrameLen(L2_L2frame2L1frame(L2_SVC_FRAME));
|
||||
memcpy(instPtr->sendPktData, testData, packLen);
|
||||
return SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -260,33 +261,63 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
}
|
||||
return Status;
|
||||
#else
|
||||
NODE_ENTRY *node;
|
||||
uint8_t nodeId = (L2_GetNodeType(instPtr) == L2_NODE_HEAD) ? 0x02 : 0x01;
|
||||
node = L2_GetNodeById(instPtr->nodeList, nodeId);
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if (node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %" PRIu8 "]", nodeId);
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum = L2_GetCurrentFrameNum(instPtr);
|
||||
uint32_t slotNum = L2_GetCurrentSlotNum(instPtr);
|
||||
|
||||
// //NOTE: Service frame length is 20ms with 5ms idle
|
||||
// if(slotNum < 5)
|
||||
// {
|
||||
// slotNum = L2_SLOTS_PER_FRAME - 5;
|
||||
// frameNum = frameNum - 1;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// slotNum = slotNum / 5 * 5 - 5;
|
||||
// }
|
||||
// Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("Failed to compute time deviation.\n")
|
||||
// return Status;
|
||||
// }
|
||||
// // Implement a auto time sync.
|
||||
// if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
// {
|
||||
// // Time sync.
|
||||
// L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
// }
|
||||
return SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool L2_Service_PktCheck(L2_INST *instPtr, uint8_t *msg)
|
||||
{
|
||||
size_t packLen = Phy_GetFrameLen(L2_L2frame2L1frame(L2_SVC_FRAME)) & 0xFFFFFFFE;
|
||||
uint32_t errorBits = 0;
|
||||
for (int i = 0; i < L2_SVC_PACK_LEN; i++)
|
||||
for (int i = 0; i < packLen; i++)
|
||||
{
|
||||
errorBits += count_ones(msg[i] ^ testData[i]);
|
||||
}
|
||||
|
||||
instPtr->serviceFSM->bitError += errorBits;
|
||||
instPtr->serviceFSM->bitTotal += L2_SVC_PACK_LEN * 8;
|
||||
|
||||
// Calculate time deviation
|
||||
uint32_t frameNum, slotNum = 0;
|
||||
L2_FrameGetChunk(msg, L2_MSG_FRAME_NUM, L2_MSG_FRAME_NUM_LEN, &frameNum);
|
||||
L2_FrameGetChunk(msg, L2_MSG_SLOT_NUM, L2_MSG_SLOT_NUM_LEN, &slotNum);
|
||||
Status = L2_GetTimeDeviation(instPtr, frameNum, slotNum, true, &(instPtr->log.timeDev));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
return Status;
|
||||
}
|
||||
// Implement a auto time sync.
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
}
|
||||
return SUCCESS;
|
||||
#endif
|
||||
instPtr->serviceFSM->bitTotal += packLen * 8;
|
||||
return (errorBits == 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -406,12 +437,7 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
if (torState == L2_TOR_TX)
|
||||
{
|
||||
svcFSMPtr->txCnt++;
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
// Packing service data
|
||||
Service_Packing(instPtr, L2_SVC_FRAME, rtneEntry->dst);
|
||||
#else
|
||||
memcpy(instPtr->sendPktData, testData, L2_SVC_PACK_LEN);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -435,4 +461,4 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
}
|
||||
|
||||
/** @} LinkLayer_Service*/
|
||||
/** @} LinkLayer*/
|
||||
/** @} LinkLayer*/
|
||||
|
||||
@@ -69,20 +69,20 @@
|
||||
// Regex: (([0-9]+, ){8})
|
||||
const uint16_t freqTable[L1_FRAME_MAX_HOPS] =
|
||||
{
|
||||
1084, 1097, 1110, 1123, 1136, 1149, 1162, 1175,
|
||||
1188, 1201, 1214, 1227, 1240, 1253, 1266, 1279,
|
||||
1292, 1305, 1318, 1331, 1344, 1357, 1370, 1383,
|
||||
1396, 1409, 1422, 1435, 1448, 1461, 1474, 1487,
|
||||
1500, 1513, 1526, 1539, 1552, 1565, 1578, 1591,
|
||||
1604, 1617, 1630, 1643, 1656, 1669, 1682, 1695,
|
||||
1708, 1721, 1734, 1747, 1760, 1773, 1786, 1799,
|
||||
1812, 1825, 1838, 1851, 1864, 1877, 1890, 1903,
|
||||
1916, 1929, 1942, 1955, 1968, 1981, 1994, 2007,
|
||||
2020, 2033, 2046, 2059, 2072, 2085, 2098, 2111,
|
||||
2124
|
||||
1084U, 1097U, 1110U, 1123U, 1136U, 1149U, 1162U, 1175U,
|
||||
1188U, 1201U, 1214U, 1227U, 1240U, 1253U, 1266U, 1279U,
|
||||
1292U, 1305U, 1318U, 1331U, 1344U, 1357U, 1370U, 1383U,
|
||||
1396U, 1409U, 1422U, 1435U, 1448U, 1461U, 1474U, 1487U,
|
||||
1500U, 1513U, 1526U, 1539U, 1552U, 1565U, 1578U, 1591U,
|
||||
1604U, 1617U, 1630U, 1643U, 1656U, 1669U, 1682U, 1695U,
|
||||
1708U, 1721U, 1734U, 1747U, 1760U, 1773U, 1786U, 1799U,
|
||||
1812U, 1825U, 1838U, 1851U, 1864U, 1877U, 1890U, 1903U,
|
||||
1916U, 1929U, 1942U, 1955U, 1968U, 1981U, 1994U, 2007U,
|
||||
2020U, 2033U, 2046U, 2059U, 2072U, 2085U, 2098U, 2111U,
|
||||
2124U
|
||||
};
|
||||
|
||||
const uint16_t antCalTable[L1_FRAME_MAX_HOPS][L1_ANT_NUM_CH] =
|
||||
const int16_t antCalTable[L1_FRAME_MAX_HOPS][L1_ANT_NUM_CH] =
|
||||
//Antenna-JG01
|
||||
{
|
||||
{ 0, 2525, -7533, -6846}, { 0, 12726, -7818, -6860},
|
||||
@@ -135,55 +135,55 @@ const uint8_t hopPattern_2KBPS_20MS[L1_FRAME_2KBPS_20MS_HOPS] =
|
||||
|
||||
const uint8_t hopPattern_2KBPS_100MS[L1_FRAME_2KBPS_100MS_HOPS] =
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19, 20, 21, 22, 23,
|
||||
24, 25, 26, 27, 28, 29, 30, 31,
|
||||
32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47,
|
||||
48, 49, 50, 51, 52, 53, 54, 55,
|
||||
56, 57, 58, 59, 60, 61, 62, 63,
|
||||
64, 65, 66, 67, 68, 69, 70, 71,
|
||||
72, 73, 74, 75, 76, 77, 78, 79,
|
||||
80
|
||||
0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
|
||||
16U, 17U, 18U, 19U, 20U, 21U, 22U, 23U,
|
||||
24U, 25U, 26U, 27U, 28U, 29U, 30U, 31U,
|
||||
32U, 33U, 34U, 35U, 36U, 37U, 38U, 39U,
|
||||
40U, 41U, 42U, 43U, 44U, 45U, 46U, 47U,
|
||||
48U, 49U, 50U, 51U, 52U, 53U, 54U, 55U,
|
||||
56U, 57U, 58U, 59U, 60U, 61U, 62U, 63U,
|
||||
64U, 65U, 66U, 67U, 68U, 69U, 70U, 71U,
|
||||
72U, 73U, 74U, 75U, 76U, 77U, 78U, 79U,
|
||||
80U
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS] =
|
||||
{
|
||||
80
|
||||
80U
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS] =
|
||||
{
|
||||
80, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10
|
||||
80U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U, 9U, 10U
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] =
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8,
|
||||
0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U,
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] =
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18
|
||||
0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
|
||||
16U, 17U, 18U
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS] =
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19
|
||||
0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
|
||||
16U, 17U, 18U, 19U
|
||||
};
|
||||
|
||||
const uint8_t hopPattern_1M2BPS_5MS[L1_FRAME_1M2BPS_5MS_HOPS] =
|
||||
{
|
||||
0, 1, 2, 3, 4, 5, 6, 7,
|
||||
8, 9, 10, 11, 12, 13, 14, 15,
|
||||
16, 17, 18, 19
|
||||
0U, 1U, 2U, 3U, 4U, 5U, 6U, 7U,
|
||||
8U, 9U, 10U, 11U, 12U, 13U, 14U, 15U,
|
||||
16U, 17U, 18U, 19U
|
||||
};
|
||||
|
||||
/** @} PhysicalLayer_AntennaConfig_Constants*/
|
||||
@@ -317,7 +317,7 @@ void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset)
|
||||
* FAILURE beamNo exceeds the table size
|
||||
*
|
||||
******************************************************************************/
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, size_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
|
||||
@@ -406,8 +406,8 @@ int32_t Phy_SetBeamAngle(PHY_INST *instPtr, double offAx, double rndAx)
|
||||
ASSERT(instPtr != NULL);
|
||||
uint16_t offAxDeg = 0;
|
||||
uint16_t rndAxDeg = 0;
|
||||
offAxDeg = (offAx >= 0) ? (((int32_t)(offAx * 180 / ANT_PI)) % 360) : (((int32_t)(offAx * 180 / ANT_PI)) % 360 + 360);
|
||||
rndAxDeg = (rndAx >= 0) ? (((int32_t)(rndAx * 180 / ANT_PI)) % 360) : (((int32_t)(rndAx * 180 / ANT_PI)) % 360 + 360);
|
||||
offAxDeg = (offAx >= 0) ? (((int32_t)(offAx * 180.0 / ANT_PI)) % 360) : (((int32_t)(offAx * 180.0 / ANT_PI)) % 360 + 360);
|
||||
rndAxDeg = (rndAx >= 0) ? (((int32_t)(rndAx * 180.0 / ANT_PI)) % 360) : (((int32_t)(rndAx * 180.0 / ANT_PI)) % 360 + 360);
|
||||
if (offAxDeg > 60)
|
||||
{
|
||||
DBG_ERROR("Angle out of range, off axis angle: %" PRIu16 " (should be 0~60), round axis angle: %" PRIu16 " (should be 0~360).\n",
|
||||
|
||||
@@ -335,7 +335,7 @@ inline L1_FRAME_TYPE Phy_GetLastRecvFrameType(PHY_INST *instPtr)
|
||||
{
|
||||
return L1_NONE_FRAME;
|
||||
}
|
||||
int32_t frame_type = (PhyRead(instPtr, COASE_FREQEST) & COASE_TYPE_MASK);
|
||||
uint32_t frame_type = (PhyRead(instPtr, COASE_FREQEST) & COASE_TYPE_MASK);
|
||||
switch (frame_type)
|
||||
{
|
||||
case COASE_TYPE_2KBPS_20MS:
|
||||
@@ -1036,7 +1036,7 @@ void Phy_RefreshHwSate(PHY_INST *instPtr)
|
||||
ASSERT(instPtr != NULL);
|
||||
uint32_t rawData;
|
||||
#ifndef EMULATION
|
||||
float evalData;
|
||||
double evalData;
|
||||
instPtr->hwSate.isSpOk = true;
|
||||
// -- Update FPGA voltage status;
|
||||
instPtr->hwSate.spFpgaVolt = 0;
|
||||
@@ -1259,7 +1259,7 @@ double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
|
||||
double freqEst;
|
||||
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME)
|
||||
if ((frameType > L1_1M2BPS_5MS_FRAME) || (frameType <= L1_NONE_FRAME))
|
||||
{
|
||||
return INFINITY; // FIXME
|
||||
}
|
||||
@@ -1297,14 +1297,14 @@ double Phy_GetFineFreqEst(PHY_INST *instPtr)
|
||||
double freqEst;
|
||||
L1_FRAME_TYPE frameType;
|
||||
frameType = Phy_GetLastRecvFrameType(instPtr);
|
||||
if (frameType > L1_1M2BPS_5MS_FRAME || frameType <= L1_NONE_FRAME)
|
||||
if ((frameType > L1_1M2BPS_5MS_FRAME) || (frameType <= L1_NONE_FRAME))
|
||||
{
|
||||
return INFINITY; // FIXME
|
||||
}
|
||||
|
||||
regValue = PhyRead(instPtr, FINE_FREQEST);
|
||||
estAbs = regValue & FINE_FREQEST_VAL_MASK;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
if ((frameType >= L1_200KBPS_5MS_FRAME))
|
||||
{
|
||||
// 12M Rc
|
||||
freqEst = 48e6 / 2048 * ((double)estAbs) / 8192.0;
|
||||
|
||||
@@ -34,24 +34,24 @@
|
||||
* @name PhysicalLayer_Common_Constant
|
||||
* @{
|
||||
*/
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 37
|
||||
#define L1_INIT_BEAM_NO 0
|
||||
#define L1_NUM_ANT_NRRW_PATTERN 37U
|
||||
#define L1_INIT_BEAM_NO 0U
|
||||
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120
|
||||
#define L1_ANT_NUM_CH 4
|
||||
#define L1_ANT_NUM_CH 4U
|
||||
|
||||
#define L1_FRAME_NONE_LEN UINT32_MAX // byte
|
||||
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
|
||||
#define L1_FRAME_NONE_HOPS UINT32_MAX
|
||||
#define L1_FRAME_MAX_HOPS 81
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1
|
||||
#define L1_FRAME_2KBPS_100MS_HOPS 81
|
||||
#define L1_FRAME_10KBPS_10MS_HOPS 1
|
||||
#define L1_FRAME_10KBPS_20MS_HOPS 11
|
||||
#define L1_FRAME_40KBPS_20MS_HOPS 19
|
||||
#define L1_FRAME_40KBPS_10MS_HOPS 9
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
#define PHY_LOG_EXPIRE 40 // 50*5ms
|
||||
#define L1_FRAME_MAX_HOPS 81U
|
||||
#define L1_FRAME_2KBPS_20MS_HOPS 1U
|
||||
#define L1_FRAME_2KBPS_100MS_HOPS 81U
|
||||
#define L1_FRAME_10KBPS_10MS_HOPS 1U
|
||||
#define L1_FRAME_10KBPS_20MS_HOPS 11U
|
||||
#define L1_FRAME_40KBPS_20MS_HOPS 19U
|
||||
#define L1_FRAME_40KBPS_10MS_HOPS 9U
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20U
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20U
|
||||
#define PHY_LOG_EXPIRE 40U // 50*5ms
|
||||
/** @} */
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
@@ -306,7 +306,7 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
|
||||
void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset);
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, size_t beamNo, PHY_ANT_BEAM_WIDTH beamWidth);
|
||||
int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
|
||||
/** @} PhysicalLayer_AntennaControl*/
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
#include "util.h"
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
#define PhyRead(instPtr, addr) IO_In32((instPtr)->phyCofig.baseAddr + addr)
|
||||
#define PhyWrite(instPtr, addr, value) IO_Out32((instPtr)->phyCofig.baseAddr + addr, value)
|
||||
#define PhyRead(instPtr, addr) IO_In32((instPtr)->phyCofig.baseAddr + (addr))
|
||||
#define PhyWrite(instPtr, addr, value) IO_Out32((instPtr)->phyCofig.baseAddr + (addr), (value))
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/**
|
||||
|
||||
@@ -127,6 +127,7 @@ void SysMonitor_Destroy(void)
|
||||
*/
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
{
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = buffIndx;
|
||||
@@ -143,6 +144,7 @@ void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(info != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
@@ -201,9 +203,13 @@ void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
{
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
}
|
||||
else
|
||||
{
|
||||
buffIndx = GetReadable(sysMonitorInst->sendCtrl);
|
||||
}
|
||||
sysMonitorInst->sendCtrl.rBusy = buffIndx;
|
||||
if (sysMonitorInst->send[buffIndx].dataId != DATA_ID_NONE)
|
||||
{
|
||||
|
||||
@@ -54,12 +54,12 @@
|
||||
// #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
// #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
// #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
|
||||
#define IS_PS_VALID(x) (x <= 1.1 && x >= 0.9)
|
||||
#define IS_PSAUX_VALID(x) (x <= 2.0 && x >= 1.6)
|
||||
#define IS_DDR_VALID(x) (x <= 1.7 && x >= 1.3)
|
||||
#define IS_PL_VALID(x) (x <= 1.1 && x >= 0.9)
|
||||
#define IS_PLAUX_VALID(x) (x <= 2.0 && x >= 1.6)
|
||||
#define IS_BRAM_VALID(x) (x <= 1.1 && x >= 0.9)
|
||||
#define IS_PS_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PSAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_DDR_VALID(x) ((x) <= 1.7 && (x) >= 1.3)
|
||||
#define IS_PL_VALID(x) (x <= 1.1 && (x) >= 0.9)
|
||||
#define IS_PLAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
|
||||
#define IS_BRAM_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
|
||||
|
||||
#define CLK_SP_PLL0_LOCK BIT(0)
|
||||
#define CLK_SP_PLL1_LOCK BIT(2)
|
||||
@@ -194,12 +194,12 @@ typedef struct __attribute__((packed))
|
||||
uint8_t spFpgaVolt; ///< Signal processor voltage state indicator
|
||||
uint8_t spClkState; ///< Signal processor clock state indicator
|
||||
uint8_t spAdLockState; ///< Signal processor adc lock state indicator
|
||||
uint8_t spAdTemp_0; ///< Signal processor adc0 temperature
|
||||
uint8_t spAdTemp_1; ///< Signal processor adc1 temperature
|
||||
uint8_t spFpgaTemp; ///< Signal processor FPGA temperature
|
||||
int8_t spAdTemp_0; ///< Signal processor adc0 temperature
|
||||
int8_t spAdTemp_1; ///< Signal processor adc1 temperature
|
||||
int8_t spFpgaTemp; ///< Signal processor FPGA temperature
|
||||
// -- Antenna status
|
||||
uint8_t antVolt; ///< Antenna voltage state indicator
|
||||
uint8_t antTemp; ///< Antenna rf temperature
|
||||
int8_t antTemp; ///< Antenna rf temperature
|
||||
uint8_t antPll; ///< Antenna rf lock state indicator
|
||||
uint8_t antMgc0; ///< Antenna rf mgc0~1 indicator
|
||||
uint8_t antMgc1; ///< Antenna rf mgc2~3 indicator
|
||||
|
||||
@@ -4,9 +4,13 @@
|
||||
GE_TXATT=0
|
||||
GE_RXATT=25
|
||||
|
||||
DST_DIR=`pwd`
|
||||
DST_DIR="$(pwd)/handout"
|
||||
PROJECT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
echo ${DST_DIR}
|
||||
|
||||
mkdir -p ${DST_DIR}
|
||||
|
||||
echo "Creating <df_datalink_ge>..."
|
||||
cp -rL $PROJECT_DIR/df_datalink_ge/src $DST_DIR/df_datalink_ge
|
||||
sed -i'' -e "s/antConfig->rfTxMgc = 0;/antConfig->rfTxMgc = $GE_TXATT;/g" $DST_DIR/df_datalink_ge/networking/phy_layer/phy_antenna.c
|
||||
@@ -38,4 +42,4 @@ for key in ${!calMap[*]};do
|
||||
/\};/!b table
|
||||
s/=.*\};/=\n\/\/Antenna-$key\n${calMap[$key]}/
|
||||
}" $DST_DIR/$projName/networking/phy_layer/phy_antenna.c
|
||||
done
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user