misc update: make it more conform with GJB-8114

This commit is contained in:
Gatsby Van
2024-06-27 13:37:51 +08:00
parent fd9e7f54eb
commit 3e7060965e
20 changed files with 125 additions and 91 deletions
+3 -2
View File
@@ -13,7 +13,8 @@
* Copyright(c) 2024 Beijing Institute of Technology. * Copyright(c) 2024 Beijing Institute of Technology.
* *
******************************************************************************/ ******************************************************************************/
#ifndef HWCONFIG_H_
#define HWCONFIG_H_
/***************************** Include Files *********************************/ /***************************** Include Files *********************************/
// Standard // Standard
#include <stdint.h> #include <stdint.h>
@@ -29,4 +30,4 @@ int8_t Hardware_GetAD9361Temp_2(void);
uint8_t Hardware_GetAD9361LockStatus(void); uint8_t Hardware_GetAD9361LockStatus(void);
uint8_t Hardware_GetHMC7044LockStatus(void); uint8_t Hardware_GetHMC7044LockStatus(void);
#endif // HWCONFIG_H_
+16 -16
View File
@@ -72,20 +72,20 @@ struct callback_desc scutm_callback_desc = {
L2_CONFIG linkConfig = { L2_CONFIG linkConfig = {
.myType = L2_NODE_HEAD, .myType = L2_NODE_HEAD,
.clustId = 1, .clustId = 1U,
.myId = 1, .myId = 1U,
.headId = 1, .headId = 1U,
.netScale = 2, .netScale = 2U,
.phyInstPtr = NULL, // physical layer reference .phyInstPtr = NULL, // physical layer reference
.tmcInstPtr = NULL .tmcInstPtr = NULL
}; };
// L2_CONFIG linkConfig = { // L2_CONFIG linkConfig = {
// .myType = L2_NODE_MEMBER, // .myType = L2_NODE_MEMBER,
// .clustId = 1, // .clustId = 1U,
// .myId = 2, // .myId = 2U,
// .headId = 1, // .headId = 1U,
// .netScale = 2, // .netScale = 2U,
// .phyInstPtr = NULL, // physical layer reference // .phyInstPtr = NULL, // physical layer reference
// .tmcInstPtr = NULL // .tmcInstPtr = NULL
// }; // };
@@ -106,21 +106,21 @@ static PHY_CONFIG phyConfig = {
TMC_CONFIG tmcConfig = { TMC_CONFIG tmcConfig = {
.baseAddr = TIME_CONTROLLER_BASEADDR, .baseAddr = TIME_CONTROLLER_BASEADDR,
.reset = 10 .reset = 10U
}; };
static SYSBUS_CONFIG sysbusConfig = { static SYSBUS_CONFIG sysbusConfig = {
.baseAddr = SYSBUS_BASE_ADDR, .baseAddr = SYSBUS_BASE_ADDR,
.txQueueMax = 16, .txQueueMax = 16U,
.rxQueueMax = 16 .rxQueueMax = 16U
}; };
/*********************** Driver Instance Definitions **************************/ /*********************** Driver Instance Definitions **************************/
static struct irq_ctrl_desc *intcDescPtr; // General interrupt controller descriptor static struct irq_ctrl_desc *intcDescPtr = NULL; // General interrupt controller descriptor
static struct timer_desc *logTmPtr; static struct timer_desc *logTmPtr = NULL;
static SYSBUS *sysbusDescPtr; static SYSBUS *sysbusDescPtr = NULL;
static PHY_INST *phyInstPtr; static PHY_INST *phyInstPtr = NULL;
static TMC_INST *tmcInstPtr = NULL; static TMC_INST *tmcInstPtr = NULL;
L2_INST *linkInstPtr; L2_INST *linkInstPtr = NULL;
/****************************************************************************/ /****************************************************************************/
@@ -165,7 +165,7 @@ bool L2_CrcCheck(uint8_t *dataBuff, uint32_t dataLen, L2_CRC_TYPE crcType)
ASSERT(dataBuff != NULL); ASSERT(dataBuff != NULL);
int32_t Status; int32_t Status;
uint32_t crcVal; uint32_t crcVal;
crcVal = 0; crcVal = 0U;
Status = L2_CrcGen(dataBuff, dataLen, crcType, &crcVal); Status = L2_CrcGen(dataBuff, dataLen, crcType, &crcVal);
if (Status == SUCCESS) if (Status == SUCCESS)
{ {
@@ -75,6 +75,10 @@ COORD Coord_GetScalarMult(COORD a, double t)
/** @brief Divides a coordinate vector by a real number. */ /** @brief Divides a coordinate vector by a real number. */
void Coord_ScalarDiv(COORD *a, double t) void Coord_ScalarDiv(COORD *a, double t)
{ {
if (t == 0.0) {
*a = COORD_NIL;
return;
}
a->x /= t; a->x /= t;
a->y /= t; a->y /= t;
a->z /= t; a->z /= t;
@@ -83,6 +87,9 @@ void Coord_ScalarDiv(COORD *a, double t)
/** @brief Divides a coordinate vector by a real number. */ /** @brief Divides a coordinate vector by a real number. */
COORD Coord_GetScalarDiv(COORD a, double t) COORD Coord_GetScalarDiv(COORD a, double t)
{ {
if (t == 0.0) {
return COORD_NIL;
}
COORD ret; COORD ret;
ret.x = a.x / t; ret.x = a.x / t;
ret.y = a.y / t; ret.y = a.y / t;
@@ -69,9 +69,9 @@ EULERANGLES EulerAngles_GetScalarMult(EULERANGLES e, double f)
/** @brief Normalize EulerAngles. */ /** @brief Normalize EulerAngles. */
void EulerAngles_Normalize(EULERANGLES *e) void EulerAngles_Normalize(EULERANGLES *e)
{ {
e->alpha = fmod(e->alpha, 2 * EUL_PI); e->alpha = fmod(e->alpha, 2.0 * EUL_PI);
e->beta = fmod(e->beta, 2 * EUL_PI); e->beta = fmod(e->beta, 2.0 * EUL_PI);
e->gamma = fmod(e->gamma, 2 * EUL_PI); e->gamma = fmod(e->gamma, 2.0 * EUL_PI);
} }
/** @brief Normalize EulerAngles. */ /** @brief Normalize EulerAngles. */
@@ -30,8 +30,8 @@
#define EUL_PI 3.14159265358979323846 #define EUL_PI 3.14159265358979323846
#define DEG2RAD(d) ((EUL_PI / 180.0) * d) #define DEG2RAD(d) ((EUL_PI / 180.0) * (d))
#define RAD2DEG(r) ((180.0 / EUL_PI) * r) #define RAD2DEG(r) ((180.0 / EUL_PI) * (r))
/** /**
* Orientations are represented by 3D double precision Tait-Bryan (Euler) tuples * 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. */ /** @brief Divides a quaternion by a real number. */
void Quaternion_ScalarDiv(QUATERNION *q, double t) void Quaternion_ScalarDiv(QUATERNION *q, double t)
{ {
if (t == 0.0) {
*q = QUATERNION_NIL;
return;
}
q->s /= t; q->s /= t;
q->i /= t; q->i /= t;
q->j /= t; q->j /= t;
@@ -190,6 +194,9 @@ inline double Quaternion_GetRotationAngle(QUATERNION q)
/** @brief Get axis of quaternion. */ /** @brief Get axis of quaternion. */
COORD Quaternion_GetRotationAxis(QUATERNION q) COORD Quaternion_GetRotationAxis(QUATERNION q)
{ {
if ((q.s > 1.0) || (q.s < -1.0)) {
return COORD_NIL;
}
double sin_theta_inv; double sin_theta_inv;
COORD ret; COORD ret;
sin_theta_inv = 1.0 / sin(acos(q.s)); 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 */ /** @brief Get the axis and rotate angle of a unit Quaternion */
void Quaternion_GetRotationAxisAndAngle(QUATERNION q, COORD *axis, double *angle) 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; double sin_theta_inv;
*angle = acos(q.s); *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. */ /** @brief Decompose the rotation on to 2 parts. */
void Quaternion_GetSwingAndTwist(QUATERNION q, COORD axis, QUATERNION *swing, QUATERNION *twist) void Quaternion_GetSwingAndTwist(QUATERNION q, COORD axis, QUATERNION *swing, QUATERNION *twist)
{ {
if ((swing == NULL) || (twist == NULL))
{
return;
}
double p; double p;
COORD v; COORD v;
v.x = q.i; v.x = q.i;
@@ -326,7 +344,7 @@ EULERANGLES Quaternion_ToEulerAngles(QUATERNION q, EULERANGLES_TYPE type)
if (mask1 || mask2) if (mask1 || mask2)
{ {
ret.alpha = 0; 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 else
{ {
@@ -339,6 +357,7 @@ EULERANGLES Quaternion_ToEulerAngles(QUATERNION q, EULERANGLES_TYPE type)
default: default:
ret = EULERANGLES_NIL; ret = EULERANGLES_NIL;
break;
} }
return ret; return ret;
} }
@@ -428,7 +447,7 @@ QUATERNION Quaternion_RotationFromTo(COORD from, COORD to)
QUATERNION Quaternion_Lerp(QUATERNION q1, QUATERNION q2, double t) QUATERNION Quaternion_Lerp(QUATERNION q1, QUATERNION q2, double t)
{ {
QUATERNION ret; QUATERNION ret;
Quaternion_ScalarMult(&q1, 1 - t); Quaternion_ScalarMult(&q1, 1.0 - t);
Quaternion_ScalarMult(&q1, t); Quaternion_ScalarMult(&q1, t);
ret = Quaternion_Add(q1, q2); ret = Quaternion_Add(q1, q2);
Quaternion_Normalize(&ret); Quaternion_Normalize(&ret);
@@ -56,13 +56,13 @@ QUATERNION Quaternion_Add(QUATERNION q1, QUATERNION q2);
void Quaternion_ScalarMult(QUATERNION *q, double t); void Quaternion_ScalarMult(QUATERNION *q, double t);
/** @brief Multiplies a quaternion by a real number. */ /** @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. */ /** @brief Divides a quaternion by a real number. */
void Quaternion_ScalarDiv(QUATERNION *q, double t); void Quaternion_ScalarDiv(QUATERNION *q, double t);
/** @brief Divides a quaternion by a real number. */ /** @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. */ /** @brief Multiplies two quaternions. */
QUATERNION Quaternion_Mult(QUATERNION q1, QUATERNION q2); QUATERNION Quaternion_Mult(QUATERNION q1, QUATERNION q2);
@@ -39,7 +39,7 @@
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/************************** Function Prototypes ******************************/ /************************** 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 UpdateMainSate(L2_INST *instPtr, L2_NODE_STATE newSate);
static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum); static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum);
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum); 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) * @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); ASSERT(rcd != NULL);
rcd->last = rcd->curr; rcd->last = rcd->curr;
@@ -132,6 +132,7 @@ static void L2_FrameStateUpdate(L2_INST *instPtr)
PHY_INST *phyRef = instPtr->config.phyInstPtr; PHY_INST *phyRef = instPtr->config.phyInstPtr;
bool isValid; bool isValid;
L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr); L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr);
isValid = false;
// Update frame state. // Update frame state.
if (Phy_IsFrameValid(phyRef) == false) if (Phy_IsFrameValid(phyRef) == false)
{ {
@@ -29,7 +29,7 @@
#include "../../system_monitor.h" #include "../../system_monitor.h"
/************************** Constant Definitions *****************************/ /************************** Constant Definitions *****************************/
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
#define AssertL2Event(instPtr, event) Linklayer_EventHandler(instPtr, event) #define AssertL2Event(instPtr, event) (Linklayer_EventHandler((instPtr), (event)))
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/** /**
@@ -145,7 +145,7 @@ typedef enum
typedef struct typedef struct
{ {
L2_EVENT_TYPE event; ///< event type L2_EVENT_TYPE event; ///< event type
void *msg; ///< event message void *msg; ///< event message (MUST be a heap item)
} L2_EVENT; } L2_EVENT;
/** /**
@@ -44,7 +44,7 @@ inline uint32_t L2_GetNodeListLen(NODE_LIST *list)
/**************************** Type Definitions *******************************/ /**************************** Type Definitions *******************************/
/************************** Variable Definitions *****************************/ /************************** Variable Definitions *****************************/
static NODE_ENTRY util_entry; static NODE_ENTRY util_entry = { 0 };
/************************** Function Prototypes ******************************/ /************************** Function Prototypes ******************************/
/** /**
* @brief helper function to free node entry. * @brief helper function to free node entry.
+22 -22
View File
@@ -182,7 +182,7 @@ static void PendCfmAck(L2_SCAN_FSM *scanFsmPtr)
******************************************************************************/ ******************************************************************************/
static void StageUpdate(L2_SCAN_FSM *scanFsmPtr, SCAN_STAGE newStage) 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", DBG_INFO("ScanNet current stage: %" PRIu8 " -> ScanNet new stage: %" PRIu8 " \n",
scanFsmPtr->scanStage, newStage); scanFsmPtr->scanStage, newStage);
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 // using pull mode to receive confirm frame
// since first time sync procedure is accomplished in ADV stage. // since first time sync procedure is accomplished in ADV stage.
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16); (void)Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16); (void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
Phy_SetMode(phyRef, PHY_MODE_PULL); (void)Phy_SetMode(phyRef, PHY_MODE_PULL);
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME); (void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
scanFsmPtr->cfmTimeout++; // increase counter. scanFsmPtr->cfmTimeout++; // increase counter.
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16; 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) if (scanFsmPtr->advTimeout > ADV_LISTEN_TIMEOUT)
{ {
/* Antenna steering (reserved, automatically accomplished by physical layer) */ /* Antenna steering (reserved, automatically accomplished by physical layer) */
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16); (void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME); (void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_SCAN_FRAME);
DBG_WARNING("Adv timeout, restart net scan from L2_SCAN_INIT_STAGE.\n"); 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; instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
} }
else else
{ {
/* Antenna steering (reserved, automatically accomplished by physical layer) */ /* Antenna steering (reserved, automatically accomplished by physical layer) */
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16); (void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME); (void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_ADV_FRAME);
scanFsmPtr->advTimeout++; scanFsmPtr->advTimeout++;
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16; 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 // using pull mode to receive confirm frame
// since first time sync procedure is accomplished in ADV stage. // since first time sync procedure is accomplished in ADV stage.
Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16); (void)Phy_SetBeamWidth(phyRef, PHY_ANT_BEAM_16);
Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16); (void)Phy_SetBeamNo(phyRef, scanFsmPtr->beamNo, PHY_ANT_BEAM_16);
Phy_SetMode(phyRef, PHY_MODE_PULL); (void)Phy_SetMode(phyRef, PHY_MODE_PULL);
L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME); (void)L2_SetupNextSlot(instPtr, L2_TOR_RX, L2_CFM_FRAME);
scanFsmPtr->cfmTimeout++; // increase counter. scanFsmPtr->cfmTimeout++; // increase counter.
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16; 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; int32_t Status;
uint32_t dataChunk; uint32_t dataChunk;
uint8_t *buff = instPtr->sendPktData; 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); DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
return EPARAM; return EPARAM;
@@ -606,7 +606,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
}; };
newRtneConfig.rtneTable = initTable; newRtneConfig.rtneTable = initTable;
newRtneConfig.rtnePrd = ARRAY_SIZE(initTable); newRtneConfig.rtnePrd = ARRAY_SIZE(initTable);
AssertL2Event(instPtr, &rtneUpEvent); (void)AssertL2Event(instPtr, &rtneUpEvent);
} }
PendCfmAck(instPtr->scanFSM); PendCfmAck(instPtr->scanFSM);
// Time sync. // Time sync.
@@ -622,7 +622,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
L2_NODE_STATE newState = L2_NORMAL_STATE; L2_NODE_STATE newState = L2_NORMAL_STATE;
l2Event.event = L2_EV_MAIN_STATE_UPDATE; l2Event.event = L2_EV_MAIN_STATE_UPDATE;
l2Event.msg = &newState; l2Event.msg = &newState;
AssertL2Event(instPtr, &l2Event); (void)AssertL2Event(instPtr, &l2Event);
} }
} }
@@ -827,7 +827,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16; instPtr->log.lastBeamWidth = PHY_ANT_BEAM_16;
if (commNode != NULL) 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 else
@@ -845,7 +845,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
torState = L2_TOR_SUSPEND; torState = L2_TOR_SUSPEND;
} }
// Setup antenna beam // 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; instPtr->log.lastBeamWidth = PHY_ANT_BEAM_120;
} }
@@ -857,7 +857,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"); DBG_ERROR("Only head node can send init-scan Frame.\n");
return FAILURE; return FAILURE;
} }
L2_SetupNextSlot(instPtr, torState, L2_SCAN_FRAME); (void)L2_SetupNextSlot(instPtr, torState, L2_SCAN_FRAME);
break; break;
case L2_SLOT_ADVERTISE: case L2_SLOT_ADVERTISE:
@@ -875,7 +875,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
} }
} }
/* Antenna setting (reserved.) */ /* Antenna setting (reserved.) */
L2_SetupNextSlot(instPtr, torState, L2_ADV_FRAME); (void)L2_SetupNextSlot(instPtr, torState, L2_ADV_FRAME);
break; break;
case L2_SLOT_CONFIRM: case L2_SLOT_CONFIRM:
@@ -896,7 +896,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
} }
} }
/* Antenna setting (reserved.) */ /* Antenna setting (reserved.) */
L2_SetupNextSlot(instPtr, torState, L2_CFM_FRAME); (void)L2_SetupNextSlot(instPtr, torState, L2_CFM_FRAME);
break; break;
default: default:
DBG_ERROR("Cannot start a routine for slot type [%" PRId8 "] properly.\n", rtneEntry->slotType); 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)) if (event->schdFrame == L2_GetCurrentFrameNum(instPtr) && event->schdSlot == L2_GetCurrentSlotNum(instPtr))
{ {
DBG_INFO("Asserting scheduled event [%" PRIu32 "].\n", event->eventId); DBG_INFO("Asserting scheduled event [%" PRIu32 "].\n", event->eventId);
AssertL2Event(instPtr, &(event->l2Event)); (void)AssertL2Event(instPtr, &(event->l2Event));
if (event->isVolatile == true) if (event->isVolatile == true)
{ {
DBG_INFO("Deleting scheduled event [%" PRIu32 "], since it is volatile.\n", event->eventId); DBG_INFO("Deleting scheduled event [%" PRIu32 "], since it is volatile.\n", event->eventId);
@@ -82,7 +82,7 @@ const uint16_t freqTable[L1_FRAME_MAX_HOPS] =
2124 2124
}; };
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 //Antenna-JG01
{ {
{ 0, 2525, -7533, -6846}, { 0, 12726, -7818, -6860}, { 0, 2525, -7533, -6846}, { 0, 12726, -7818, -6860},
@@ -317,7 +317,7 @@ void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset)
* FAILURE beamNo exceeds the table size * 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); ASSERT(instPtr != NULL);
@@ -406,8 +406,8 @@ int32_t Phy_SetBeamAngle(PHY_INST *instPtr, double offAx, double rndAx)
ASSERT(instPtr != NULL); ASSERT(instPtr != NULL);
uint16_t offAxDeg = 0; uint16_t offAxDeg = 0;
uint16_t rndAxDeg = 0; uint16_t rndAxDeg = 0;
offAxDeg = (offAx >= 0) ? (((int32_t)(offAx * 180 / ANT_PI)) % 360) : (((int32_t)(offAx * 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 / ANT_PI)) % 360) : (((int32_t)(rndAx * 180 / 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) 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", 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; 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) switch (frame_type)
{ {
case COASE_TYPE_2KBPS_20MS: case COASE_TYPE_2KBPS_20MS:
@@ -1036,7 +1036,7 @@ void Phy_RefreshHwSate(PHY_INST *instPtr)
ASSERT(instPtr != NULL); ASSERT(instPtr != NULL);
uint32_t rawData; uint32_t rawData;
#ifndef EMULATION #ifndef EMULATION
float evalData; double evalData;
instPtr->hwSate.isSpOk = true; instPtr->hwSate.isSpOk = true;
// -- Update FPGA voltage status; // -- Update FPGA voltage status;
instPtr->hwSate.spFpgaVolt = 0; instPtr->hwSate.spFpgaVolt = 0;
@@ -1259,7 +1259,7 @@ double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
double freqEst; double freqEst;
frameType = Phy_GetLastRecvFrameType(instPtr); 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 return INFINITY; // FIXME
} }
@@ -1297,14 +1297,14 @@ double Phy_GetFineFreqEst(PHY_INST *instPtr)
double freqEst; double freqEst;
L1_FRAME_TYPE frameType; L1_FRAME_TYPE frameType;
frameType = Phy_GetLastRecvFrameType(instPtr); 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 return INFINITY; // FIXME
} }
regValue = PhyRead(instPtr, FINE_FREQEST); regValue = PhyRead(instPtr, FINE_FREQEST);
estAbs = regValue & FINE_FREQEST_VAL_MASK; estAbs = regValue & FINE_FREQEST_VAL_MASK;
if (frameType >= L1_200KBPS_5MS_FRAME) if ((frameType >= L1_200KBPS_5MS_FRAME))
{ {
// 12M Rc // 12M Rc
freqEst = 48e6 / 2048 * ((double)estAbs) / 8192.0; freqEst = 48e6 / 2048 * ((double)estAbs) / 8192.0;
@@ -34,24 +34,24 @@
* @name PhysicalLayer_Common_Constant * @name PhysicalLayer_Common_Constant
* @{ * @{
*/ */
#define L1_NUM_ANT_NRRW_PATTERN 37 #define L1_NUM_ANT_NRRW_PATTERN 37U
#define L1_INIT_BEAM_NO 0 #define L1_INIT_BEAM_NO 0U
#define L1_INIT_ANT_WD PHY_ANT_BEAM_120 #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_LEN UINT32_MAX // byte
#define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L) #define L1_FRAME_NONE_COMP UINT32_MAX // *10ns(Timer_L)
#define L1_FRAME_NONE_HOPS UINT32_MAX #define L1_FRAME_NONE_HOPS UINT32_MAX
#define L1_FRAME_MAX_HOPS 81 #define L1_FRAME_MAX_HOPS 81U
#define L1_FRAME_2KBPS_20MS_HOPS 1 #define L1_FRAME_2KBPS_20MS_HOPS 1U
#define L1_FRAME_2KBPS_100MS_HOPS 81 #define L1_FRAME_2KBPS_100MS_HOPS 81U
#define L1_FRAME_10KBPS_10MS_HOPS 1 #define L1_FRAME_10KBPS_10MS_HOPS 1U
#define L1_FRAME_10KBPS_20MS_HOPS 11 #define L1_FRAME_10KBPS_20MS_HOPS 11U
#define L1_FRAME_40KBPS_20MS_HOPS 19 #define L1_FRAME_40KBPS_20MS_HOPS 19U
#define L1_FRAME_40KBPS_10MS_HOPS 9 #define L1_FRAME_40KBPS_10MS_HOPS 9U
#define L1_FRAME_200KBPS_5MS_HOPS 20 #define L1_FRAME_200KBPS_5MS_HOPS 20U
#define L1_FRAME_1M2BPS_5MS_HOPS 20 #define L1_FRAME_1M2BPS_5MS_HOPS 20U
#define PHY_LOG_EXPIRE 40 // 50*5ms #define PHY_LOG_EXPIRE 40U // 50*5ms
/** @} */ /** @} */
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
/**************************** Type 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_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
void Phy_SetBeamTable(PHY_INST *instPtr, PHY_ANT_ANGLE *table, uint32_t offset); 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_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); int32_t Phy_SetBeamAngle(PHY_INST *phyInstPtr, double offAx, double rndAx);
/** @} PhysicalLayer_AntennaControl*/ /** @} PhysicalLayer_AntennaControl*/
@@ -26,8 +26,8 @@
#include "util.h" #include "util.h"
/***************** Macros (Inline Functions) Definitions *********************/ /***************** Macros (Inline Functions) Definitions *********************/
#define PhyRead(instPtr, addr) IO_In32((instPtr)->phyCofig.baseAddr + addr) #define PhyRead(instPtr, addr) IO_In32((instPtr)->phyCofig.baseAddr + (addr))
#define PhyWrite(instPtr, addr, value) IO_Out32((instPtr)->phyCofig.baseAddr + addr, value) #define PhyWrite(instPtr, addr, value) IO_Out32((instPtr)->phyCofig.baseAddr + (addr), (value))
/************************** Constant Definitions *****************************/ /************************** Constant Definitions *****************************/
/** /**
+6
View File
@@ -127,6 +127,7 @@ void SysMonitor_Destroy(void)
*/ */
void SysMonitor_UpdateSysinfo(const SYSINFO *info) void SysMonitor_UpdateSysinfo(const SYSINFO *info)
{ {
ASSERT(info != NULL);
uint8_t buffIndx; uint8_t buffIndx;
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl); buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
sysMonitorInst->sysInfoCtrl.wBusy = buffIndx; sysMonitorInst->sysInfoCtrl.wBusy = buffIndx;
@@ -143,6 +144,7 @@ void SysMonitor_UpdateSysinfo(const SYSINFO *info)
void SysMonitor_GetSysinfo(SYSINFO *info) void SysMonitor_GetSysinfo(SYSINFO *info)
{ {
ASSERT(sysMonitorInst != NULL); ASSERT(sysMonitorInst != NULL);
ASSERT(info != NULL);
uint8_t buffIndx, buffIndex_old; uint8_t buffIndx, buffIndex_old;
buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy; buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy;
if (buffIndex_old != BUFF_NONE) 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; uint8_t buffIndx, buffIndex_old;
buffIndex_old = sysMonitorInst->sendCtrl.rBusy; buffIndex_old = sysMonitorInst->sendCtrl.rBusy;
if (buffIndex_old != BUFF_NONE) if (buffIndex_old != BUFF_NONE)
{
buffIndx = buffIndex_old; // Keep it busy buffIndx = buffIndex_old; // Keep it busy
}
else else
{
buffIndx = GetReadable(sysMonitorInst->sendCtrl); buffIndx = GetReadable(sysMonitorInst->sendCtrl);
}
sysMonitorInst->sendCtrl.rBusy = buffIndx; sysMonitorInst->sendCtrl.rBusy = buffIndx;
if (sysMonitorInst->send[buffIndx].dataId != DATA_ID_NONE) if (sysMonitorInst->send[buffIndx].dataId != DATA_ID_NONE)
{ {
+10 -10
View File
@@ -54,12 +54,12 @@
// #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97) // #define IS_PL_VALID(x) (x <= 1.03 && x >= 0.97)
// #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71) // #define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
// #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97) // #define IS_BRAM_VALID(x) (x <= 1.03 && x >= 0.97)
#define IS_PS_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_PSAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
#define IS_DDR_VALID(x) (x <= 1.7 && x >= 1.3) #define IS_DDR_VALID(x) ((x) <= 1.7 && (x) >= 1.3)
#define IS_PL_VALID(x) (x <= 1.1 && x >= 0.9) #define IS_PL_VALID(x) (x <= 1.1 && (x) >= 0.9)
#define IS_PLAUX_VALID(x) (x <= 2.0 && x >= 1.6) #define IS_PLAUX_VALID(x) ((x) <= 2.0 && (x) >= 1.6)
#define IS_BRAM_VALID(x) (x <= 1.1 && x >= 0.9) #define IS_BRAM_VALID(x) ((x) <= 1.1 && (x) >= 0.9)
#define CLK_SP_PLL0_LOCK BIT(0) #define CLK_SP_PLL0_LOCK BIT(0)
#define CLK_SP_PLL1_LOCK BIT(2) #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 spFpgaVolt; ///< Signal processor voltage state indicator
uint8_t spClkState; ///< Signal processor clock state indicator uint8_t spClkState; ///< Signal processor clock state indicator
uint8_t spAdLockState; ///< Signal processor adc lock state indicator uint8_t spAdLockState; ///< Signal processor adc lock state indicator
uint8_t spAdTemp_0; ///< Signal processor adc0 temperature int8_t spAdTemp_0; ///< Signal processor adc0 temperature
uint8_t spAdTemp_1; ///< Signal processor adc1 temperature int8_t spAdTemp_1; ///< Signal processor adc1 temperature
uint8_t spFpgaTemp; ///< Signal processor FPGA temperature int8_t spFpgaTemp; ///< Signal processor FPGA temperature
// -- Antenna status // -- Antenna status
uint8_t antVolt; ///< Antenna voltage state indicator 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 antPll; ///< Antenna rf lock state indicator
uint8_t antMgc0; ///< Antenna rf mgc0~1 indicator uint8_t antMgc0; ///< Antenna rf mgc0~1 indicator
uint8_t antMgc1; ///< Antenna rf mgc2~3 indicator uint8_t antMgc1; ///< Antenna rf mgc2~3 indicator