Compare commits
99
Commits
b5f920b4f3
...
alpha-0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c45d1e5b8 | ||
|
|
9412f65c3c | ||
|
|
c0ebef41ee | ||
|
|
a2c6ff83f7 | ||
|
|
73b8ee8bc5 | ||
|
|
d8fbdfb8e6 | ||
|
|
ff87644416 | ||
|
|
adcf7200bc | ||
|
|
f71ce6bd94 | ||
|
|
c8b0ca74a3 | ||
|
|
1a413e4d06 | ||
|
|
b7a337f821 | ||
|
|
38b7f6b985 | ||
|
|
4457eb8bc1 | ||
|
|
0248c185e4 | ||
|
|
e81be59bbb | ||
|
|
d0aad73ce5 | ||
|
|
c384bf9e9d | ||
|
|
752e9b3081 | ||
|
|
81fdd612ce | ||
|
|
ad3a6be9b1 | ||
|
|
6a680a1291 | ||
|
|
1f98662ee8 | ||
|
|
73f236bbd3 | ||
|
|
223a772582 | ||
|
|
3a99da8b76 | ||
|
|
d9ce3ae207 | ||
|
|
29d5ec32cb | ||
|
|
45080efd34 | ||
|
|
b5acfcf827 | ||
|
|
bf2a199f79 | ||
|
|
15e0fc2e39 | ||
|
|
bd51428bca | ||
|
|
d15dd7ece5 | ||
|
|
e308a61abc | ||
|
|
b9e055c039 | ||
|
|
2700e7442e | ||
|
|
653483a68e | ||
|
|
d310647fa6 | ||
|
|
d2eee6548f | ||
|
|
28a2767efc | ||
|
|
3dbf893347 | ||
|
|
070face8d3 | ||
|
|
bfa0d40996 | ||
|
|
9fcfcce584 | ||
|
|
f8dec485c5 | ||
|
|
b27bc16ab0 | ||
|
|
99e564476b | ||
|
|
4d5a4ec0da | ||
|
|
2f63058882 | ||
|
|
413c984e85 | ||
|
|
448895866a | ||
|
|
aba91e02b0 | ||
|
|
56d0fd80d0 | ||
|
|
6acd4b1ca0 | ||
|
|
f4175cd7b5 | ||
|
|
678bb7f393 | ||
|
|
085e5cea93 | ||
|
|
3916b18a6f | ||
|
|
74d20c1010 | ||
|
|
25d89b30a1 | ||
|
|
632b1ec636 | ||
|
|
9f75b519e0 | ||
|
|
7e38cf59e2 | ||
|
|
86d089e2b4 | ||
|
|
5cefee63f8 | ||
|
|
1647f4b97c | ||
|
|
1b1790657a | ||
|
|
da212a47e7 | ||
|
|
49e962612e | ||
|
|
64c116dbe0 | ||
|
|
a13ded2a89 | ||
|
|
949d0d7049 | ||
|
|
ec56ec6f6f | ||
|
|
f4f9bd0125 | ||
|
|
06cac2a2ed | ||
|
|
a4106b997c | ||
|
|
3463fab14c | ||
|
|
246d54755a | ||
|
|
c5f64ada29 | ||
|
|
b4a88711d7 | ||
|
|
3f10a1cbe4 | ||
|
|
1555c7493c | ||
|
|
b87bcb8fb7 | ||
|
|
9afd439852 | ||
|
|
017886bf00 | ||
|
|
2f0ee92e33 | ||
|
|
0496e6a2f6 | ||
|
|
463836b92a | ||
|
|
8b2fcfb810 | ||
|
|
ddf42c6543 | ||
|
|
03aec683ef | ||
|
|
bbf5aad749 | ||
|
|
0882d94071 | ||
|
|
90a48b908b | ||
|
|
89ef050cc2 | ||
|
|
683940b5ff | ||
|
|
9c6b3a64c8 | ||
|
|
43df6dd7af |
+5
-1
@@ -50,4 +50,8 @@
|
||||
modules.order
|
||||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
dkms.conf
|
||||
|
||||
# MacOS .DS_Store file
|
||||
**/.DS_Store
|
||||
**/._.DS_Store
|
||||
@@ -93,9 +93,6 @@
|
||||
#if !defined(DATALINK_ENABLE_AUTOTIMESYNC)
|
||||
#warning To enbale bit error rate test, auto time-sync should be enabled...
|
||||
#endif
|
||||
#if defined(DATALINK_ENABLE_AUTORECONNECT)
|
||||
#error Do not support auto reconnnect in bit error rate test mode...
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -989,7 +989,7 @@ int HW_9371LargeFrequencyChange(mykonosDevice_t *mykDevice, uint64_t freq_Hz)
|
||||
// HW_9371LargeFrequencyChange(&mykDevice, NewFreqHz);
|
||||
// }
|
||||
// mykDevice.tx->txPllLoFrequency_Hz = NewFreqHz;
|
||||
// printf("New Tx frequency set to %ld Hz!\n",NewFreqHz);
|
||||
// printf("New Tx frequency set to %d Hz!\n",NewFreqHz);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
@@ -1017,7 +1017,7 @@ int HW_9371LargeFrequencyChange(mykonosDevice_t *mykDevice, uint64_t freq_Hz)
|
||||
// HW_9371LargeFrequencyChange(&mykDevice, NewFreqHz);
|
||||
// }
|
||||
// mykDevice.rx->rxPllLoFrequency_Hz = NewFreqHz;
|
||||
// printf("New Rx frequency set to %ld Hz!\n",NewFreqHz);
|
||||
// printf("New Rx frequency set to %d Hz!\n",NewFreqHz);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
#include "util.h"
|
||||
#include "error.h"
|
||||
|
||||
+33
-32
@@ -49,6 +49,7 @@ void Phy_IntrHandler(void *context);
|
||||
void PeriodicPull_Handler(void *callBackRef);
|
||||
void ScuTimer_IntrHandler(void *context);
|
||||
void Systembus_RxIntrHandler(void *context);
|
||||
void Systembus_TxIntrHandler(void *context);
|
||||
/************************** Constant Definitions *****************************/
|
||||
struct callback_desc phy_callback_desc = {
|
||||
.callback = Phy_IntrHandler,
|
||||
@@ -67,7 +68,7 @@ struct callback_desc sysbus_rx_callback_desc = {
|
||||
};
|
||||
|
||||
struct callback_desc sysbus_tx_callback_desc = {
|
||||
.callback = Systembus_RxIntrHandler,
|
||||
.callback = Systembus_TxIntrHandler,
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
@@ -76,25 +77,25 @@ struct callback_desc scutm_callback_desc = {
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
static L2_CONFIG linkConfig = {
|
||||
L2_CONFIG linkConfig = {
|
||||
.myType = L2_NODE_HEAD,
|
||||
.clustId = 1,
|
||||
.myId = 1,
|
||||
.headId = 1,
|
||||
.bkpHeadId = 0,
|
||||
.netScale = 2,
|
||||
.phyInstPtr = NULL, // pyhsical layer reference
|
||||
.phyInstPtr = NULL, // physical layer reference
|
||||
.tmcInstPtr = NULL
|
||||
};
|
||||
|
||||
// static L2_CONFIG linkConfig = {
|
||||
// L2_CONFIG linkConfig = {
|
||||
// .myType = L2_NODE_MEMBER,
|
||||
// .clustId = 1,
|
||||
// .myId = 2,
|
||||
// .headId = 1,
|
||||
// .bkpHeadId = 0,
|
||||
// .netScale = 2,
|
||||
// .phyInstPtr = NULL, // pyhsical layer reference
|
||||
// .phyInstPtr = NULL, // physical layer reference
|
||||
// .tmcInstPtr = NULL
|
||||
// };
|
||||
|
||||
@@ -123,7 +124,7 @@ static struct timer_desc *logTmPtr;
|
||||
static SYSBUS *sysbusDescPtr;
|
||||
static PHY_INST *phyInstPtr;
|
||||
static TMC_INST *tmcInstPtr = NULL;
|
||||
static L2_INST *linkInstPtr;
|
||||
L2_INST *linkInstPtr;
|
||||
|
||||
/****************************************************************************/
|
||||
/**
|
||||
@@ -145,7 +146,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_ctrl_init(&descPtr, &intc_init_param);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Intc Init FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("Intc Init FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -159,21 +160,21 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_trigger_level_set(descPtr, PHY_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set highest interrupt priority
|
||||
Status = irq_set_priority(descPtr, PHY_INTR_ID, 0x08);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Connect the interrupt service routine isr1 to the interrupt controller
|
||||
Status = irq_register_callback(descPtr, PHY_INTR_ID, &phy_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -181,21 +182,21 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_trigger_level_set(descPtr, PERIODIC_5MS_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set highest interrupt priority
|
||||
Status = irq_set_priority(descPtr, PERIODIC_5MS_INTR_ID, 0x00);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Connect the interrupt service routine isr1 to the interrupt controller
|
||||
Status = irq_register_callback(descPtr, PERIODIC_5MS_INTR_ID, &periodicpull_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -203,14 +204,14 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
// Status = irq_trigger_level_set(descPtr, SYSBUS_TX_INTR_ID, IRQ_EDGE_RISING);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
// // Set interrupt priority
|
||||
// Status = irq_set_priority(descPtr, SYSBUS_TX_INTR_ID, 0x10);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
//
|
||||
@@ -218,20 +219,20 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
// Status = irq_register_callback(descPtr, SYSBUS_TX_INTR_ID, &sysbus_tx_callback_desc);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
// Status = irq_trigger_level_set(descPtr, SYSBUS_RX_INTR_ID, IRQ_EDGE_RISING);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
// // Set interrupt priority
|
||||
// Status = irq_set_priority(descPtr, SYSBUS_RX_INTR_ID, 0x18);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
//
|
||||
@@ -239,7 +240,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
// Status = irq_register_callback(descPtr, SYSBUS_RX_INTR_ID, &sysbus_rx_callback_desc);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
//
|
||||
@@ -248,7 +249,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
// Status = irq_register_callback(descPtr, SCUTIMER_INTR_ID, &scutm_callback_desc);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
// DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
|
||||
@@ -263,7 +264,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_global_enable(descPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("IRQ global enable FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("IRQ global enable FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
return SUCCESS;
|
||||
@@ -300,7 +301,7 @@ void PeriodicPull_Handler(void *callBackRef)
|
||||
Status = Linklayer_Proc(linkInstPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Link layer runs failed, with error code: %ld\n", Status);
|
||||
DBG_ERROR("Link layer runs failed, with error code: %" PRId32 "\n", Status);
|
||||
_nop_();
|
||||
}
|
||||
} // PeriodicPull_Handler
|
||||
@@ -320,7 +321,7 @@ void Systembus_RxIntrHandler(void *context)
|
||||
Status = SystemBus_RxIntrHandler(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_RxIntrHandler exit with error code %ld,\n", Status);
|
||||
DBG_ERROR("SystemBus_RxIntrHandler exit with error code %" PRId32 ",\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +340,7 @@ void Systembus_TxIntrHandler(void *context)
|
||||
Status = SystemBus_TxIntrHandler(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_TxIntrHandler exit with error code %ld,\n", Status);
|
||||
DBG_ERROR("SystemBus_TxIntrHandler exit with error code %" PRId32 ",\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,8 +359,8 @@ void ScuTimer_IntrHandler(void *context)
|
||||
xdesc = (struct xil_timer_desc *)(logTmPtr->extra);
|
||||
if (XScuTimer_IsExpired((XScuTimer *)xdesc->instance))
|
||||
{
|
||||
// Update log
|
||||
Phy_UpdateHwSate(phyInstPtr);
|
||||
// Refresh log
|
||||
Phy_RefreshHwSate(phyInstPtr);
|
||||
XScuTimer_ClearInterruptStatus((XScuTimer *)xdesc->instance);
|
||||
}
|
||||
else
|
||||
@@ -380,7 +381,7 @@ void ScuTimer_IntrHandler(void *context)
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
int32_t Status;
|
||||
DBG_PRINT("Application Version: %2d.%2d.%4d.\n", _APP_VER_MAIN, _APP_VER_MINOR, _APP_VER_PATCH);
|
||||
|
||||
/* System Monitor Initialize */
|
||||
@@ -448,7 +449,7 @@ int main(void)
|
||||
// Status = SystemBus_Init(&sysbusDescPtr, &sysbusConfig);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("Systembus init FAILED, with error code: %d\n", Status);
|
||||
// DBG_ERROR("Systembus init FAILED, with error code: %" PRId32 "\n", Status);
|
||||
// return Status;
|
||||
// }
|
||||
|
||||
@@ -456,7 +457,7 @@ int main(void)
|
||||
Status = timer_init(&logTmPtr, &scutimer_init_param);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SCU Timer init FAILED, with error code: %d\n", Status);
|
||||
DBG_ERROR("SCU Timer init FAILED, with error code: %" PRId32 "\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -468,7 +469,7 @@ int main(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("Interrupt system setup FAILED, ErrorCode: %d.\n", Status);
|
||||
DBG_ERROR("Interrupt system setup FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -490,7 +491,7 @@ int main(void)
|
||||
// Status = SystemBus_HandleCmd(sysbusDescPtr);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %d.\n", Status);
|
||||
// DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %" PRId32 ".\n", Status);
|
||||
// }
|
||||
// }
|
||||
// if (SystemBus_IsRsqPendding(sysbusDescPtr) && (!SystemBus_IsTxBusy(sysbusDescPtr)))
|
||||
@@ -500,7 +501,7 @@ int main(void)
|
||||
// Status = SystemBus_MakeResp(sysbusDescPtr);
|
||||
// if (Status != SUCCESS)
|
||||
// {
|
||||
// DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %d.\n", Status);
|
||||
// DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %" PRId32 ".\n", Status);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -190,9 +190,6 @@ typedef enum
|
||||
#if !defined(DATALINK_ENABLE_AUTOTIMESYNC)
|
||||
#warning To enbale bit error rate test, auto time-sync should be enabled...
|
||||
#endif
|
||||
#if defined(DATALINK_ENABLE_AUTORECONNECT)
|
||||
#error Do not support auto reconnnect in bit error rate test mode...
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif //__APP_CONFIG_H_
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
#include "util.h"
|
||||
#include "error.h"
|
||||
|
||||
+39
-38
@@ -45,6 +45,7 @@ void Phy_IntrHandler(void *context);
|
||||
void PeriodicPull_Handler(void *callBackRef);
|
||||
void ScuTimer_IntrHandler(void *context);
|
||||
void Systembus_RxIntrHandler(void *context);
|
||||
void Systembus_TxIntrHandler(void *context);
|
||||
/************************** Constant Definitions *****************************/
|
||||
struct callback_desc phy_callback_desc = {
|
||||
.callback = Phy_IntrHandler,
|
||||
@@ -63,7 +64,7 @@ struct callback_desc sysbus_rx_callback_desc = {
|
||||
};
|
||||
|
||||
struct callback_desc sysbus_tx_callback_desc = {
|
||||
.callback = Systembus_RxIntrHandler,
|
||||
.callback = Systembus_TxIntrHandler,
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
@@ -72,25 +73,25 @@ struct callback_desc scutm_callback_desc = {
|
||||
.ctx = NULL
|
||||
};
|
||||
|
||||
static L2_CONFIG linkConfig = {
|
||||
L2_CONFIG linkConfig = {
|
||||
.myType = L2_NODE_HEAD,
|
||||
.clustId = 1,
|
||||
.myId = 1,
|
||||
.headId = 1,
|
||||
.bkpHeadId = 0,
|
||||
.netScale = 2,
|
||||
.phyInstPtr = NULL, // pyhsical layer reference
|
||||
.phyInstPtr = NULL, // physical layer reference
|
||||
.tmcInstPtr = NULL
|
||||
};
|
||||
|
||||
// static L2_CONFIG linkConfig = {
|
||||
// L2_CONFIG linkConfig = {
|
||||
// .myType = L2_NODE_MEMBER,
|
||||
// .clustId = 1,
|
||||
// .myId = 2,
|
||||
// .headId = 1,
|
||||
// .bkpHeadId = 0,
|
||||
// .netScale = 2,
|
||||
// .phyInstPtr = NULL, // pyhsical layer reference
|
||||
// .phyInstPtr = NULL, // physical layer reference
|
||||
// .tmcInstPtr = NULL
|
||||
// };
|
||||
|
||||
@@ -119,7 +120,7 @@ static struct timer_desc *logTmPtr;
|
||||
static SYSBUS *sysbusDescPtr;
|
||||
static PHY_INST *phyInstPtr;
|
||||
static TMC_INST *tmcInstPtr = NULL;
|
||||
static L2_INST *linkInstPtr;
|
||||
L2_INST *linkInstPtr;
|
||||
|
||||
static struct hmc7044_dev *hmc7044_inst;
|
||||
static struct ad9361_reg_dev *ad9361_1_reg_inst;
|
||||
@@ -146,7 +147,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_ctrl_init(&descPtr, &intc_init_param);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Intc Init FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("Intc Init FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -160,21 +161,21 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_trigger_level_set(descPtr, PHY_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set highest interrupt priority
|
||||
Status = irq_set_priority(descPtr, PHY_INTR_ID, 0x08);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Connect the interrupt service routine isr1 to the interrupt controller
|
||||
Status = irq_register_callback(descPtr, PHY_INTR_ID, &phy_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -182,21 +183,21 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_trigger_level_set(descPtr, PERIODIC_5MS_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set highest interrupt priority
|
||||
Status = irq_set_priority(descPtr, PERIODIC_5MS_INTR_ID, 0x00);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PERIODIC_5MS_INTR_ID priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Connect the interrupt service routine isr1 to the interrupt controller
|
||||
Status = irq_register_callback(descPtr, PERIODIC_5MS_INTR_ID, &periodicpull_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -204,14 +205,14 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_trigger_level_set(descPtr, SYSBUS_TX_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set interrupt priority
|
||||
Status = irq_set_priority(descPtr, SYSBUS_TX_INTR_ID, 0x10);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -219,20 +220,20 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_register_callback(descPtr, SYSBUS_TX_INTR_ID, &sysbus_tx_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
Status = irq_trigger_level_set(descPtr, SYSBUS_RX_INTR_ID, IRQ_EDGE_RISING);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR trigger level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
// Set interrupt priority
|
||||
Status = irq_set_priority(descPtr, SYSBUS_RX_INTR_ID, 0x18);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR priority level set FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -240,7 +241,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_register_callback(descPtr, SYSBUS_RX_INTR_ID, &sysbus_rx_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -249,7 +250,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_register_callback(descPtr, SCUTIMER_INTR_ID, &scutm_callback_desc);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("PHY_INTR register callback FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -264,7 +265,7 @@ int32_t SetupInterruptSystem(struct irq_ctrl_desc *descPtr)
|
||||
Status = irq_global_enable(descPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("IRQ global enable FAILED, ErrorCode: %ld.\n", Status);
|
||||
DBG_ERROR("IRQ global enable FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
return SUCCESS;
|
||||
@@ -301,7 +302,7 @@ void PeriodicPull_Handler(void *callBackRef)
|
||||
Status = Linklayer_Proc(linkInstPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Link layer runs failed, with error code: %ld\n", Status);
|
||||
DBG_ERROR("Link layer runs failed, with error code: %" PRId32 "\n", Status);
|
||||
_nop_();
|
||||
}
|
||||
} // PeriodicPull_Handler
|
||||
@@ -321,7 +322,7 @@ void Systembus_RxIntrHandler(void *context)
|
||||
Status = SystemBus_RxIntrHandler(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_RxIntrHandler exit with error code %ld,\n", Status);
|
||||
DBG_ERROR("SystemBus_RxIntrHandler exit with error code %" PRId32 ",\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +341,7 @@ void Systembus_TxIntrHandler(void *context)
|
||||
Status = SystemBus_TxIntrHandler(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_TxIntrHandler exit with error code %ld,\n", Status);
|
||||
DBG_ERROR("SystemBus_TxIntrHandler exit with error code %" PRId32 ",\n", Status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,8 +360,8 @@ void ScuTimer_IntrHandler(void *context)
|
||||
xdesc = (struct xil_timer_desc *)(logTmPtr->extra);
|
||||
if (XScuTimer_IsExpired((XScuTimer *)xdesc->instance))
|
||||
{
|
||||
// Update log
|
||||
Phy_UpdateHwSate(phyInstPtr);
|
||||
// Refresh log
|
||||
Phy_RefreshHwSate(phyInstPtr);
|
||||
XScuTimer_ClearInterruptStatus((XScuTimer *)xdesc->instance);
|
||||
}
|
||||
else
|
||||
@@ -373,7 +374,7 @@ void ScuTimer_IntrHandler(void *context)
|
||||
/**
|
||||
* @brief Hardware_SwitchFreq
|
||||
*
|
||||
* @param dev
|
||||
* @param devSysMonitor_UpdateHardwareStatus(newHwState);
|
||||
* @param freq
|
||||
*
|
||||
* @return None.
|
||||
@@ -566,7 +567,7 @@ int Hardware_Init(void)
|
||||
Status = hmc7044_init(&hmc7044_inst, &hmc7044_default_init_param);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("hmc7044_init() error: %ld\n", Status);
|
||||
DBG_ERROR("hmc7044_init() error: %" PRId32 "\n", Status);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@@ -730,7 +731,7 @@ int Hardware_Init(void)
|
||||
******************************************************************************/
|
||||
int main(void)
|
||||
{
|
||||
int Status;
|
||||
int32_t Status;
|
||||
DBG_PRINT("Application Version: %2d.%2d.%4d.\n", _APP_VER_MAIN, _APP_VER_MINOR, _APP_VER_PATCH);
|
||||
|
||||
/* System Monitor Initialize */
|
||||
@@ -744,7 +745,7 @@ int main(void)
|
||||
DBG_PRINT("System monitor Init FAILED! \n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/* Hardware Initialize */
|
||||
Status = Hardware_Init();
|
||||
if (Status == SUCCESS)
|
||||
@@ -799,7 +800,7 @@ int main(void)
|
||||
Status = SystemBus_Init(&sysbusDescPtr, &sysbusConfig);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Systembus init FAILED, with error code: %d\n", Status);
|
||||
DBG_ERROR("Systembus init FAILED, with error code: %" PRId32 "\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -807,7 +808,7 @@ int main(void)
|
||||
Status = timer_init(&logTmPtr, &scutimer_init_param);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SCU Timer init FAILED, with error code: %d\n", Status);
|
||||
DBG_ERROR("SCU Timer init FAILED, with error code: %" PRId32 "\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -819,7 +820,7 @@ int main(void)
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_ERROR("Interrupt system setup FAILED, ErrorCode: %d.\n", Status);
|
||||
DBG_ERROR("Interrupt system setup FAILED, ErrorCode: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -828,8 +829,8 @@ int main(void)
|
||||
|
||||
DBG_PRINT("Physical started...\n");
|
||||
Phy_Start(phyInstPtr);
|
||||
|
||||
Linklayer_Start(linkInstPtr);
|
||||
|
||||
// Linklayer_Start(linkInstPtr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -839,17 +840,17 @@ int main(void)
|
||||
Status = SystemBus_HandleCmd(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %d.\n", Status);
|
||||
DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %" PRId32 ".\n", Status);
|
||||
}
|
||||
}
|
||||
if (SystemBus_IsRsqPendding(sysbusDescPtr) && (!SystemBus_IsTxBusy(sysbusDescPtr)))
|
||||
{
|
||||
// FIXME: Required by 12 (CASC)
|
||||
udelay(200);
|
||||
udelay(4000);
|
||||
Status = SystemBus_MakeResp(sysbusDescPtr);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %d.\n", Status);
|
||||
DBG_ERROR("SystemBus_HandleCmd exit with ErrorCode: %" PRId32 ".\n", Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "util.h"
|
||||
#include "circ_queue.h"
|
||||
#include "../time_ctrl/time_ctrl.h"
|
||||
#ifndef EMULATION
|
||||
#ifndef EMULATION
|
||||
#include "../config/app_config.h"
|
||||
#endif
|
||||
/************************** Constant Definitions *****************************/
|
||||
@@ -49,7 +49,7 @@ static void L2_DataAvailUpdate(L2_INST *instPtr, bool status);
|
||||
static inline void UpdateMainSate(L2_INST *instPtr, L2_NODE_STATE newSate)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
DBG_INFO("MainStateUpdate: %d -> %d\n", instPtr->mainState, newSate);
|
||||
DBG_INFO("MainStateUpdate: %" PRId8 " -> %" PRId8 "\n", instPtr->mainState, newSate);
|
||||
instPtr->nextState = newSate;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ static inline void UpdateMainSate(L2_INST *instPtr, L2_NODE_STATE newSate)
|
||||
static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
DBG_INFO("Set new slot number to %u\n", newSlotNum);
|
||||
DBG_INFO("Set new slot number to %" PRIu32 "\n", newSlotNum);
|
||||
instPtr->slotNum.next = newSlotNum;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ static void L2_SetSlotNum(L2_INST *instPtr, uint32_t newSlotNum)
|
||||
static void L2_SetFrameNum(L2_INST *instPtr, uint32_t newFrameNum)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
DBG_INFO("Set new frame number to %u\n", newFrameNum);
|
||||
DBG_INFO("Set new frame number to %" PRIu32 "\n", newFrameNum);
|
||||
instPtr->frameNum.next = newFrameNum;
|
||||
}
|
||||
|
||||
@@ -288,7 +288,7 @@ inline void L2_RcdShift(L2_RCD *rcd, int32_t netxVal)
|
||||
rcd->next = netxVal;
|
||||
}
|
||||
|
||||
// FIXME:
|
||||
// FIXME:
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Infer last received frame type.
|
||||
@@ -333,7 +333,6 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
PHY_INST *phyRef = instPtr->config.phyInstPtr;
|
||||
bool isValid;
|
||||
L2_FRAME_TYPE recvType = L2_GetLastOptFrameType(instPtr);
|
||||
L2_FRAME_TYPE sendType = L2_GetNextFrameType(instPtr);
|
||||
// Update frame state.
|
||||
if (Phy_IsFrameValid(phyRef) == false)
|
||||
{
|
||||
@@ -342,20 +341,23 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
else
|
||||
{
|
||||
DBG_INFO("A frame received, checking data validation...\n");
|
||||
DBG_INFO("Last frame type is: %u.\n", instPtr->frame.last);
|
||||
DBG_INFO("Last frame type is: %" PRId32 ".\n", instPtr->frame.last);
|
||||
Phy_RetrieveRecvData(phyRef, instPtr->recvPktData);
|
||||
instPtr->log.frameRecv++;
|
||||
|
||||
// Update frame state.
|
||||
// FIXME: add log
|
||||
switch (recvType)
|
||||
{
|
||||
case L2_SCAN_FRAME:
|
||||
case L2_ADV_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_ADV_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.advRecvCnt++;
|
||||
instPtr->log.advCorrectCnt = isValid ? instPtr->log.advCorrectCnt + 1 : instPtr->log.advCorrectCnt;
|
||||
break;
|
||||
case L2_CFM_FRAME:
|
||||
isValid = L2_CrcCheck(instPtr->recvPktData, L2_CMF_PACK_LEN, L2_CRC16_1021);
|
||||
instPtr->log.cfmRecvCnt++;
|
||||
instPtr->log.cfmCorrectCnt = isValid ? instPtr->log.cfmCorrectCnt + 1 : instPtr->log.cfmCorrectCnt;
|
||||
break;
|
||||
case L2_SVC_FRAME:
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
@@ -363,6 +365,8 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
#else
|
||||
isValid = true;
|
||||
#endif
|
||||
instPtr->log.svcRecvCnt++;
|
||||
instPtr->log.svcCorrectCnt = isValid ? instPtr->log.svcCorrectCnt + 1 : instPtr->log.svcCorrectCnt;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -379,54 +383,6 @@ void L2_FrameStateUpdate(L2_INST *instPtr)
|
||||
L2_DataAvailUpdate(instPtr, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Logging status.
|
||||
// -- send slot status
|
||||
if (instPtr->tor.curr == L2_TOR_RX)
|
||||
{
|
||||
instPtr->rxSlotLog.tuNo = L2_GetCurrentFrameNum(instPtr);
|
||||
instPtr->rxSlotLog.slotNo = L2_GetCurrentSlotNum(instPtr);
|
||||
instPtr->rxSlotLog.frameType = recvType;
|
||||
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->rxSlotLog.payload));
|
||||
if (isValid == true)
|
||||
{
|
||||
memcpy(instPtr->rxSlotLog.payload,
|
||||
instPtr->recvPktData,
|
||||
Phy_GetFrameLen(L2_L2frame2L1frame(recvType)));
|
||||
TIME_WORD timeWrod;
|
||||
Phy_GetLastReceivedFrameSyncTimeStamp(phyRef, &timeWrod);
|
||||
instPtr->rxSlotLog.tmStamp = timeWrod.frac_part;
|
||||
instPtr->rxSlotLog.tmStamp += (uint64_t)timeWrod.int_part * TIME_FRAC_MAX;
|
||||
|
||||
// Log time deviation.
|
||||
instPtr->txSlotLog.tmDevi = 0; // TODO:
|
||||
// Log frequency deviation
|
||||
instPtr->rxSlotLog.freqDevi = (uint32_t)Phy_GetFreqEst(phyRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
instPtr->rxSlotLog.tmStamp = 0;
|
||||
instPtr->rxSlotLog.tmDevi = 0;
|
||||
instPtr->rxSlotLog.freqDevi = 0;
|
||||
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->rxSlotLog.payload));
|
||||
}
|
||||
SysMonitor_UpdateRecvSlotLog(&(instPtr->rxSlotLog));
|
||||
}
|
||||
// -- send slot status
|
||||
if (instPtr->tor.next == L2_TOR_TX)
|
||||
{
|
||||
instPtr->txSlotLog.tuNo = L2_GetCurrentFrameNum(instPtr);
|
||||
instPtr->txSlotLog.slotNo = L2_GetCurrentSlotNum(instPtr);
|
||||
instPtr->txSlotLog.frameType = sendType;
|
||||
memset(instPtr->rxSlotLog.payload, 0x00, sizeof(instPtr->txSlotLog.payload));
|
||||
memcpy(instPtr->txSlotLog.payload,
|
||||
instPtr->sendPktData,
|
||||
Phy_GetFrameLen(L2_L2frame2L1frame(sendType)));
|
||||
instPtr->txSlotLog.tmStamp = 0;
|
||||
instPtr->txSlotLog.tmDevi = 0;
|
||||
instPtr->txSlotLog.freqDevi = 0;
|
||||
SysMonitor_UpdateSendSlotLog(&(instPtr->txSlotLog));
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -451,7 +407,7 @@ int32_t L2_SteerBeam2Node(L2_INST *instPtr, uint8_t nodeId)
|
||||
Status = L2_GetNodePos(instPtr->nodeList, nodeId, &dstPos);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to retrieve position info of node %u, remain last configuration.\n", nodeId);
|
||||
DBG_ERROR("Failed to retrieve position info of node %" PRIu8 ", remain last configuration.\n", nodeId);
|
||||
return EPARAM;
|
||||
}
|
||||
myPos.x = instPtr->sysInfo.posX;
|
||||
@@ -587,7 +543,7 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
frameStr = "UNKNOWN Frame";
|
||||
break;
|
||||
}
|
||||
DBG_INFO("# Setup Next Slot # [%u-%u], %s, %s.\n",
|
||||
DBG_INFO("# Setup Next Slot # [%" PRIu32 "-%" PRIu32 "], %s, %s.\n",
|
||||
instPtr->frameNum.next,
|
||||
instPtr->slotNum.next,
|
||||
torStr, frameStr);
|
||||
@@ -603,7 +559,7 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %d\n", Status);
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
|
||||
PHY_TOR_TYPE tor;
|
||||
@@ -619,14 +575,14 @@ int32_t L2_SetupNextSlot(L2_INST *instPtr, L2_TOR_TYPE txrxMode, L2_FRAME_TYPE f
|
||||
tor = PHY_TOR_RX;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Invalid txrx mode :%d.\n", txrxMode);
|
||||
DBG_ERROR("Invalid txrx mode :%" PRId8 ".\n", txrxMode);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
|
||||
Status = Phy_SetupNextSlot(phyRef, tor, L2_L2frame2L1frame(frameType), instPtr->sendPktData);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical setup failed, with error code: %d\n", Status);
|
||||
DBG_ERROR("Physical setup failed, with error code: %" PRId32 "\n", Status);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
@@ -723,7 +679,7 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
|
||||
goto init_error;
|
||||
}
|
||||
// Reset basic info
|
||||
(*instPtr)->netStartTime = UINT32_MAX;
|
||||
(*instPtr)->netStartTime = NET_START_TIME_INFTY;
|
||||
(*instPtr)->rtneConfig.last = NULL;
|
||||
(*instPtr)->rtneConfig.curr = NULL;
|
||||
(*instPtr)->rtneConfig.next = NULL;
|
||||
@@ -762,14 +718,14 @@ int32_t Linklayer_Init(L2_INST **instPtr, const L2_CONFIG *config)
|
||||
Status = L2_CreateSchedEventPool(&((*instPtr)->schdEventPool));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("L2_CreateSchedEventPool runs failed, with error code: %d.\n", Status);
|
||||
DBG_ERROR("L2_CreateSchedEventPool runs failed, with error code: %" PRId32 ".\n", Status);
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
Status = L2_NodeList_Init(&((*instPtr)->nodeList));
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("NodeList_Init runs failed, with error code: %d.\n", Status);
|
||||
DBG_ERROR("NodeList_Init runs failed, with error code: %" PRId32 ".\n", Status);
|
||||
goto init_error;
|
||||
}
|
||||
|
||||
@@ -895,7 +851,10 @@ void Linklayer_Destroy(L2_INST *instPtr)
|
||||
int32_t Linklayer_Start(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
instPtr->netStartTime = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) / L2_SLOTS_PER_FRAME + 1;
|
||||
// Set netStartTime at first call.
|
||||
if (instPtr->netStartTime == NET_START_TIME_INFTY) {
|
||||
instPtr->netStartTime = TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) / L2_SLOTS_PER_FRAME + 1;
|
||||
}
|
||||
instPtr->isEnable = true;
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -990,7 +949,7 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
||||
DBG_ERROR("Illegal event, only None_Head node can assert L2_EV_LOST_CXN.\n");
|
||||
break;
|
||||
}
|
||||
DBG_WARNING("Lost connection with head node [%d].\n", L2_GetHeadId(instPtr));
|
||||
DBG_WARNING("Lost connection with head node [%" PRId8 "].\n", L2_GetHeadId(instPtr));
|
||||
L2_Scan_Reset(instPtr->scanFSM);
|
||||
L2_Service_Reset(instPtr->serviceFSM);
|
||||
instPtr->cxn2Net = false;
|
||||
@@ -1024,7 +983,7 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_WARNING("Unsupported routine state [%d], Continue withe previous routine table.\n", instPtr->nextState);
|
||||
DBG_WARNING("Unsupported routine state [%" PRId8 "], Continue withe previous routine table.\n", instPtr->nextState);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1038,7 +997,7 @@ int32_t Linklayer_EventHandler(L2_INST *instPtr, const L2_EVENT *l2Event)
|
||||
}
|
||||
default:
|
||||
{
|
||||
DBG_WARNING("UNKNOWN Event %d asserted.\n", l2Event->event);
|
||||
DBG_WARNING("UNKNOWN Event %" PRId8 " asserted.\n", l2Event->event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1076,7 +1035,7 @@ int32_t Linklayer_PktHandler(L2_INST *instPtr, L2_FRAME_TYPE frameType)
|
||||
Status = L2_Service_PktHandler(instPtr, instPtr->recvPktData);
|
||||
break;
|
||||
default:
|
||||
DBG_WARNING("L2FrameHandler: UNKNOWN L2-FrameType %d", frameType);
|
||||
DBG_WARNING("L2FrameHandler: UNKNOWN L2-FrameType %" PRId8 "\n", frameType);
|
||||
Status = FAILURE;
|
||||
break;
|
||||
}
|
||||
@@ -1100,14 +1059,14 @@ static int32_t IntcNodeTTL(NODE_ENTRY *node, const void *param)
|
||||
static bool IsNodeConnected(NODE_ENTRY *node)
|
||||
{
|
||||
ASSERT(node != NULL);
|
||||
DBG_INFO("Node: %u, TTL: %u.\n", node->nodeInfo.nodeId, node->ttlCnt);
|
||||
DBG_INFO("Node: %" PRIu8 ", TTL: %" PRIu32 ".\n", node->nodeInfo.nodeId, node->ttlCnt);
|
||||
if (node->ttlCnt < LINK_BROCK_THRESHOLD)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_WARNING("Lost Connection to NODE %u.\n", node->nodeInfo.nodeId);
|
||||
DBG_WARNING("Lost Connection to NODE %" PRIu8 ".\n", node->nodeInfo.nodeId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1139,7 +1098,7 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
instPtr->rtneConfig.curr = instPtr->rtneConfig.next;
|
||||
instPtr->rtneConfig.next = &(instPtr->rtneConfig.rtneTable[tableIndx][entryIndx]);
|
||||
rtneEntry = instPtr->rtneConfig.rtneTable[tableIndx][entryIndx];
|
||||
DBG_INFO("## Routine: %u-%u, Routine period: %u.\n", tableIndx, entryIndx, instPtr->rtneConfig.rtnePrd);
|
||||
DBG_INFO("## Routine: %" PRIu32 "-%" PRIu32 ", Routine period: %" PRIu32 ".\n", tableIndx, entryIndx, instPtr->rtneConfig.rtnePrd);
|
||||
|
||||
switch (rtneEntry.slotType)
|
||||
{
|
||||
@@ -1157,7 +1116,7 @@ static int32_t Linklayer_Routine(L2_INST *instPtr)
|
||||
Status = L2_Service_Routine(instPtr, &rtneEntry);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("UNKNOWN slot type [%d].\n", rtneEntry.slotType);
|
||||
DBG_ERROR("UNKNOWN slot type [%" PRId8 "].\n", rtneEntry.slotType);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
@@ -1212,7 +1171,7 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
uint32_t nextTimeUnit = (TimeCtrl_GetIntCnt(instPtr->config.tmcInstPtr) + 1) / L2_SLOTS_PER_FRAME;
|
||||
if (nextTimeUnit < instPtr->netStartTime)
|
||||
{
|
||||
DBG_WARNING("Linklayer not start yet, next time unit: %u, start time unit: %u.\n",
|
||||
DBG_WARNING("Linklayer not start yet, next time unit: %" PRIu32 ", start time unit: %" PRIu32 ".\n",
|
||||
nextTimeUnit, instPtr->netStartTime);
|
||||
return EIGNORE;
|
||||
}
|
||||
@@ -1220,7 +1179,7 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
// Update slot number.
|
||||
L2_UpdateSlotNum(instPtr);
|
||||
|
||||
DBG_INFO("######## Current frameNum: %u, SlotNum: %u ########\n",
|
||||
DBG_INFO("######## Current frameNum: %" PRIu32 ", SlotNum: %" PRIu32 " ########\n",
|
||||
instPtr->frameNum.curr, instPtr->slotNum.curr);
|
||||
|
||||
// Sync System info
|
||||
@@ -1234,7 +1193,7 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
{
|
||||
if (Linklayer_PktHandler(instPtr, L2_GetLastOptFrameType(instPtr)) != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Failed to handle last received frame: %d.\n", L2_GetLastOptFrameType(instPtr));
|
||||
DBG_ERROR("Failed to handle last received frame: %" PRId8 ".\n", L2_GetLastOptFrameType(instPtr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1267,25 +1226,33 @@ int32_t Linklayer_Proc(L2_INST *instPtr)
|
||||
// Check and execute scheduled event.
|
||||
L2_EventPoolHandler(instPtr);
|
||||
|
||||
PHY_INST* phyRef = instPtr->config.phyInstPtr;
|
||||
TMC_INST* tmcRef = instPtr->config.tmcInstPtr;
|
||||
|
||||
TIME_WORD timeWord;
|
||||
// Update Protocol log
|
||||
instPtr->prtcLog.tmSys = instPtr->frameNum.last * L2_SLOTS_PER_FRAME + instPtr->slotNum.last;
|
||||
instPtr->prtcLog.phySt = 0; // TODO: Update physical state.
|
||||
TimeCtrl_GetCurrentTime(tmcRef, &timeWord);
|
||||
instPtr->prtcLog.tmLocal = timeWord.frac_part; // us
|
||||
instPtr->prtcLog.tmLocal += (uint64_t)timeWord.int_part * TIME_FRAC_MAX; // us
|
||||
instPtr->prtcLog.beamNo = phyRef->beamNo.last;
|
||||
instPtr->prtcLog.beamNo = phyRef->beamWd.last;
|
||||
instPtr->prtcLog.stage = instPtr->mainState;
|
||||
instPtr->prtcLog.recvCnt = instPtr->log.frameRecv;
|
||||
instPtr->prtcLog.recvCorrect = instPtr->log.frameCorrect;
|
||||
SysMonitor_UpdateProtocolLog(&(instPtr->prtcLog));
|
||||
|
||||
|
||||
// Update link layer state.
|
||||
instPtr->mainState = instPtr->nextState;
|
||||
|
||||
instPtr->linkLog.tuNum = instPtr->frameNum.curr;
|
||||
instPtr->linkLog.slotNum = (uint8_t)instPtr->slotNum.curr;
|
||||
instPtr->linkLog.nodeType = (instPtr->config.myType == L2_NODE_HEAD) ? 0xAA : 0xCC;
|
||||
instPtr->linkLog.cxnStatus = (instPtr->cxn2Net) ? 0x11 : 0x00;
|
||||
instPtr->linkLog.linkStage = (instPtr->mainState == L2_INIT_STATE) ? 0x00 : 0x11;
|
||||
// TODO:
|
||||
// instPtr->linkLog.recxnCnt =
|
||||
// instPtr->linkLog.beamNo =
|
||||
// instPtr->linkLog.beamWidth =
|
||||
// instPtr->linkLog.beamAz =
|
||||
// instPtr->linkLog.beamEl =
|
||||
instPtr->linkLog.advTxCnt = (uint16_t)instPtr->log.advTxCnt;
|
||||
instPtr->linkLog.advRecvCnt = (uint16_t)instPtr->log.advRecvCnt;
|
||||
instPtr->linkLog.advCorrectCnt = (uint16_t)instPtr->log.advCorrectCnt;
|
||||
instPtr->linkLog.cfmTxCnt = instPtr->log.cfmTxCnt;
|
||||
instPtr->linkLog.cfmRecvCnt = instPtr->log.cfmRecvCnt;
|
||||
instPtr->linkLog.cfmCorrectCnt = instPtr->log.cfmCorrectCnt;
|
||||
instPtr->linkLog.svcTxCnt = instPtr->log.svcTxCnt;
|
||||
instPtr->linkLog.svcRecvCnt = instPtr->log.svcRecvCnt;
|
||||
instPtr->linkLog.svcCorrectCnt = instPtr->log.svcCorrectCnt;
|
||||
instPtr->linkLog.timeDev = instPtr->log.timeDev;
|
||||
instPtr->linkLog.sendId = instPtr->serviceFSM->txLog.dataId;
|
||||
instPtr->linkLog.recvId = instPtr->serviceFSM->rxLog.dataId;
|
||||
|
||||
SysMonitor_UpdateLinklayerLog(&(instPtr->linkLog));
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@ typedef struct
|
||||
uint32_t svcTxCnt;
|
||||
uint32_t svcRecvCnt;
|
||||
uint32_t svcCorrectCnt;
|
||||
|
||||
int64_t timeDev;
|
||||
} L2_LOG;
|
||||
|
||||
typedef struct
|
||||
@@ -90,9 +92,7 @@ typedef struct
|
||||
L2_LOG log;
|
||||
// for system log
|
||||
SYSINFO sysInfo;
|
||||
SLOTLOG txSlotLog;
|
||||
SLOTLOG rxSlotLog;
|
||||
PRTCLLOG prtcLog;
|
||||
LINKLOG linkLog;
|
||||
} L2_INST;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
@@ -166,7 +166,8 @@ L2_FRAME_TYPE L2_GetNextFrameType(L2_INST *instPtr);
|
||||
L2_TOR_TYPE L2_GetNextTor(L2_INST *instPtr);
|
||||
|
||||
// Time syncronization
|
||||
int32_t L2_TimeAlign(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative);
|
||||
int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative, int64_t* timeDev);
|
||||
void L2_TimeAdjust(L2_INST *instPtr, const int64_t *timeDev);
|
||||
|
||||
|
||||
#endif /* __LINK_LAYER_H_ */
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#include "geometry/coord.h"
|
||||
#include "geometry/quaternion.h"
|
||||
#include "../phy_layer/phy_layer.h"
|
||||
#ifndef EMULATION
|
||||
#include "../config/app_config.h"
|
||||
#endif
|
||||
/************************** Constant Definitions *****************************/
|
||||
// Common node ID definition
|
||||
#define L2_BROADCAST_ID 0xFF
|
||||
@@ -193,8 +196,8 @@ typedef struct
|
||||
bool isAckPending; // 2way acq done.
|
||||
uint8_t scanCnt;
|
||||
uint8_t beamNo;
|
||||
uint32_t advTimeout;
|
||||
uint32_t cfmTimeout;
|
||||
uint8_t advTimeout;
|
||||
uint8_t cfmTimeout;
|
||||
SCAN_STAGE scanStage; // only for member node
|
||||
} L2_SCAN_FSM;
|
||||
|
||||
@@ -210,6 +213,8 @@ typedef struct
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
uint32_t bitTotal;
|
||||
uint32_t bitError;
|
||||
double lossRate;
|
||||
double errorRate;
|
||||
#endif
|
||||
} L2_SVC_FSM;
|
||||
|
||||
|
||||
@@ -104,8 +104,10 @@
|
||||
#define L2_MSG_SVC_SRC_SPEEDY_LEN 4
|
||||
#define L2_MSG_SVC_SRC_SPEEDZ 28
|
||||
#define L2_MSG_SVC_SRC_SPEEDZ_LEN 4
|
||||
#define L2_MSG_SVC_PAYLOAD 32
|
||||
#define L2_MSG_SVC_PAYLOAD_LEN 234
|
||||
#define L2_MSG_SVC_PAYLOAD_ID 32
|
||||
#define L2_MSG_SVC_PAYLOAD_ID_LEN 4
|
||||
#define L2_MSG_SVC_PAYLOAD 36
|
||||
#define L2_MSG_SVC_PAYLOAD_LEN 230
|
||||
#define L2_MSG_SVC_CRC 266
|
||||
#define L2_MSG_SVC_CRC_LEN 2
|
||||
|
||||
|
||||
@@ -159,10 +159,10 @@ NODE_ENTRY *L2_AppendNode(NODE_LIST *list, uint8_t nodeId, L2_NODE_TYPE nodeType
|
||||
ASSERT(list != NULL);
|
||||
if (L2_isNodeInList(list, nodeId))
|
||||
{
|
||||
DBG_WARNING("Node [%d] already exist.\n", nodeId);
|
||||
DBG_WARNING("Node [%" PRIu8 "] already exist.\n", nodeId);
|
||||
return NULL;
|
||||
}
|
||||
DBG_INFO("Link layer appending node [%d] to node list.\n", nodeId);
|
||||
DBG_INFO("Link layer appending node [%" PRIu8 "] to node list.\n", nodeId);
|
||||
NODE_ENTRY *nodeEntry = (NODE_ENTRY *)malloc(sizeof(NODE_ENTRY));
|
||||
if (nodeEntry == NULL)
|
||||
{
|
||||
@@ -208,10 +208,10 @@ int32_t L2_DeleteNodeById(NODE_LIST *list, uint8_t nodeId)
|
||||
clist_node_t *node = clist_find(list, &util_entry);
|
||||
if (node == NULL)
|
||||
{
|
||||
DBG_WARNING("Node [%d] in not in node list, skip deleting process.\n", nodeId);
|
||||
DBG_WARNING("Node [%" PRIu8 "] in not in node list, skip deleting process.\n", nodeId);
|
||||
return SUCCESS;
|
||||
}
|
||||
DBG_INFO("Deleting node [%d].\n", nodeId);
|
||||
DBG_INFO("Deleting node [%" PRIu8 "].\n", nodeId);
|
||||
clist_remove(list, node);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
#include "link_layer.h"
|
||||
#include "link_layer_types.h"
|
||||
|
||||
#define LINKLAYER_INSERT_EXTRGAP
|
||||
|
||||
#ifndef LINKLAYER_INSERT_EXTRGAP
|
||||
L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
@@ -38,6 +41,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 1
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
@@ -59,6 +63,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 2
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
@@ -80,6 +85,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 3
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
@@ -122,6 +128,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
@@ -143,6 +150,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
@@ -164,6 +172,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
@@ -185,6 +194,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
@@ -206,6 +216,7 @@ L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
@@ -450,13 +461,458 @@ L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
};
|
||||
#else
|
||||
L2_RTNE_TABLE_ENTRY intraScanSubT[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD] =
|
||||
// SubFrame 1
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 2
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
|
||||
// SubFrame 3
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_SCAN, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_ADVERTISE, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 4
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0x01, 0xFF},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0x01, 0xFF},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_CONFIRM, 0x00, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x01, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x02, 0xFF, 0x01},
|
||||
{L2_SLOT_CONFIRM, 0x03, 0xFF, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
};
|
||||
|
||||
L2_RTNE_TABLE_ENTRY normalSub[L2_SLOTS_PER_FRAME] = {
|
||||
// SubFrame 0
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 1
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 2
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 3
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 4
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 5
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 6
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 7
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 8
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
|
||||
// SubFrame 9
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x01, 0x02},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x01, 0x02},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
{L2_SLOT_SERVICE, 0x00, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x01, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x02, 0x02, 0x01},
|
||||
{L2_SLOT_SERVICE, 0x03, 0x02, 0x01},
|
||||
{L2_SLOT_IDLE, 0x00, 0x00, 0x00},
|
||||
};
|
||||
#endif
|
||||
|
||||
L2_RTNE_TABLE_ENTRY *initTable[L2_INIT_RTNE_PERIOD] =
|
||||
{
|
||||
intraScanSubT
|
||||
};
|
||||
|
||||
L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD] =
|
||||
L2_RTNE_TABLE_ENTRY *normalTable[L2_NORMAL_RTNE_PERIOD] =
|
||||
{
|
||||
normalSub
|
||||
};
|
||||
@@ -53,7 +53,7 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
static inline void LockStateUpdate(L2_SCAN_FSM *scanFsmPtr, bool state)
|
||||
{
|
||||
ASSERT(scanFsmPtr != NULL);
|
||||
DBG_INFO("Update BeamLockState from [%d] to [%d].\n",
|
||||
DBG_INFO("Update BeamLockState from [%" PRId8 "] to [%" PRId8 "].\n",
|
||||
scanFsmPtr->isLocked, state);
|
||||
scanFsmPtr->isLocked = state;
|
||||
return;
|
||||
@@ -65,7 +65,7 @@ static inline void LockStateUpdate(L2_SCAN_FSM *scanFsmPtr, bool state)
|
||||
static void AdvRecvStateUpdate(L2_SCAN_FSM *scanFsmPtr, bool state)
|
||||
{
|
||||
ASSERT(scanFsmPtr != NULL);
|
||||
DBG_INFO("Update AdvRecvState from [%d] to [%d].\n",
|
||||
DBG_INFO("Update AdvRecvState from [%" PRId8 "] to [%" PRId8 "].\n",
|
||||
scanFsmPtr->isAdvRecvd, state);
|
||||
scanFsmPtr->isAdvRecvd = state;
|
||||
return;
|
||||
@@ -95,7 +95,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);
|
||||
DBG_INFO("ScanNet current stage: %u -> ScanNet new stage: %u \n",
|
||||
DBG_INFO("ScanNet current stage: %" PRIu8 " -> ScanNet new stage: %" PRIu8 " \n",
|
||||
scanFsmPtr->scanStage, newStage);
|
||||
scanFsmPtr->scanStage = newStage;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ static int32_t Scan_InitScanHandler(L2_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
DBG_INFO("** Net-Setup - InitScan Procedure (Attempts: %u)**\n", scanFsmPtr->scanCnt);
|
||||
DBG_INFO("** Net-Setup - InitScan Procedure (Attempts: %" PRIu8 ")**\n", scanFsmPtr->scanCnt);
|
||||
|
||||
if (scanFsmPtr->isLocked == true)
|
||||
{
|
||||
@@ -144,7 +144,7 @@ static int32_t Scan_InitScanHandler(L2_INST *instPtr)
|
||||
static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
{
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
DBG_INFO("** Net-Setup - Advertisement Procedure (Timeout: %u) **\n", scanFsmPtr->advTimeout);
|
||||
DBG_INFO("** Net-Setup - Advertisement Procedure (Timeout: %" PRIu8 ") **\n", scanFsmPtr->advTimeout);
|
||||
|
||||
// if received a valid bm frame.
|
||||
if (scanFsmPtr->isAdvRecvd == true)
|
||||
@@ -188,7 +188,7 @@ static int32_t Scan_AdvHandler(L2_INST *instPtr)
|
||||
static int32_t Scan_CfmHandler(L2_INST *instPtr)
|
||||
{
|
||||
L2_SCAN_FSM *scanFsmPtr = instPtr->scanFSM;
|
||||
DBG_INFO("** Net-Setup - Confirm Procedure (Timeout: %u) **\n", scanFsmPtr->cfmTimeout);
|
||||
DBG_INFO("** Net-Setup - Confirm Procedure (Timeout: %" PRIu8 ") **\n", scanFsmPtr->cfmTimeout);
|
||||
|
||||
// 2 way acq failed, back to init stage.
|
||||
if (scanFsmPtr->cfmTimeout >= CFM_LISTEN_TIMEOUT)
|
||||
@@ -225,9 +225,9 @@ 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: %d.\n", type);
|
||||
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
Status = L2_CrcAppend(buff, L2_ADV_PACK_LEN - L2_MSG_ADV_SVC_CRC_LEN, L2_MSG_ADV_SVC_CRC, L2_CRC16_1021);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Fail to append CRC, error code: %d.\n", Status);
|
||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
break;
|
||||
@@ -282,14 +282,14 @@ static int32_t ScanMsg_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
Status = L2_CrcAppend(buff, L2_CMF_PACK_LEN - L2_MSG_CFM_CRC_LEN, L2_MSG_CFM_CRC, L2_CRC16_1021);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Fail to append CRC, error code: %d.\n", Status);
|
||||
DBG_ERROR("Fail to append CRC, error code: %" PRId32 ".\n", Status);
|
||||
return Status;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DBG_ERROR("Unexpected frame type: %d.\n", type);
|
||||
DBG_ERROR("Unexpected frame type: %" PRId8 ".\n", type);
|
||||
return EPARAM;
|
||||
}
|
||||
}
|
||||
@@ -390,9 +390,9 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
if(node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %d]", nodeId);
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
@@ -409,22 +409,28 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
if (L2_isCxn2Net(instPtr) == false)
|
||||
uint32_t netstartTime;
|
||||
// Update net start time.
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_NETSTART_TIME, L2_MSG_ADV_SRC_NETSTART_TIME_LEN, &netstartTime);
|
||||
L2_EVENT netSetupDoneEvent = {
|
||||
.event = L2_EV_NET_ADV_UPDATE,
|
||||
.msg = &netstartTime};
|
||||
AssertL2Event(instPtr, &netSetupDoneEvent);
|
||||
|
||||
// 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)
|
||||
{
|
||||
uint32_t netstartTime, frameNum, slotNum = 0;
|
||||
// Update net start time.
|
||||
L2_FrameGetChunk(msg, L2_MSG_ADV_SRC_NETSTART_TIME, L2_MSG_ADV_SRC_NETSTART_TIME_LEN, &netstartTime);
|
||||
L2_EVENT netSetupDoneEvent = {
|
||||
.event = L2_EV_NET_ADV_UPDATE,
|
||||
.msg = &netstartTime};
|
||||
AssertL2Event(instPtr, &netSetupDoneEvent);
|
||||
|
||||
// Time sync.
|
||||
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);
|
||||
// TODO: Check
|
||||
L2_TimeAlign(instPtr, frameNum, slotNum, true);
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
|
||||
// trigger flag
|
||||
AdvRecvStateUpdate(scanFsmPtr, true);
|
||||
Status = SUCCESS;
|
||||
@@ -439,9 +445,9 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
if(node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %d]", nodeId);
|
||||
DBG_ERROR("Failed to append new node [id: %" PRId8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
@@ -465,6 +471,17 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
// 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")
|
||||
break;
|
||||
}
|
||||
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// check if net setup finished.
|
||||
@@ -478,7 +495,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
|
||||
// Assert update routine event...
|
||||
L2_RTNE_CONFIG newRtneConfig = {0};
|
||||
L2_EVENT rtneUpEvent =
|
||||
L2_EVENT rtneUpEvent =
|
||||
{
|
||||
.event = L2_ROUTINE_UPDATE,
|
||||
.msg = &newRtneConfig
|
||||
@@ -491,7 +508,7 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (L2_GetMainState(instPtr) == L2_INIT_STATE
|
||||
if (L2_GetMainState(instPtr) == L2_INIT_STATE
|
||||
&& L2_GetNodeListLen(instPtr->nodeList) >= instPtr->config.netScale - 1)
|
||||
{
|
||||
// Assert Net-Setup Done.
|
||||
@@ -501,12 +518,14 @@ int32_t L2_Scan_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
l2Event.msg = &newState;
|
||||
AssertL2Event(instPtr, &l2Event);
|
||||
}
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
}
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG_ERROR("Unsupported frame type: %d.\n", frameType);
|
||||
DBG_ERROR("Unsupported frame type: %" PRId8 ".\n", frameType);
|
||||
Status = EUNEXP;
|
||||
break;
|
||||
}
|
||||
@@ -550,7 +569,7 @@ int32_t L2_Scan_Proc(L2_INST *instPtr)
|
||||
Status = Scan_CfmHandler(instPtr);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Unexpected scan net stage: %d.\n", scanFSM->scanStage);
|
||||
DBG_ERROR("Unexpected scan net stage: %" PRId8 ".\n", scanFSM->scanStage);
|
||||
Status = FAILURE;
|
||||
break;
|
||||
}
|
||||
@@ -647,7 +666,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
{
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
if (instPtr->scanFSM->isAckPending == false)
|
||||
if (instPtr->scanFSM->isAckPending == false)
|
||||
{
|
||||
DBG_INFO("Member node has no pending CFM-Ack frame.\n");
|
||||
break;
|
||||
@@ -664,7 +683,7 @@ int32_t L2_Scan_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntry)
|
||||
L2_SetupNextSlot(instPtr, torState, L2_CFM_FRAME);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Cannot start a routine for slot type [%d] properly.\n", rtneEntry->slotType);
|
||||
DBG_ERROR("Cannot start a routine for slot type [%" PRId8 "] properly.\n", rtneEntry->slotType);
|
||||
Status = FAILURE;
|
||||
goto routine_err;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ L2_SCHD_EVENT *L2_CreatNewSchdEvent(L2_SCHD_POOL *schdPool, L2_EVENT_TYPE event,
|
||||
ASSERT(schdPool != NULL);
|
||||
if (event < L2_EV_SCAN_PROC_DONE || event > L2_ROUTINE_UPDATE)
|
||||
{
|
||||
DBG_ERROR("Unknown event type: %d.\n", event);
|
||||
DBG_ERROR("Unknown event type: %" PRId8 ".\n", event);
|
||||
return NULL;
|
||||
}
|
||||
L2_SCHD_EVENT *schdEvent = (L2_SCHD_EVENT *)malloc(sizeof(L2_SCHD_EVENT));
|
||||
@@ -192,7 +192,7 @@ L2_SCHD_EVENT *L2_GetEventById(L2_SCHD_POOL *schdPool, uint32_t id)
|
||||
clist_node_t *node = clist_find(schdPool->schdList, &util_schdevent);
|
||||
if (node != NULL)
|
||||
{
|
||||
DBG_WARNING("Event with id=%d, dose not exist.\n", id);
|
||||
DBG_WARNING("Event with id=%" PRIu32 ", dose not exist.\n", id);
|
||||
return NULL;
|
||||
}
|
||||
return ((L2_SCHD_EVENT *)node->val);
|
||||
@@ -217,7 +217,7 @@ int32_t L2_DeleteSchdEventById(L2_SCHD_POOL *schdPool, uint32_t id)
|
||||
clist_node_t *node = clist_find(schdPool->schdList, &util_schdevent);
|
||||
if (node != NULL)
|
||||
{
|
||||
DBG_ERROR("Event with id=%d, dose not exist.\n", id);
|
||||
DBG_ERROR("Event with id=%" PRIu32 ", dose not exist.\n", id);
|
||||
return EIGNORE;
|
||||
}
|
||||
clist_remove(schdPool->schdList, node);
|
||||
@@ -242,16 +242,16 @@ int32_t L2_ScheduleEventAt(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_t
|
||||
ASSERT(schdEvent != NULL);
|
||||
if (L2_isEventScheduled(schdEvent) == true)
|
||||
{
|
||||
DBG_ERROR("Event %d has already been scheduled.\n", schdEvent->eventId);
|
||||
DBG_ERROR("Event %" PRIu32 " has already been scheduled.\n", schdEvent->eventId);
|
||||
return FAILURE;
|
||||
}
|
||||
if (frameNum <= L2_GetCurrentFrameNum(instPtr) && slotNum < L2_GetCurrentSlotNum(instPtr))
|
||||
{
|
||||
DBG_ERROR("Cannot schedule event %d to the past(current: [%u-%u], schedule: [%u-%u]).\n",
|
||||
DBG_ERROR("Cannot schedule event %" PRIu32 " to the past(current: [%" PRIu32 "-%" PRIu32 "], schedule: [%" PRIu32 "-%" PRIu32 "]).\n",
|
||||
schdEvent->eventId, L2_GetCurrentFrameNum(instPtr), L2_GetCurrentSlotNum(instPtr), frameNum, slotNum);
|
||||
return FAILURE;
|
||||
}
|
||||
DBG_INFO("Schedule event (type:%d) [%u] at %u-%u.\n",
|
||||
DBG_INFO("Schedule event (type:%" PRIu8 ") [%" PRIu32 "] at %" PRIu32 "-%" PRIu32 ".\n",
|
||||
schdEvent->l2Event.event, schdEvent->eventId,
|
||||
frameNum, slotNum);
|
||||
schdEvent->isSchd = true;
|
||||
@@ -277,7 +277,7 @@ int32_t L2_ScheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32
|
||||
ASSERT(schdEvent != NULL);
|
||||
if (L2_isEventScheduled(schdEvent) == true)
|
||||
{
|
||||
DBG_ERROR("Event %d has already been scheduled.\n", schdEvent->eventId);
|
||||
DBG_ERROR("Event %" PRIu32 " has already been scheduled.\n", schdEvent->eventId);
|
||||
return FAILURE;
|
||||
}
|
||||
uint32_t frameNum = L2_GetCurrentFrameNum(instPtr) + (numSlots / L2_SLOTS_PER_FRAME);
|
||||
@@ -303,7 +303,7 @@ int32_t L2_RescheduleEventAt(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint32_
|
||||
ASSERT(schdEvent != NULL);
|
||||
if (schdEvent->isSchd == false)
|
||||
{
|
||||
DBG_WARNING("Event %d has not been scheduled yet.\n", schdEvent->eventId);
|
||||
DBG_WARNING("Event %" PRIu32 " has not been scheduled yet.\n", schdEvent->eventId);
|
||||
}
|
||||
schdEvent->isSchd = false;
|
||||
return L2_ScheduleEventAt(instPtr, schdEvent, frameNum, slotNum);
|
||||
@@ -326,7 +326,7 @@ int32_t L2_RescheduleEventAfter(L2_INST *instPtr, L2_SCHD_EVENT *schdEvent, uint
|
||||
ASSERT(schdEvent != NULL);
|
||||
if (schdEvent->isSchd == false)
|
||||
{
|
||||
DBG_WARNING("Event %d has not been scheduled yet.\n", schdEvent->eventId);
|
||||
DBG_WARNING("Event %" PRIu32 " has not been scheduled yet.\n", schdEvent->eventId);
|
||||
}
|
||||
return L2_ScheduleEventAfter(instPtr, schdEvent, numSlots);
|
||||
}
|
||||
@@ -359,11 +359,11 @@ void L2_EventPoolHandler(L2_INST *instPtr)
|
||||
{
|
||||
if (event->schdFrame == L2_GetCurrentFrameNum(instPtr) && event->schdSlot == L2_GetCurrentSlotNum(instPtr))
|
||||
{
|
||||
DBG_INFO("Asserting scheduled event [%d].\n", event->eventId);
|
||||
DBG_INFO("Asserting scheduled event [%" PRIu32 "].\n", event->eventId);
|
||||
AssertL2Event(instPtr, &(event->l2Event));
|
||||
if (event->isVolatile == true)
|
||||
{
|
||||
DBG_INFO("Deleting scheduled event [%d], since it is volatile.\n", event->eventId);
|
||||
DBG_INFO("Deleting scheduled event [%" PRIu32 "], since it is volatile.\n", event->eventId);
|
||||
clist_remove(pool->schdList, node);
|
||||
}
|
||||
else
|
||||
@@ -407,7 +407,7 @@ inline int32_t L2_CancelEvent(L2_SCHD_EVENT *schdEvent)
|
||||
ASSERT(schdEvent != NULL);
|
||||
if (schdEvent->isSchd == false)
|
||||
{
|
||||
DBG_WARNING("Event %d has not been scheduled yet.\n", schdEvent->eventId);
|
||||
DBG_WARNING("Event %" PRIu32 " has not been scheduled yet.\n", schdEvent->eventId);
|
||||
}
|
||||
schdEvent->isSchd = false;
|
||||
return SUCCESS;
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "error.h"
|
||||
#include "common.h"
|
||||
#include "circ_queue.h"
|
||||
#ifndef EMULATION
|
||||
#ifndef EMULATION
|
||||
#include "../config/app_config.h"
|
||||
#endif
|
||||
/************************** Constant Definitions *****************************/
|
||||
@@ -32,39 +32,39 @@
|
||||
static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dstId);
|
||||
/************************** Variable Definitions *****************************/
|
||||
|
||||
static uint8_t testData[L2_PACK_LEN_MAX] =
|
||||
static uint8_t testData[L2_PACK_LEN_MAX] =
|
||||
{
|
||||
0x39, 0x85, 0x02, 0xF0, 0xC7, 0x6A, 0xE8, 0xB4, 0xE7, 0xAB, 0xC9, 0xDC, 0x0B, 0x41, 0x42, 0xE0,
|
||||
0xED, 0x21, 0x07, 0x62, 0x4E, 0x80, 0xA0, 0xE1, 0xAC, 0x77, 0x9B, 0x1F, 0x48, 0x0B, 0x58, 0xB9,
|
||||
0x45, 0xA5, 0x24, 0xEF, 0xF3, 0x71, 0x2E, 0x84, 0x6C, 0x22, 0xB3, 0x05, 0xEB, 0x75, 0xF2, 0x0B,
|
||||
0x45, 0x73, 0x01, 0xA8, 0x1E, 0x00, 0x21, 0x3E, 0x03, 0x86, 0x55, 0x59, 0x98, 0x5C, 0x61, 0xA2,
|
||||
0xE8, 0x20, 0x0E, 0x7A, 0xD5, 0x72, 0xAF, 0xF4, 0xBC, 0xB3, 0x6F, 0xFE, 0xB3, 0x78, 0x6A, 0x59,
|
||||
0x73, 0xBD, 0x97, 0xBE, 0x44, 0xA4, 0x9B, 0x71, 0x11, 0x45, 0x37, 0xFE, 0xB3, 0x71, 0xEF, 0x1E,
|
||||
0x3A, 0x2B, 0x58, 0x07, 0xF6, 0x01, 0x1C, 0x73, 0x28, 0x11, 0xA8, 0x15, 0xA2, 0x58, 0x32, 0x2E,
|
||||
0x7D, 0x35, 0x9C, 0xE4, 0x98, 0x7F, 0x9C, 0x81, 0x32, 0xAA, 0xC4, 0x87, 0x16, 0x26, 0x23, 0x95,
|
||||
0x57, 0xC9, 0xD4, 0x34, 0xCE, 0x63, 0x78, 0x7E, 0xD4, 0x3C, 0x16, 0x1D, 0x80, 0xC0, 0x55, 0xBF,
|
||||
0xB5, 0xD6, 0x0C, 0xA5, 0xB9, 0x0A, 0x14, 0x5B, 0x4D, 0x52, 0xF2, 0xA9, 0x7A, 0x08, 0x67, 0x8E,
|
||||
0xEB, 0x67, 0x34, 0x7F, 0x7A, 0x35, 0xAF, 0xD9, 0x07, 0x52, 0x30, 0x38, 0x70, 0xC9, 0x41, 0xF8,
|
||||
0x36, 0x61, 0x32, 0x72, 0xA4, 0x7A, 0xEA, 0x21, 0xB4, 0xBF, 0xAA, 0xCF, 0x93, 0x4F, 0xE1, 0x5C,
|
||||
0xA0, 0xFB, 0xD0, 0x2B, 0xA3, 0x82, 0x2E, 0x69, 0x7D, 0xB7, 0x76, 0x88, 0xF7, 0x5C, 0xF3, 0x82,
|
||||
0xC6, 0x6D, 0x49, 0x92, 0x64, 0x88, 0x9A, 0x43, 0xEE, 0xE9, 0x93, 0xC3, 0x70, 0x50, 0x22, 0xF1,
|
||||
0xD3, 0x2B, 0xCF, 0xA9, 0xE5, 0x69, 0x22, 0xF9, 0xBF, 0x78, 0x9A, 0xA4, 0x5A, 0x3D, 0x2E, 0x2A,
|
||||
0x23, 0xE3, 0x51, 0x8F, 0x1A, 0xC1, 0xAF, 0x47, 0x9C, 0x14, 0xCE, 0xB9, 0xCD, 0xD0, 0x02, 0xB7,
|
||||
0xB8, 0x81, 0xCC, 0x44, 0xE7, 0xA2, 0x6F, 0x32, 0x8C, 0x78, 0x79, 0x10, 0xF3, 0xE1, 0xB0, 0x7C,
|
||||
0xAB, 0x40, 0xDB, 0xF9, 0x99, 0xE7, 0x27, 0x30, 0x53, 0x67, 0x00, 0xE8, 0x33, 0x6D, 0xFC, 0x4D,
|
||||
0xDC, 0xB0, 0xFC, 0x3D, 0xEF, 0x8D, 0x43, 0xAF, 0x7E, 0x41, 0x69, 0xDA, 0xFD, 0xDF, 0x2F, 0xF8,
|
||||
0xEC, 0xFB, 0x6A, 0x65, 0xE7, 0xEC, 0xC7, 0x53, 0x1B, 0x14, 0xDF, 0xBD, 0x0C, 0x54, 0x57, 0xD2,
|
||||
0x56, 0x15, 0xF4, 0x34, 0xE2, 0xFB, 0x12, 0xA0, 0xA2, 0xDE, 0x82, 0xF5, 0x04, 0x81, 0x9B, 0x08,
|
||||
0xB6, 0x8C, 0x7B, 0xE0, 0xAA, 0xDF, 0xC9, 0x92, 0x9D, 0x5F, 0x2D, 0xF7, 0x4A, 0x0B, 0xFF, 0xA5,
|
||||
0xAA, 0xDC, 0xD6, 0x3F, 0x56, 0xB2, 0x6A, 0x3C, 0x6F, 0xAA, 0xAC, 0x84, 0xAC, 0x3F, 0x3D, 0x05,
|
||||
0x96, 0x12, 0x44, 0x39, 0x1C, 0xD1, 0xFA, 0xBE, 0x6B, 0x1A, 0xCD, 0x31, 0x29, 0x41, 0x31, 0xA3,
|
||||
0xA8, 0x0D, 0x87, 0xEB, 0x96, 0x21, 0x39, 0xD6, 0x3B, 0x11, 0x50, 0xB5, 0xFE, 0x44, 0x0E, 0x74,
|
||||
0x31, 0x12, 0xA1, 0x66, 0x49, 0xFD, 0x2D, 0x75, 0x72, 0xF9, 0xC8, 0xD9, 0x6C, 0xC9, 0x11, 0x74,
|
||||
0x2E, 0xEB, 0x20, 0x33, 0x3D, 0x2C, 0x5E, 0xEA, 0x39, 0x31, 0x88, 0xC7, 0xD1, 0x93, 0x95, 0xD8,
|
||||
0x9E, 0x87, 0x93, 0xBC, 0x09, 0x17, 0xC9, 0xA2, 0x59, 0x18, 0x51, 0x8F, 0xBF, 0x55, 0x45, 0x81,
|
||||
0x8D, 0xFD, 0xAF, 0xB2, 0x21, 0xB7, 0xD8, 0xA8, 0x00, 0x2E, 0x70, 0x73, 0x2F, 0x74, 0xBC, 0x61,
|
||||
0x0A, 0x8E, 0xE3, 0x0A, 0x92, 0x82, 0xD2, 0x82, 0xBA, 0xE4, 0x3E, 0x8E, 0xBB, 0xC7, 0xA2, 0x8F,
|
||||
0x68, 0xE1, 0x29, 0x34, 0x7C, 0xB4, 0x22, 0xCF, 0x36, 0x8F, 0x9D, 0x63, 0x9D, 0x04, 0x8F, 0x4A,
|
||||
0x39, 0x85, 0x02, 0xF0, 0xC7, 0x6A, 0xE8, 0xB4, 0xE7, 0xAB, 0xC9, 0xDC, 0x0B, 0x41, 0x42, 0xE0,
|
||||
0xED, 0x21, 0x07, 0x62, 0x4E, 0x80, 0xA0, 0xE1, 0xAC, 0x77, 0x9B, 0x1F, 0x48, 0x0B, 0x58, 0xB9,
|
||||
0x45, 0xA5, 0x24, 0xEF, 0xF3, 0x71, 0x2E, 0x84, 0x6C, 0x22, 0xB3, 0x05, 0xEB, 0x75, 0xF2, 0x0B,
|
||||
0x45, 0x73, 0x01, 0xA8, 0x1E, 0x00, 0x21, 0x3E, 0x03, 0x86, 0x55, 0x59, 0x98, 0x5C, 0x61, 0xA2,
|
||||
0xE8, 0x20, 0x0E, 0x7A, 0xD5, 0x72, 0xAF, 0xF4, 0xBC, 0xB3, 0x6F, 0xFE, 0xB3, 0x78, 0x6A, 0x59,
|
||||
0x73, 0xBD, 0x97, 0xBE, 0x44, 0xA4, 0x9B, 0x71, 0x11, 0x45, 0x37, 0xFE, 0xB3, 0x71, 0xEF, 0x1E,
|
||||
0x3A, 0x2B, 0x58, 0x07, 0xF6, 0x01, 0x1C, 0x73, 0x28, 0x11, 0xA8, 0x15, 0xA2, 0x58, 0x32, 0x2E,
|
||||
0x7D, 0x35, 0x9C, 0xE4, 0x98, 0x7F, 0x9C, 0x81, 0x32, 0xAA, 0xC4, 0x87, 0x16, 0x26, 0x23, 0x95,
|
||||
0x57, 0xC9, 0xD4, 0x34, 0xCE, 0x63, 0x78, 0x7E, 0xD4, 0x3C, 0x16, 0x1D, 0x80, 0xC0, 0x55, 0xBF,
|
||||
0xB5, 0xD6, 0x0C, 0xA5, 0xB9, 0x0A, 0x14, 0x5B, 0x4D, 0x52, 0xF2, 0xA9, 0x7A, 0x08, 0x67, 0x8E,
|
||||
0xEB, 0x67, 0x34, 0x7F, 0x7A, 0x35, 0xAF, 0xD9, 0x07, 0x52, 0x30, 0x38, 0x70, 0xC9, 0x41, 0xF8,
|
||||
0x36, 0x61, 0x32, 0x72, 0xA4, 0x7A, 0xEA, 0x21, 0xB4, 0xBF, 0xAA, 0xCF, 0x93, 0x4F, 0xE1, 0x5C,
|
||||
0xA0, 0xFB, 0xD0, 0x2B, 0xA3, 0x82, 0x2E, 0x69, 0x7D, 0xB7, 0x76, 0x88, 0xF7, 0x5C, 0xF3, 0x82,
|
||||
0xC6, 0x6D, 0x49, 0x92, 0x64, 0x88, 0x9A, 0x43, 0xEE, 0xE9, 0x93, 0xC3, 0x70, 0x50, 0x22, 0xF1,
|
||||
0xD3, 0x2B, 0xCF, 0xA9, 0xE5, 0x69, 0x22, 0xF9, 0xBF, 0x78, 0x9A, 0xA4, 0x5A, 0x3D, 0x2E, 0x2A,
|
||||
0x23, 0xE3, 0x51, 0x8F, 0x1A, 0xC1, 0xAF, 0x47, 0x9C, 0x14, 0xCE, 0xB9, 0xCD, 0xD0, 0x02, 0xB7,
|
||||
0xB8, 0x81, 0xCC, 0x44, 0xE7, 0xA2, 0x6F, 0x32, 0x8C, 0x78, 0x79, 0x10, 0xF3, 0xE1, 0xB0, 0x7C,
|
||||
0xAB, 0x40, 0xDB, 0xF9, 0x99, 0xE7, 0x27, 0x30, 0x53, 0x67, 0x00, 0xE8, 0x33, 0x6D, 0xFC, 0x4D,
|
||||
0xDC, 0xB0, 0xFC, 0x3D, 0xEF, 0x8D, 0x43, 0xAF, 0x7E, 0x41, 0x69, 0xDA, 0xFD, 0xDF, 0x2F, 0xF8,
|
||||
0xEC, 0xFB, 0x6A, 0x65, 0xE7, 0xEC, 0xC7, 0x53, 0x1B, 0x14, 0xDF, 0xBD, 0x0C, 0x54, 0x57, 0xD2,
|
||||
0x56, 0x15, 0xF4, 0x34, 0xE2, 0xFB, 0x12, 0xA0, 0xA2, 0xDE, 0x82, 0xF5, 0x04, 0x81, 0x9B, 0x08,
|
||||
0xB6, 0x8C, 0x7B, 0xE0, 0xAA, 0xDF, 0xC9, 0x92, 0x9D, 0x5F, 0x2D, 0xF7, 0x4A, 0x0B, 0xFF, 0xA5,
|
||||
0xAA, 0xDC, 0xD6, 0x3F, 0x56, 0xB2, 0x6A, 0x3C, 0x6F, 0xAA, 0xAC, 0x84, 0xAC, 0x3F, 0x3D, 0x05,
|
||||
0x96, 0x12, 0x44, 0x39, 0x1C, 0xD1, 0xFA, 0xBE, 0x6B, 0x1A, 0xCD, 0x31, 0x29, 0x41, 0x31, 0xA3,
|
||||
0xA8, 0x0D, 0x87, 0xEB, 0x96, 0x21, 0x39, 0xD6, 0x3B, 0x11, 0x50, 0xB5, 0xFE, 0x44, 0x0E, 0x74,
|
||||
0x31, 0x12, 0xA1, 0x66, 0x49, 0xFD, 0x2D, 0x75, 0x72, 0xF9, 0xC8, 0xD9, 0x6C, 0xC9, 0x11, 0x74,
|
||||
0x2E, 0xEB, 0x20, 0x33, 0x3D, 0x2C, 0x5E, 0xEA, 0x39, 0x31, 0x88, 0xC7, 0xD1, 0x93, 0x95, 0xD8,
|
||||
0x9E, 0x87, 0x93, 0xBC, 0x09, 0x17, 0xC9, 0xA2, 0x59, 0x18, 0x51, 0x8F, 0xBF, 0x55, 0x45, 0x81,
|
||||
0x8D, 0xFD, 0xAF, 0xB2, 0x21, 0xB7, 0xD8, 0xA8, 0x00, 0x2E, 0x70, 0x73, 0x2F, 0x74, 0xBC, 0x61,
|
||||
0x0A, 0x8E, 0xE3, 0x0A, 0x92, 0x82, 0xD2, 0x82, 0xBA, 0xE4, 0x3E, 0x8E, 0xBB, 0xC7, 0xA2, 0x8F,
|
||||
0x68, 0xE1, 0x29, 0x34, 0x7C, 0xB4, 0x22, 0xCF, 0x36, 0x8F, 0x9D, 0x63, 0x9D, 0x04, 0x8F, 0x4A,
|
||||
0xFB, 0x84, 0xBB, 0x6B, 0x97, 0x2C, 0x15, 0xC9, 0x37, 0x4F, 0x40, 0xD7, 0x47, 0x50, 0x39, 0x97
|
||||
};
|
||||
|
||||
@@ -112,17 +112,28 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_SRC_SPEEDY, L2_MSG_SVC_SRC_SPEEDY_LEN, &(instPtr->sysInfo.vY));
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_SRC_SPEEDZ, L2_MSG_SVC_SRC_SPEEDZ_LEN, &(instPtr->sysInfo.vZ));
|
||||
|
||||
// packing payload
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD, L2_MSG_SVC_PAYLOAD_LEN, testData);
|
||||
uint32_t dataId;
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_SVC_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_GetSendPayload(buff + L2_MSG_SVC_PAYLOAD, &dataId, PAYLOAD_LEN_LJ_TX);
|
||||
}
|
||||
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
|
||||
if (dataId == DATA_ID_NONE)
|
||||
{
|
||||
L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD, L2_MSG_SVC_PAYLOAD_LEN, testData);
|
||||
}
|
||||
|
||||
// // packing payload
|
||||
// uint32_t dataId;
|
||||
// dataId = DATA_ID_TEST;
|
||||
// L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
|
||||
// L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD, L2_MSG_SVC_PAYLOAD_LEN, testData);
|
||||
|
||||
// if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
// {
|
||||
// SysMonitor_GetSendPayloadLJRaw(buff+L2_MSG_SVC_PAYLOAD);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// SysMonitor_GetSendPayloadFLJRaw(buff+L2_MSG_SVC_PAYLOAD);
|
||||
// }
|
||||
|
||||
Status = L2_CrcAppend(buff, L2_SVC_PACK_LEN - L2_MSG_SVC_CRC_LEN, L2_MSG_SVC_CRC, L2_CRC16_1021);
|
||||
if (Status != SUCCESS)
|
||||
@@ -130,11 +141,14 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
|
||||
DBG_ERROR("Fail to append CRC...\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
memcpy(instPtr->serviceFSM->txLog.data, buff, L2_SVC_PACK_LEN);
|
||||
instPtr->serviceFSM->txLog.dataId = dataId;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
DBG_ERROR("Unexpected frame type: %d.\n", type);
|
||||
DBG_ERROR("Unexpected frame type: %" PRIu8 ".\n", type);
|
||||
return EPARAM;
|
||||
break;
|
||||
}
|
||||
@@ -216,8 +230,8 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(msg != NULL);
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
int32_t Status;
|
||||
#ifndef DATALINK_ENABLE_BERTEST
|
||||
uint8_t frameType;
|
||||
L2_FrameGetChunk(msg, L2_MSG_TYPE, L2_MSG_TYPE_LEN, &frameType);
|
||||
switch (frameType)
|
||||
@@ -231,9 +245,9 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
if (node == NULL)
|
||||
{
|
||||
node = L2_AppendNode(instPtr->nodeList, nodeId, L2_NODE_MEMBER);
|
||||
if(node == NULL)
|
||||
if(node == NULL)
|
||||
{
|
||||
DBG_ERROR("Failed to append new node [id: %d]", nodeId);
|
||||
DBG_ERROR("Failed to append new node [id: %" PRIu8 "]", nodeId);
|
||||
Status = ENOMEM;
|
||||
break;
|
||||
}
|
||||
@@ -258,49 +272,78 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
|
||||
// Reset node ttl
|
||||
node->ttlCnt = 0;
|
||||
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
// 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)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayloadLJRaw(msg+L2_MSG_SVC_PAYLOAD);
|
||||
DBG_ERROR("Failed to compute time deviation.\n")
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
||||
uint32_t dataId;
|
||||
L2_FrameGetChunk(msg, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
|
||||
|
||||
if(dataId != DATA_ID_NONE)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayloadFLJRaw(msg+L2_MSG_SVC_PAYLOAD);
|
||||
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_FLJ_RX);
|
||||
}
|
||||
else
|
||||
{
|
||||
SysMonitor_UpdateRecvPayload(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_LJ_RX);
|
||||
}
|
||||
}
|
||||
|
||||
// Logging
|
||||
memcpy(instPtr->serviceFSM->rxLog.data, msg, L2_SVC_PACK_LEN);
|
||||
instPtr->serviceFSM->rxLog.dataId = dataId;
|
||||
|
||||
#ifdef DATALINK_ENABLE_AUTOTIMESYNC
|
||||
// Implement a auto time sync.
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
uint32_t frameNum, slotNum;
|
||||
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);
|
||||
L2_TimeAlign(instPtr, frameNum, slotNum, true);
|
||||
// Time sync.
|
||||
L2_TimeAdjust(instPtr, &(instPtr->log.timeDev));
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DBG_ERROR("Unsupported frame type: %d.\n", instPtr->frame.last);
|
||||
DBG_ERROR("Unsupported frame type: %" PRIu8 ".\n", frameType);
|
||||
break;
|
||||
}
|
||||
return Status;
|
||||
#else
|
||||
#else
|
||||
uint32_t errorBits = 0;
|
||||
for (int i = 0; i < SVC_PACK_LEN; i++)
|
||||
for (int i = 0; i < L2_SVC_PACK_LEN; i++)
|
||||
{
|
||||
errorBits += count_ones(msg[i] ^ testData[i]);
|
||||
}
|
||||
|
||||
instPtr->serviceFsm.bitError += errorBits;
|
||||
instPtr->serviceFsm.bitTotal += SVC_PACK_LEN * 8;
|
||||
instPtr->serviceFSM->bitError += errorBits;
|
||||
instPtr->serviceFSM->bitTotal += L2_SVC_PACK_LEN * 8;
|
||||
|
||||
// Implement a auto time sync.
|
||||
if (L2_GetNodeType(instPtr) != L2_NODE_HEAD)
|
||||
// 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)
|
||||
{
|
||||
uint32_t frameNum, slotNum;
|
||||
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);
|
||||
L2_TimeAlign(instPtr, frameNum, slotNum, true);
|
||||
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
|
||||
}
|
||||
|
||||
@@ -318,6 +361,12 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
DBG_INFO("-------- ServiceNet Routine --------\n");
|
||||
|
||||
if (rtneEntry->slotSeq != 0)
|
||||
{
|
||||
return SUCCESS; // skip
|
||||
}
|
||||
|
||||
PHY_INST* phyRef = instPtr->config.phyInstPtr;
|
||||
L2_TOR_TYPE torState;
|
||||
if (rtneEntry->src == L2_GetNodeId(instPtr))
|
||||
@@ -342,7 +391,7 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
// Packing service data
|
||||
Service_Packing(instPtr, L2_SVC_FRAME, rtneEntry->dst);
|
||||
#else
|
||||
memcpy(instPtr->sendPktData, testData, SVC_PACK_LEN);
|
||||
memcpy(instPtr->sendPktData, testData, L2_SVC_PACK_LEN);
|
||||
#endif
|
||||
}
|
||||
// FIXME: Steer antenna to point to destination.
|
||||
@@ -351,17 +400,16 @@ int32_t L2_Service_Routine(L2_INST *instPtr, const L2_RTNE_TABLE_ENTRY *rtneEntr
|
||||
L2_SetupNextSlot(instPtr, torState, L2_SVC_FRAME);
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("UNKNOWN slot type [%d].\n", rtneEntry->slotType);
|
||||
DBG_ERROR("UNKNOWN slot type [%" PRIu8 "].\n", rtneEntry->slotType);
|
||||
return FAILURE;
|
||||
}
|
||||
#ifdef DATALINK_ENABLE_BERTEST
|
||||
uint32_t pktLoss;
|
||||
double errorRate, lossRate;
|
||||
pktLoss = instPtr->log.svcRecvCnt - instPtr->log.svcCorrectCnt;
|
||||
lossRate = (instPtr->log.svcRecvCnt == 0) ? 0 : (double)pktLoss / (double)instPtr->serviceFsm.pktRecv;
|
||||
errorRate = (instPtr->serviceFsm.bitTotal == 0) ? 0 : (double)instPtr->serviceFsm.bitError / (double)instPtr->serviceFsm.bitTotal;
|
||||
DBG_PRINT("Packet Loss Rate -- Total: %lu, Loss: %lu.\n", instPtr->serviceFsm.pktRecv, pktLoss);
|
||||
DBG_PRINT("Bit Error Rate -- Total:%lu, Error:%lu.\n", instPtr->serviceFsm.bitTotal, instPtr->serviceFsm.bitError);
|
||||
instPtr->serviceFSM->lossRate = (instPtr->log.svcRecvCnt == 0) ? 0 : (double)pktLoss / (double)instPtr->serviceFSM->pktRecv;
|
||||
instPtr->serviceFSM->errorRate = (instPtr->serviceFSM->bitTotal == 0) ? 0 : (double)instPtr->serviceFSM->bitError / (double)instPtr->serviceFSM->bitTotal;
|
||||
DBG_PRINT("Packet Loss Rate -- Total: %lu, Loss: %lu.\n", instPtr->serviceFSM->pktRecv, pktLoss);
|
||||
DBG_PRINT("Bit Error Rate -- Total:%lu, Error:%lu.\n", instPtr->serviceFSM->bitTotal, instPtr->serviceFSM->bitError);
|
||||
#endif
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -32,20 +32,22 @@
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief a slot alignment, base on physical layer information.
|
||||
* @brief Get time deviation to the specified frame and slot number.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer layer instance
|
||||
* @param frameNum
|
||||
* @param slotNum
|
||||
* @param relative
|
||||
* @param timeDev
|
||||
*
|
||||
* @return SUCCESS Initialize successfully.
|
||||
* FAILURE Initialization failed, allocate memory fail or initial
|
||||
* bram controller fail.
|
||||
* @return SUCCESS
|
||||
* EIGNORE there is no received frame
|
||||
*
|
||||
******************************************************************************/
|
||||
// TODO: Check
|
||||
int32_t L2_TimeAlign(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative)
|
||||
int32_t L2_GetTimeDeviation(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool relative, int64_t *timeDev)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(timeDev != NULL);
|
||||
L1_FRAME_TYPE lastRecvdFrame;
|
||||
lastRecvdFrame = Phy_GetLastRecvFrameType(instPtr->config.phyInstPtr);
|
||||
if (lastRecvdFrame == L1_NONE_FRAME)
|
||||
@@ -57,8 +59,7 @@ int32_t L2_TimeAlign(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool
|
||||
DBG_INFO("Starting TimeAlign operation...\n");
|
||||
// read nextSendTime from physical layer
|
||||
uint64_t currTime, expectTime;
|
||||
int64_t timeDiff;
|
||||
TIME_WORD timeStamp, slotTimerAdjmet;
|
||||
TIME_WORD timeStamp;
|
||||
expectTime = ((uint64_t)(frameNum * L2_SLOTS_PER_FRAME + slotNum)) * TIME_FRAC_MAX;
|
||||
expectTime += Phy_GetTimeComp(lastRecvdFrame);
|
||||
|
||||
@@ -71,10 +72,27 @@ int32_t L2_TimeAlign(L2_INST *instPtr, uint32_t frameNum, uint32_t slotNum, bool
|
||||
currTime = (uint64_t)timeStamp.frac_part;
|
||||
currTime += ((uint64_t)timeStamp.int_part) * TIME_FRAC_MAX;
|
||||
|
||||
timeDiff = (int64_t)(expectTime - currTime);
|
||||
|
||||
slotTimerAdjmet.int_part = (uint32_t)(timeDiff / TIME_FRAC_MAX);
|
||||
slotTimerAdjmet.frac_part = (uint32_t)(timeDiff % TIME_FRAC_MAX);
|
||||
TimeCtrl_TimeAdjust(instPtr->config.tmcInstPtr, &slotTimerAdjmet, TM_ADJ_ADD);
|
||||
*timeDev = (int64_t)(expectTime - currTime);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief Implement time adjustment by applying time deviation.
|
||||
*
|
||||
* @param instPtr a pointer to linklayer layer instance
|
||||
* @param timeDev
|
||||
*
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void L2_TimeAdjust(L2_INST *instPtr, const int64_t *timeDev)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
ASSERT(timeDev != NULL);
|
||||
TIME_WORD slotTimerAdjmet;
|
||||
slotTimerAdjmet.int_part = (uint32_t)(*timeDev / TIME_FRAC_MAX);
|
||||
slotTimerAdjmet.frac_part = (uint32_t)(*timeDev % TIME_FRAC_MAX);
|
||||
TimeCtrl_TimeAdjust(instPtr->config.tmcInstPtr, &slotTimerAdjmet, TM_ADJ_ADD);
|
||||
}
|
||||
@@ -35,9 +35,9 @@
|
||||
#define ANT_MODE_WIDE_BEAM_3 0x30 // 120
|
||||
|
||||
#define ANT_MODE_HIGH_POWER 0x00
|
||||
#define ANT_MODE_LOWAPOWER 0x04
|
||||
#define ANT_MODE_LOW_POWER 0x04
|
||||
#define ANT_MODE_STANDBY 0x0F
|
||||
#define ATN_MODE_DEFAULT (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_LOWAPOWER)
|
||||
#define ATN_MODE_DEFAULT (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_LOW_POWER)
|
||||
#define ATN_MODE_HIGH (ANT_MODE_WIDE_BEAM_1 | ANT_MODE_HIGH_POWER)
|
||||
|
||||
#define DEFAULT_CENTRTAL_FREQ 0x06D7 // 26.25GHz
|
||||
@@ -86,21 +86,17 @@ uint16_t hopPattern_10KBPS_10MS[L1_FRAME_10KBPS_10MS_HOPS] =
|
||||
|
||||
uint16_t hopPattern_10KBPS_20MS[L1_FRAME_10KBPS_20MS_HOPS] =
|
||||
{
|
||||
1500, 1600, 1700, 1800, 1900, 2000, 1500, 1600,
|
||||
1700, 1800, 1900
|
||||
1500
|
||||
};
|
||||
|
||||
uint16_t hopPattern_40KBPS_10MS[L1_FRAME_40KBPS_10MS_HOPS] =
|
||||
{
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
2400
|
||||
1600
|
||||
};
|
||||
|
||||
uint16_t hopPattern_40KBPS_20MS[L1_FRAME_40KBPS_20MS_HOPS] =
|
||||
{
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
2400, 2400, 2400, 2400, 2400, 2400, 2400, 2400,
|
||||
2400, 2400, 2400
|
||||
1600
|
||||
};
|
||||
|
||||
uint16_t hopPattern_200KBPS_5MS[L1_FRAME_200KBPS_5MS_HOPS] =
|
||||
@@ -246,8 +242,31 @@ void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig)
|
||||
// ***********************
|
||||
}
|
||||
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint8_t config = instPtr->antConfig.antMode & ANT_MODE_BEAM_MASK;
|
||||
switch (mode)
|
||||
{
|
||||
case PHY_ANT_MODE_SILENT:
|
||||
config |= ANT_MODE_STANDBY;
|
||||
break;
|
||||
case PHY_ANT_MODE_LOW_POWER:
|
||||
config |= ANT_MODE_LOW_POWER;
|
||||
break;
|
||||
case PHY_ANT_MODE_HIGH_POWER:
|
||||
config |= ANT_MODE_HIGH_POWER;
|
||||
break;
|
||||
default:
|
||||
DBG_ERROR("Unknown antenna mode: %" PRIu8 ", remain previous mode.\n", mode);
|
||||
return;
|
||||
}
|
||||
instPtr->antConfig.antMode = config;
|
||||
}
|
||||
|
||||
int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
if (instPtr->beamWd.next == PHY_ANT_BEAM_8)
|
||||
{
|
||||
if (beamNo >= L1_NUM_ANT_NRRW_PATTERN)
|
||||
@@ -296,6 +315,7 @@ int32_t Phy_SetBeamNo(PHY_INST *instPtr, int32_t beamNo)
|
||||
|
||||
int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint8_t beamConfig = instPtr->antConfig.antMode & (~ANT_MODE_BEAM_MASK);
|
||||
switch (beamWidth)
|
||||
{
|
||||
@@ -324,13 +344,14 @@ int32_t Phy_SetBeamWidth(PHY_INST *instPtr, PHY_ANT_BEAM_WIDTH beamWidth)
|
||||
// Common version radius double input
|
||||
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);
|
||||
if (offAxDeg > 60)
|
||||
{
|
||||
DBG_ERROR("Angle out of range, off axis angle: %u (should be 0~60), round axis angle: %u (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",
|
||||
offAxDeg, rndAxDeg);
|
||||
return EPARAM;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,29 @@
|
||||
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
#define TOR_BUFF_MAX_SIZE 1024 // 8192bits
|
||||
#define L1_FRAME_LEN_MAX (8192 / 8) // byte
|
||||
#define L1_FRAME_2KBPS_20MS_LEN 0 // byte
|
||||
#define L1_FRAME_2KBPS_100MS_LEN (312 / 8) // byte
|
||||
#define L1_FRAME_10KBPS_10MS_LEN 0 // 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 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 111485 // *10ns(Timer_L)
|
||||
#define L1_FRAME_40KBPS_10MS_COMP 111485 // *10ns(Timer_L)
|
||||
#define L1_FRAME_200KBPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
#define L1_FRAME_1M2BPS_5MS_COMP 22493 // *10ns(Timer_L)
|
||||
|
||||
#define L1_ANTCONFIG_MAX_LEN 8192
|
||||
#define L1_TXRXDATA_MAX_LEN 2048
|
||||
|
||||
#define ANT_COINFO_LEN 32 // bytes
|
||||
#define ANTCONFIG_MAX_LEN (8192 / 2)
|
||||
#define PAYLOAD_MAX_LEN (4096 / 2)
|
||||
|
||||
/***************** Macros (Inline Functions) Definitions *********************/
|
||||
/************************** Function Prototypes ******************************/
|
||||
@@ -292,6 +311,28 @@ void Phy_UpdateState(PHY_INST *instPtr)
|
||||
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);
|
||||
|
||||
instPtr->phyLog.acqCnt = PhyRead(instPtr, PHY_ACQ_CNT);
|
||||
instPtr->phyLog.fsyncCnt = PhyRead(instPtr, PHY_FRAME_SYNC_CNT);
|
||||
instPtr->phyLog.decodeCnt = PhyRead(instPtr, PHY_DECODE_CNT);
|
||||
instPtr->phyLog.crcCnt = PhyRead(instPtr, PHY_CRC_OK_CNT);
|
||||
instPtr->phyLog.doppler = Phy_GetFreqEst(instPtr);
|
||||
instPtr->phyLog.recvStamp = (uint64_t)instPtr->recvFsTime.int_part * TIME_FRAC_MAX + instPtr->recvFsTime.frac_part;
|
||||
instPtr->phyLog.acqPeak = PhyRead(instPtr, PHY_ACQ_PEAK_L);
|
||||
instPtr->phyLog.acqPeak |= ((uint64_t)PhyRead(instPtr, PHY_ACQ_PEAK_H)) << 32;
|
||||
instPtr->phyLog.acqMean = PhyRead(instPtr, PHY_ACQ_MEAN_L);
|
||||
instPtr->phyLog.acqMean |= ((uint64_t)PhyRead(instPtr, PHY_ACQ_MEAN_H)) << 32;
|
||||
instPtr->phyLog.acqPhase = (PhyRead(instPtr, PHY_ACQ_FREQEST) & PHY_ACQ_FREQEST_PHASE_MASK) >> PHY_ACQ_FREQEST_PHASE_SHIFT;
|
||||
instPtr->phyLog.acqFreqCh = (PhyRead(instPtr, PHY_ACQ_FREQEST) & PHY_ACQ_FREQEST_CHANNEL_MASK) >> PHY_ACQ_FREQEST_CHANNEL_SHIFT;
|
||||
instPtr->phyLog.fsyncPeak = PhyRead(instPtr, PHY_FRAME_SYNC_PEAK_L);
|
||||
instPtr->phyLog.fsyncPeak |= ((uint64_t)PhyRead(instPtr, PHY_FRAME_SYNC_PEAK_H)) << 32;
|
||||
instPtr->phyLog.fsyncMean = PhyRead(instPtr, PHY_FRAME_SYNC_MEAN_L);
|
||||
instPtr->phyLog.fsyncMean |= ((uint64_t)PhyRead(instPtr, PHY_FRAME_SYNC_MEAN_H)) << 32;
|
||||
instPtr->phyLog.fsyncFreqCh = (PhyRead(instPtr, PHY_FRAME_SYNC_FREQEST) & PHY_FRAME_SYNC_FREQEST_CHANNEL_MASK) >> PHY_FRAME_SYNC_FREQEST_CHANNEL_SHIFT;
|
||||
instPtr->phyLog.deintlvAmpEst = PhyRead(instPtr, PHY_DEINTLV_AMPEST) & PHY_DEINTLV_AMPEST_MASK;
|
||||
instPtr->phyLog.reserve = 0;
|
||||
|
||||
SysMonitor_UpdatePhysicalLayerLog(&(instPtr->phyLog));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -338,6 +379,7 @@ int32_t Phy_InstInit(PHY_INST **instPtr, PHY_CONFIG *phyConfig)
|
||||
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));
|
||||
memset(&((*instPtr)->phyLog), 0x00, sizeof(PHYLOG));
|
||||
|
||||
#ifndef EMULATION
|
||||
XBram_Config *bramConfigPtr;
|
||||
@@ -519,7 +561,7 @@ void Phy_Halt(PHY_INST *instPtr)
|
||||
uint32_t phyMainCtrl = PhyRead(instPtr, PHY_MAIN_CTRL);
|
||||
if ((phyMainCtrl & PHY_MAIN_CTRL_EN_MASK) == PHY_MAIN_CTRL_EN_DSBL)
|
||||
{
|
||||
DBG_WARNING("Physical layer was allready halted.\n");
|
||||
DBG_WARNING("Physical layer was already halted.\n");
|
||||
}
|
||||
instPtr->isPhyEn = false;
|
||||
PhyWrite(instPtr, PHY_MAIN_CTRL, (phyMainCtrl & (~PHY_MAIN_CTRL_EN_MASK)));
|
||||
@@ -611,7 +653,7 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
case L1_2KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_20MS;
|
||||
hopNum = L1_FRAME_2KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_10KBPS_10MS;
|
||||
hopPattern = hopPattern_2KBPS_20MS;
|
||||
break;
|
||||
case L1_2KBPS_100MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_2KBPS_100MS;
|
||||
@@ -630,8 +672,8 @@ int32_t Phy_SetupNextSlot(PHY_INST *instPtr, PHY_TOR_TYPE txrxMode,
|
||||
break;
|
||||
case L1_40KBPS_20MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_20MS;
|
||||
hopNum = L1_FRAME_200KBPS_5MS_HOPS;
|
||||
hopPattern = hopPattern_200KBPS_5MS;
|
||||
hopNum = L1_FRAME_40KBPS_20MS_HOPS;
|
||||
hopPattern = hopPattern_40KBPS_20MS;
|
||||
break;
|
||||
case L1_40KBPS_10MS_FRAME:
|
||||
phyModeCtrl |= PHY_MODE_CTRL_FRAME_40KBPS_10MS;
|
||||
@@ -808,14 +850,6 @@ double Phy_GetFreqEst(PHY_INST *instPtr)
|
||||
fineReg = PhyRead(instPtr, FINE_FREQEST);
|
||||
estAbs = fineReg & FINE_FREQEST_VAL_MASK;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
{
|
||||
// 1.5M Rc
|
||||
coarse = (double)(80 - acqFreqIdx) * (31.25e3 / 4);
|
||||
coarse += (double)syncFreqIdx * 1.5e6 / 64 / 128;
|
||||
|
||||
fine = 12e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 12M Rc
|
||||
coarse = (double)(8 - acqFreqIdx) * (250e3 / 4);
|
||||
@@ -823,6 +857,14 @@ double Phy_GetFreqEst(PHY_INST *instPtr)
|
||||
|
||||
fine = 48e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1.5M Rc
|
||||
coarse = (double)(80 - acqFreqIdx) * (31.25e3 / 4);
|
||||
coarse += (double)syncFreqIdx * 1.5e6 / 64 / 128;
|
||||
|
||||
fine = 12e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
|
||||
fine = ((fineReg & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ?
|
||||
-fine : fine;
|
||||
@@ -857,17 +899,17 @@ double Phy_GetCoarseFreqEst(PHY_INST *instPtr)
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 1.5M Rc
|
||||
freqEst = (double)(80 - acqFreqIdx) * (31.25e3 / 4);
|
||||
freqEst += (double)syncFreqIdx * 1.5e6 / 64 / 128;
|
||||
}
|
||||
|
||||
return freqEst;
|
||||
}
|
||||
@@ -896,13 +938,13 @@ double Phy_GetFineFreqEst(PHY_INST *instPtr)
|
||||
estAbs = regValue & FINE_FREQEST_VAL_MASK;
|
||||
if (frameType >= L1_200KBPS_5MS_FRAME)
|
||||
{
|
||||
// 1.5M Rc
|
||||
freqEst = 12e6/2048*((double)estAbs)/8192.0;
|
||||
// 12M Rc
|
||||
freqEst = 48e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 12M Rc
|
||||
freqEst = 48e6/2048*((double)estAbs)/8192.0;
|
||||
// 1.5M Rc
|
||||
freqEst = 12e6/2048*((double)estAbs)/8192.0;
|
||||
}
|
||||
freqEst = ((regValue & FINE_FREQEST_SIGN_MASK) == FINE_FREQEST_SIGN_NEG) ?
|
||||
-freqEst : freqEst;
|
||||
@@ -1091,64 +1133,114 @@ void Phy_RetrieveRecvData(PHY_INST *instPtr, uint8_t *dataBuff)
|
||||
* @param instPtr a pointer to hopping pattern buffer
|
||||
* @param patternLen a integer indicate the length of hopping pattern.
|
||||
*
|
||||
* @return SUCCESS
|
||||
* FAILURE pattern length exceeds maximum length.
|
||||
* @return NONE
|
||||
*
|
||||
******************************************************************************/
|
||||
void Phy_UpdateHwSate(PHY_INST *instPtr)
|
||||
void Phy_RefreshHwSate(PHY_INST *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
uint32_t rawData;
|
||||
#ifndef EMULATION
|
||||
// -- Update Chip voltage, unit mV
|
||||
float evalData;
|
||||
instPtr->hwSate.isSpOk = true;
|
||||
// -- Update Ps voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VCCPINT);
|
||||
instPtr->hwSate.spVolt = (uint16_t)(XAdcPs_RawToVoltage(rawData) * 1000);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spPsVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_PS_VALID(evalData);
|
||||
|
||||
// -- Update Ps aux voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VCCPAUX);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spPsAuxVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_PSAUX_VALID(evalData);
|
||||
|
||||
// -- Update DDR voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VCCPDRO);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spDdrVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_DDR_VALID(evalData);
|
||||
|
||||
// -- Update PL voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VCCINT);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spPlVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_PL_VALID(evalData);
|
||||
|
||||
// -- Update PL aux voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VCCAUX);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spPlAuxVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_PLAUX_VALID(evalData);
|
||||
|
||||
// -- Update Bram voltage, unit mV
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_VBRAM);
|
||||
evalData = XAdcPs_RawToVoltage(rawData);
|
||||
instPtr->hwSate.spBramVolt = (evalData > VOLTAGE_MAX) ? UINT8_MAX : (uint8_t) round(evalData/VOLTAGE_LSB);
|
||||
instPtr->hwSate.isSpOk = instPtr->hwSate.isSpOk && IS_BRAM_VALID(evalData);
|
||||
|
||||
// -- Update Chip temperature, unit 0.01 deg
|
||||
rawData = XAdcPs_GetAdcData(&(instPtr->hwXadc), XADCPS_CH_TEMP);
|
||||
instPtr->hwSate.spTemp = (uint16_t)(XAdcPs_RawToTemperature(rawData) * 100);
|
||||
evalData = XAdcPs_RawToTemperature(rawData);
|
||||
instPtr->hwSate.spTemp = (evalData > TEMPERATURE_MAX)
|
||||
? INT8_MAX
|
||||
: ((evalData < TEMPERATURE_MIN) ? INT8_MIN : (int8_t) round(evalData/TEMPERATURE_LSB));
|
||||
|
||||
// FIXME: Chip status determine.
|
||||
instPtr->hwSate.chipSt = 0;
|
||||
#else
|
||||
instPtr->hwSate.spVolt = 0;
|
||||
instPtr->hwSate.spTemp = 0;
|
||||
instPtr->hwSate.chipSt = 0;
|
||||
instPtr->spPsVolt = 0;
|
||||
instPtr->spPsAuxVolt = 0;
|
||||
instPtr->spDdrVolt = 0;
|
||||
instPtr->spPlVolt = 0;
|
||||
instPtr->spPlAuxVolt = 0;
|
||||
instPtr->spBramVolt = 0;
|
||||
instPtr->spTemp = 0;
|
||||
instPtr->isSpOk = true;
|
||||
#endif
|
||||
/*** Voltage and Status ***/
|
||||
rawData = PhyRead(instPtr, ANT_STATUS);
|
||||
// -- Update Antenna Status Code: 0xAA - normal, 0x55 - error
|
||||
instPtr->hwSate.antSt = ((rawData & ANT_STATUS_CODE_MASK) == 0) ? 0xAA : 0x55;
|
||||
// -- Update Antenna Voltage Status: 1 - normal, 0 - error
|
||||
// [0] - ANT voltage status
|
||||
// [2] - RF voltage status
|
||||
// [4] - NIL voltage status
|
||||
instPtr->hwSate.antVolt = (rawData & ANT_STATUS_ANT_VOLT_MASK) ? 0x01 : 0x00;
|
||||
instPtr->hwSate.antVolt |= (rawData & ANT_STATUS_RF_VOLT_MASK) ? 0x04 : 0x00;
|
||||
instPtr->hwSate.antVolt |= (rawData & ANT_STATUS_NIL_VOLT_MASK) ? 0x10 : 0x00;
|
||||
// [6] - Antenna status
|
||||
instPtr->hwSate.antVolt = ((rawData & ANT_STATUS_ANT_VOLT_MASK) == ANT_STATUS_ANT_VOLT_OK) ? 0x01 : 0x00;
|
||||
instPtr->hwSate.antVolt |= ((rawData & ANT_STATUS_RF_VOLT_MASK) == ANT_STATUS_RF_VOLT_OK) ? 0x04 : 0x00;
|
||||
instPtr->hwSate.antVolt |= ((rawData & ANT_STATUS_NIL_VOLT_MASK) == ANT_STATUS_NIL_VOLT_OK) ? 0x10 : 0x00;
|
||||
instPtr->hwSate.antVolt |= ((rawData & ANT_STATUS_CODE_MASK) == ANT_STATUS_CODE_OK) ? 0x40 : 0x00;
|
||||
|
||||
/*** Temperature and Lock Status ***/
|
||||
rawData = PhyRead(instPtr, RF_STATUS);
|
||||
rawData = PhyRead(instPtr, ANT_RF_STATUS);
|
||||
//-- Update Antenna Temperature (signed 8bit integer, 1 centigrade per LSB)
|
||||
instPtr->hwSate.antTemp = (uint8_t)(rawData & RF_STATUS_TEMP_MASK);
|
||||
instPtr->hwSate.antTemp = (uint8_t)(rawData & ANT_RF_STATUS_TEMP_MASK);
|
||||
// -- Update Antenna PLL Lock Status: 1 - normal, 0 - error
|
||||
// [0] - BASEBAND lock status
|
||||
// [2] - PLLA lock status
|
||||
// [4] - PLLB lock status
|
||||
instPtr->hwSate.antPll = (rawData & RF_STATUS_BDLOCK_MASK) ? 0x01 : 0x00;
|
||||
instPtr->hwSate.antPll |= (rawData & RF_STATUS_PLLA_MASK) ? 0x04 : 0x00;
|
||||
instPtr->hwSate.antPll |= (rawData & RF_STATUS_PLLB_MASK) ? 0x10 : 0x00;
|
||||
instPtr->hwSate.antPll = ((rawData & ANT_RF_STATUS_BBLOCK_MASK) == ANT_RF_STATUS_BBLOCK_OK) ? 0x01 : 0x00;
|
||||
instPtr->hwSate.antPll |= ((rawData & ANT_RF_STATUS_PLLA_MASK) == ANT_RF_STATUS_PLLA_OK) ? 0x04 : 0x00;
|
||||
instPtr->hwSate.antPll |= ((rawData & ANT_RF_STATUS_PLLB_MASK) == ANT_RF_STATUS_PLLB_OK) ? 0x10 : 0x00;
|
||||
|
||||
/*** MGCs ***/
|
||||
rawData = PhyRead(instPtr, RF_MGC);
|
||||
rawData = PhyRead(instPtr, ANT_RF_MGC);
|
||||
// -- Update Antenna MGC (0~15 dB)
|
||||
// [3:0] - Channel 1 MGC
|
||||
// [7:4] - Channel 2 MGC
|
||||
// [11:8] - Channel 3 MGC
|
||||
// [15:12] - Channel 4 MGC
|
||||
instPtr->hwSate.antMgc = (rawData & RF_MGC_CH1_MASK);
|
||||
instPtr->hwSate.antMgc |= (rawData & RF_MGC_CH2_MASK) >> 4;
|
||||
instPtr->hwSate.antMgc |= (rawData & RF_MGC_CH3_MASK) >> 8;
|
||||
instPtr->hwSate.antMgc |= (rawData & RF_MGC_CH4_MASK) >> 12;
|
||||
instPtr->hwSate.antMgc0 = (rawData & ANT_RF_MGC_CH1_MASK);
|
||||
instPtr->hwSate.antMgc0 |= (rawData & ANT_RF_MGC_CH2_MASK) >> 4;
|
||||
instPtr->hwSate.antMgc1 = (rawData & ANT_RF_MGC_CH3_MASK) >> 16;
|
||||
instPtr->hwSate.antMgc1 |= (rawData & ANT_RF_MGC_CH4_MASK) >> 24;
|
||||
|
||||
// Determin if antenna is ok.
|
||||
if(instPtr->hwSate.antVolt != 0x55 //01010101
|
||||
||instPtr->hwSate.antPll != 0x15) // 00010101
|
||||
{
|
||||
instPtr->hwSate.isSpOk = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
instPtr->hwSate.isSpOk = true;
|
||||
}
|
||||
SysMonitor_UpdateHardwareStatus(&(instPtr->hwSate));
|
||||
}
|
||||
|
||||
@@ -35,15 +35,14 @@
|
||||
#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_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
|
||||
@@ -55,27 +54,6 @@
|
||||
#define L1_FRAME_200KBPS_5MS_HOPS 20
|
||||
#define L1_FRAME_1M2BPS_5MS_HOPS 20
|
||||
|
||||
#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 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 *********************/
|
||||
@@ -189,6 +167,14 @@ typedef enum
|
||||
PHY_MODE_PULL = 3
|
||||
} PHY_MODE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PHY_ANT_MODE_NONE = 0,
|
||||
PHY_ANT_MODE_SILENT = 1,
|
||||
PHY_ANT_MODE_LOW_POWER = 2,
|
||||
PHY_ANT_MODE_HIGH_POWER = 3,
|
||||
} PHY_ANT_MODE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t devId;
|
||||
@@ -232,6 +218,7 @@ typedef struct
|
||||
XAdcPs hwXadc;
|
||||
#endif
|
||||
HWSTATE hwSate;
|
||||
PHYLOG phyLog;
|
||||
} PHY_INST;
|
||||
|
||||
/************************** Variable Definitions *****************************/
|
||||
@@ -254,7 +241,7 @@ 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);
|
||||
void Phy_RefreshHwSate(PHY_INST *instPtr);
|
||||
|
||||
void Phy_Start(PHY_INST *instPtr);
|
||||
void Phy_Halt(PHY_INST *instPtr);
|
||||
@@ -277,6 +264,7 @@ uint32_t Phy_GetHopLength(L1_FRAME_TYPE frameType);
|
||||
uint32_t Phy_GetTimeComp(L1_FRAME_TYPE frameType);
|
||||
|
||||
void Phy_AntConfigInit(PHY_ANT_CONFIG *antConfig);
|
||||
void Phy_AntConfigMode(PHY_INST *instPtr, PHY_ANT_MODE mode);
|
||||
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);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* History:
|
||||
* [2021-11-16]: Initial version.
|
||||
* [2022-06-18]: New branch for glink control purpose:
|
||||
* -Add poll modephysical layer will start Tx/Rx procedure
|
||||
* -Add poll mode physical layer will start Tx/Rx procedure
|
||||
* at specific time stamp.
|
||||
* [2023-04-24]: Porting for DUIFEI.
|
||||
*
|
||||
@@ -33,7 +33,7 @@
|
||||
/**
|
||||
* Register: PHY_MAIN_CTRL
|
||||
*/
|
||||
#define PHY_MAIN_CTRL 0X00000000U
|
||||
#define PHY_MAIN_CTRL 0x00000000U
|
||||
#define PHY_MAIN_CTRL_EN_SHIFT 0
|
||||
#define PHY_MAIN_CTRL_EN_WIDTH 1
|
||||
#define PHY_MAIN_CTRL_EN_MASK 0x00000001U
|
||||
@@ -275,21 +275,28 @@
|
||||
#define BEAM_AXIS_AZ_MASK 0xFFFF0000U
|
||||
|
||||
/**
|
||||
* Register: ANT_STATUS_0
|
||||
* Register: ANT_STATUS
|
||||
*/
|
||||
#define ANT_STATUS 0x00000100U
|
||||
#define ANT_STATUS_CODE_SHIFT 0
|
||||
#define ANT_STATUS_CODE_WIDTH 8
|
||||
#define ANT_STATUS_CODE_MASK 0x000000FFU
|
||||
#define ANT_STATUS_NIL_VOLT_SHIFT 8
|
||||
#define ANT_STATUS_NIL_VOLT_WIDTH 8
|
||||
#define ANT_STATUS_NIL_VOLT_MASK 0x0000FF00U
|
||||
#define ANT_STATUS_RF_VOLT_SHIFT 16
|
||||
#define ANT_STATUS_RF_VOLT_WIDTH 8
|
||||
#define ANT_STATUS_RF_VOLT_MASK 0x00FF0000U
|
||||
#define ANT_STATUS_ANT_VOLT_SHIFT 24
|
||||
#define ANT_STATUS_ANT_VOLT_SHIFT 0
|
||||
#define ANT_STATUS_ANT_VOLT_WIDTH 8
|
||||
#define ANT_STATUS_ANT_VOLT_MASK 0xFF000000U
|
||||
#define ANT_STATUS_ANT_VOLT_MASK 0x000000FFU
|
||||
#define ANT_STATUS_ANT_VOLT_OK 0x00000001U
|
||||
|
||||
#define ANT_STATUS_RF_VOLT_SHIFT 8
|
||||
#define ANT_STATUS_RF_VOLT_WIDTH 8
|
||||
#define ANT_STATUS_RF_VOLT_MASK 0x0000FF00U
|
||||
#define ANT_STATUS_RF_VOLT_OK 0x00000100U
|
||||
|
||||
#define ANT_STATUS_NIL_VOLT_SHIFT 16
|
||||
#define ANT_STATUS_NIL_VOLT_WIDTH 8
|
||||
#define ANT_STATUS_NIL_VOLT_MASK 0x00FF0000U
|
||||
#define ANT_STATUS_NIL_VOLT_OK 0x00010000U
|
||||
|
||||
#define ANT_STATUS_CODE_SHIFT 24
|
||||
#define ANT_STATUS_CODE_WIDTH 8
|
||||
#define ANT_STATUS_CODE_MASK 0xFF000000U
|
||||
#define ANT_STATUS_CODE_OK 0x00000000U
|
||||
|
||||
/**
|
||||
* Register: ANT_FRAME_CNT
|
||||
@@ -300,45 +307,184 @@
|
||||
#define ANT_FRAME_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: RF_STATUS
|
||||
* Register: ANT_RF_STATUS
|
||||
*/
|
||||
#define RF_STATUS 0x00000108U
|
||||
#define RF_STATUS_TEMP_SHIFT 0
|
||||
#define RF_STATUS_TEMP_WIDTH 8
|
||||
#define RF_STATUS_TEMP_MASK 0x000000FFU
|
||||
#define RF_STATUS_BDLOCK_SHIFT 8
|
||||
#define RF_STATUS_BDLOCK_WIDTH 8
|
||||
#define RF_STATUS_BDLOCK_MASK 0x0000FF00U
|
||||
#define RF_STATUS_PLLA_SHIFT 16
|
||||
#define RF_STATUS_PLLA_WIDTH 8
|
||||
#define RF_STATUS_PLLA_MASK 0x00FF0000U
|
||||
#define RF_STATUS_PLLB_SHIFT 24
|
||||
#define RF_STATUS_PLLB_WIDTH 8
|
||||
#define RF_STATUS_PLLB_MASK 0xFF000000U
|
||||
#define ANT_RF_STATUS 0x00000108U
|
||||
#define ANT_RF_STATUS_TEMP_SHIFT 0
|
||||
#define ANT_RF_STATUS_TEMP_WIDTH 8
|
||||
#define ANT_RF_STATUS_TEMP_MASK 0x000000FFU
|
||||
|
||||
#define ANT_RF_STATUS_BBLOCK_SHIFT 8
|
||||
#define ANT_RF_STATUS_BBLOCK_WIDTH 8
|
||||
#define ANT_RF_STATUS_BBLOCK_MASK 0x0000FF00U
|
||||
#define ANT_RF_STATUS_BBLOCK_OK 0x00000100U
|
||||
|
||||
#define ANT_RF_STATUS_PLLA_SHIFT 16
|
||||
#define ANT_RF_STATUS_PLLA_WIDTH 8
|
||||
#define ANT_RF_STATUS_PLLA_MASK 0x00FF0000U
|
||||
#define ANT_RF_STATUS_PLLA_OK 0x00010000U
|
||||
|
||||
#define ANT_RF_STATUS_PLLB_SHIFT 24
|
||||
#define ANT_RF_STATUS_PLLB_WIDTH 8
|
||||
#define ANT_RF_STATUS_PLLB_MASK 0xFF000000U
|
||||
#define ANT_RF_STATUS_PLLB_OK 0x01000000U
|
||||
|
||||
/**
|
||||
* Register: RF_MGC
|
||||
* Register: ANT_RF_MGC
|
||||
*/
|
||||
#define RF_MGC 0x0000010CU
|
||||
#define RF_MGC_CH1_SHIFT 0
|
||||
#define RF_MGC_CH1_WIDTH 4
|
||||
#define RF_MGC_CH1_MASK 0x0000000FU
|
||||
#define RF_MGC_CH2_SHIFT 8
|
||||
#define RF_MGC_CH2_WIDTH 4
|
||||
#define RF_MGC_CH2_MASK 0x00000F00U
|
||||
#define RF_MGC_CH3_SHIFT 16
|
||||
#define RF_MGC_CH3_WIDTH 4
|
||||
#define RF_MGC_CH3_MASK 0x000F0000U
|
||||
#define RF_MGC_CH4_SHIFT 24
|
||||
#define RF_MGC_CH4_WIDTH 4
|
||||
#define RF_MGC_CH4_MASK 0x0F000000U
|
||||
#define ANT_RF_MGC 0x0000010CU
|
||||
#define ANT_RF_MGC_CH1_SHIFT 0
|
||||
#define ANT_RF_MGC_CH1_WIDTH 4
|
||||
#define ANT_RF_MGC_CH1_MASK 0x0000000FU
|
||||
#define ANT_RF_MGC_CH2_SHIFT 8
|
||||
#define ANT_RF_MGC_CH2_WIDTH 4
|
||||
#define ANT_RF_MGC_CH2_MASK 0x00000F00U
|
||||
#define ANT_RF_MGC_CH3_SHIFT 16
|
||||
#define ANT_RF_MGC_CH3_WIDTH 4
|
||||
#define ANT_RF_MGC_CH3_MASK 0x000F0000U
|
||||
#define ANT_RF_MGC_CH4_SHIFT 24
|
||||
#define ANT_RF_MGC_CH4_WIDTH 4
|
||||
#define ANT_RF_MGC_CH4_MASK 0x0F000000U
|
||||
|
||||
/**
|
||||
* Register: RF_FRAME_CNT
|
||||
* Register: ANT_RF_FRAME_CNT
|
||||
*/
|
||||
#define RF_FRAME_CNT 0x00000110U
|
||||
#define RF_FRAME_CNT_SHIFT 0
|
||||
#define RF_FRAME_CNT_WIDTH 32
|
||||
#define RF_FRAME_CNT_MASK 0xFFFFFFFFU
|
||||
#define ANT_RF_FRAME_CNT 0x00000110U
|
||||
#define ANT_RF_FRAME_CNT_SHIFT 0
|
||||
#define ANT_RF_FRAME_CNT_WIDTH 32
|
||||
#define ANT_RF_FRAME_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_CNT
|
||||
*/
|
||||
#define PHY_ACQ_CNT 0x00000114U
|
||||
#define PHY_ACQ_CNT_SHIFT 0
|
||||
#define PHY_ACQ_CNT_WIDTH 32
|
||||
#define PHY_ACQ_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_CNT
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_CNT 0x00000118U
|
||||
#define PHY_FRAME_SYNC_CNT_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_CNT_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_DECODE_CNT
|
||||
*/
|
||||
#define PHY_DECODE_CNT 0x0000011CU
|
||||
#define PHY_DECODE_CNT_SHIFT 0
|
||||
#define PHY_DECODE_CNT_WIDTH 32
|
||||
#define PHY_DECODE_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_CRC_OK_CNT
|
||||
*/
|
||||
#define PHY_CRC_OK_CNT 0x00000120U
|
||||
#define PHY_CRC_OK_CNT_SHIFT 0
|
||||
#define PHY_CRC_OK_CNT_WIDTH 32
|
||||
#define PHY_CRC_OK_CNT_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_PEAK_H
|
||||
*/
|
||||
#define PHY_ACQ_PEAK_H 0x00000124U
|
||||
#define PHY_ACQ_PEAK_H_SHIFT 0
|
||||
#define PHY_ACQ_PEAK_H_WIDTH 32
|
||||
#define PHY_ACQ_PEAK_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_PEAK_L
|
||||
*/
|
||||
#define PHY_ACQ_PEAK_L 0x00000128U
|
||||
#define PHY_ACQ_PEAK_L_SHIFT 0
|
||||
#define PHY_ACQ_PEAK_L_WIDTH 32
|
||||
#define PHY_ACQ_PEAK_L_MASK 0xFFFFFFFFU
|
||||
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_MEAN_H
|
||||
*/
|
||||
#define PHY_ACQ_MEAN_H 0x0000012CU
|
||||
#define PHY_ACQ_MEAN_H_SHIFT 0
|
||||
#define PHY_ACQ_MEAN_H_WIDTH 32
|
||||
#define PHY_ACQ_MEAN_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_MEAN_L
|
||||
*/
|
||||
#define PHY_ACQ_MEAN_L 0x00000130U
|
||||
#define PHY_ACQ_MEAN_L_SHIFT 0
|
||||
#define PHY_ACQ_MEAN_L_WIDTH 32
|
||||
#define PHY_ACQ_MEAN_L_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_ACQ_FREQEST
|
||||
*/
|
||||
#define PHY_ACQ_FREQEST 0x00000134U
|
||||
#define PHY_ACQ_FREQEST_SHIFT 0
|
||||
#define PHY_ACQ_FREQEST_WIDTH 32
|
||||
#define PHY_ACQ_FREQEST_MASK 0xFFFFFFFFU
|
||||
|
||||
#define PHY_ACQ_FREQEST_PHASE_SHIFT 0
|
||||
#define PHY_ACQ_FREQEST_PHASE_WIDTH 8
|
||||
#define PHY_ACQ_FREQEST_PHASE_MASK 0x000000FFU
|
||||
#define PHY_ACQ_FREQEST_CHANNEL_SHIFT 8
|
||||
#define PHY_ACQ_FREQEST_CHANNEL_WIDTH 8
|
||||
#define PHY_ACQ_FREQEST_CHANNEL_MASK 0x0000FF00U
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_PEAK_H
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_PEAK_H 0x00000138U
|
||||
#define PHY_FRAME_SYNC_PEAK_H_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_PEAK_H_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_PEAK_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_PEAK_L
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_PEAK_L 0x0000013CU
|
||||
#define PHY_FRAME_SYNC_PEAK_L_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_PEAK_L_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_PEAK_L_MASK 0xFFFFFFFFU
|
||||
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_MEAN_H
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_MEAN_H 0x00000140U
|
||||
#define PHY_FRAME_SYNC_MEAN_H_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_MEAN_H_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_MEAN_H_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_MEAN_L
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_MEAN_L 0x00000144U
|
||||
#define PHY_FRAME_SYNC_MEAN_L_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_MEAN_L_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_MEAN_L_MASK 0xFFFFFFFFU
|
||||
|
||||
/**
|
||||
* Register: PHY_FRAME_SYNC_FREQEST
|
||||
*/
|
||||
#define PHY_FRAME_SYNC_FREQEST 0x00000148U
|
||||
#define PHY_FRAME_SYNC_FREQEST_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_FREQEST_WIDTH 32
|
||||
#define PHY_FRAME_SYNC_FREQEST_MASK 0xFFFFFFFFU
|
||||
|
||||
#define PHY_FRAME_SYNC_FREQEST_CHANNEL_SHIFT 0
|
||||
#define PHY_FRAME_SYNC_FREQEST_CHANNEL_WIDTH 8
|
||||
#define PHY_FRAME_SYNC_FREQEST_CHANNEL_MASK 0x000000FFU
|
||||
|
||||
/**
|
||||
* Register: PHY_DEINTLV_AMPEST
|
||||
*/
|
||||
#define PHY_DEINTLV_AMPEST 0x0000014CU
|
||||
#define PHY_DEINTLV_AMPEST_SHIFT 0
|
||||
#define PHY_DEINTLV_AMPEST_WIDTH 16
|
||||
#define PHY_DEINTLV_AMPEST_MASK 0x0000FFFFU
|
||||
|
||||
#endif /* PHY_REG_H_ */
|
||||
|
||||
@@ -23,18 +23,16 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PINGPONG recvPLCtrl;
|
||||
PAYLOAD recvPL[2];
|
||||
PINGPONG sendPLCtrl;
|
||||
PAYLOAD sendPL[2];
|
||||
PINGPONG recvCtrl;
|
||||
PAYLOAD recv[2];
|
||||
PINGPONG sendCtrl;
|
||||
PAYLOAD send[2];
|
||||
PINGPONG sysInfoCtrl;
|
||||
SYSINFO sysInfo[2];
|
||||
PINGPONG sendLogCtrl;
|
||||
SLOTLOG sendLog[2];
|
||||
PINGPONG recvLogCtrl;
|
||||
SLOTLOG recvLog[2];
|
||||
PINGPONG protocolLogCtrl;
|
||||
PRTCLLOG protocolLog[2];
|
||||
PINGPONG linkLogCtrl;
|
||||
LINKLOG linkLog[2];
|
||||
PINGPONG phyLogCtrl;
|
||||
PHYLOG phyLog[2];
|
||||
PINGPONG hwStateCtrl;
|
||||
HWSTATE hwState[2];
|
||||
} SYSMONITOR;
|
||||
@@ -70,13 +68,17 @@ int32_t SysMonitor_Init(void)
|
||||
{
|
||||
return ENOMEM;
|
||||
}
|
||||
memset(&(sysMonitorInst->recvPLCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->sendPLCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->recvCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->sendCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->sysInfoCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->sendLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->recvLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->protocolLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->linkLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->phyLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->hwStateCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
|
||||
sysMonitorInst->recv[0].dataId = DATA_ID_NONE;
|
||||
sysMonitorInst->recv[1].dataId = DATA_ID_NONE;
|
||||
sysMonitorInst->send[0].dataId = DATA_ID_NONE;
|
||||
sysMonitorInst->send[1].dataId = DATA_ID_NONE;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -87,7 +89,10 @@ void SysMonitor_Destroy(void)
|
||||
}
|
||||
|
||||
// @System Info
|
||||
void SysMonitor_UpdateSysinfo(SYSINFO *info)
|
||||
/**
|
||||
* Update system info.
|
||||
*/
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info)
|
||||
{
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
|
||||
@@ -97,49 +102,9 @@ void SysMonitor_UpdateSysinfo(SYSINFO *info)
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
void SysMonitor_UpdateSysinfoRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = buffIndx;
|
||||
// Decapsulate Systeminfo
|
||||
SYSINFO *infoEntry = &(sysMonitorInst->sysInfo[buffIndx]);
|
||||
memcpy(&(infoEntry->psBDS), buff, sizeof(infoEntry->psBDS));
|
||||
buff += sizeof(infoEntry->psBDS);
|
||||
memcpy(&(infoEntry->pBDS), buff, sizeof(infoEntry->pBDS));
|
||||
buff += sizeof(infoEntry->pBDS);
|
||||
memcpy(&(infoEntry->psGPS), buff, sizeof(infoEntry->psGPS));
|
||||
buff += sizeof(infoEntry->psGPS);
|
||||
memcpy(&(infoEntry->pGPS), buff, sizeof(infoEntry->pGPS));
|
||||
buff += sizeof(infoEntry->pGPS);
|
||||
memcpy(&(infoEntry->tmInd), buff, sizeof(infoEntry->tmInd));
|
||||
buff += sizeof(infoEntry->tmInd);
|
||||
memcpy(&(infoEntry->tmFly), buff, sizeof(infoEntry->tmFly));
|
||||
buff += sizeof(infoEntry->tmFly);
|
||||
memcpy(&(infoEntry->stFly), buff, sizeof(infoEntry->stFly));
|
||||
buff += sizeof(infoEntry->stFly);
|
||||
memcpy(&(infoEntry->posX), buff, sizeof(infoEntry->posX));
|
||||
buff += sizeof(infoEntry->posX);
|
||||
memcpy(&(infoEntry->posY), buff, sizeof(infoEntry->posY));
|
||||
buff += sizeof(infoEntry->posY);
|
||||
memcpy(&(infoEntry->posZ), buff, sizeof(infoEntry->posZ));
|
||||
buff += sizeof(infoEntry->posZ);
|
||||
memcpy(&(infoEntry->vX), buff, sizeof(infoEntry->vX));
|
||||
buff += sizeof(infoEntry->vX);
|
||||
memcpy(&(infoEntry->vY), buff, sizeof(infoEntry->vY));
|
||||
buff += sizeof(infoEntry->vY);
|
||||
memcpy(&(infoEntry->vZ), buff, sizeof(infoEntry->vZ));
|
||||
buff += sizeof(infoEntry->vZ);
|
||||
memcpy(&(infoEntry->pitch), buff, sizeof(infoEntry->pitch));
|
||||
buff += sizeof(infoEntry->pitch);
|
||||
memcpy(&(infoEntry->yaw), buff, sizeof(infoEntry->yaw));
|
||||
buff += sizeof(infoEntry->yaw);
|
||||
memcpy(&(infoEntry->roll), buff, sizeof(infoEntry->roll));
|
||||
sysMonitorInst->sysInfoCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sysInfoCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get system info.
|
||||
*/
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
@@ -154,375 +119,150 @@ void SysMonitor_GetSysinfo(SYSINFO *info)
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
void SysMonitor_GetSysinfoRaw(uint8_t *buff)
|
||||
{
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sysInfoCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sysInfoCtrl);
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndx;
|
||||
|
||||
// Encapsulate Systeminfo
|
||||
SYSINFO *infoEntry = &(sysMonitorInst->sysInfo[buffIndx]);
|
||||
memcpy(buff, &(infoEntry->psBDS), sizeof(infoEntry->psBDS));
|
||||
buff += sizeof(infoEntry->psBDS);
|
||||
memcpy(buff, &(infoEntry->pBDS), sizeof(infoEntry->pBDS));
|
||||
buff += sizeof(infoEntry->pBDS);
|
||||
memcpy(buff, &(infoEntry->psGPS), sizeof(infoEntry->psGPS));
|
||||
buff += sizeof(infoEntry->psGPS);
|
||||
memcpy(buff, &(infoEntry->pGPS), sizeof(infoEntry->pGPS));
|
||||
buff += sizeof(infoEntry->pGPS);
|
||||
memcpy(buff, &(infoEntry->tmInd), sizeof(infoEntry->tmInd));
|
||||
buff += sizeof(infoEntry->tmInd);
|
||||
memcpy(buff, &(infoEntry->tmFly), sizeof(infoEntry->tmFly));
|
||||
buff += sizeof(infoEntry->tmFly);
|
||||
memcpy(buff, &(infoEntry->stFly), sizeof(infoEntry->stFly));
|
||||
buff += sizeof(infoEntry->stFly);
|
||||
memcpy(buff, &(infoEntry->posX), sizeof(infoEntry->posX));
|
||||
buff += sizeof(infoEntry->posX);
|
||||
memcpy(buff, &(infoEntry->posY), sizeof(infoEntry->posY));
|
||||
buff += sizeof(infoEntry->posY);
|
||||
memcpy(buff, &(infoEntry->posZ), sizeof(infoEntry->posZ));
|
||||
buff += sizeof(infoEntry->posZ);
|
||||
memcpy(buff, &(infoEntry->vX), sizeof(infoEntry->vX));
|
||||
buff += sizeof(infoEntry->vX);
|
||||
memcpy(buff, &(infoEntry->vY), sizeof(infoEntry->vY));
|
||||
buff += sizeof(infoEntry->vY);
|
||||
memcpy(buff, &(infoEntry->vZ), sizeof(infoEntry->vZ));
|
||||
buff += sizeof(infoEntry->vZ);
|
||||
memcpy(buff, &(infoEntry->pitch), sizeof(infoEntry->pitch));
|
||||
buff += sizeof(infoEntry->pitch);
|
||||
memcpy(buff, &(infoEntry->yaw), sizeof(infoEntry->yaw));
|
||||
buff += sizeof(infoEntry->yaw);
|
||||
memcpy(buff, &(infoEntry->roll), sizeof(infoEntry->roll));
|
||||
sysMonitorInst->sysInfoCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
// @Send Payload
|
||||
// @Send Payload
|
||||
/**
|
||||
* Update send FLJ payload by raw data.
|
||||
* Update send payload by.
|
||||
*/
|
||||
void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff)
|
||||
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sendPLCtrl);
|
||||
sysMonitorInst->sendPLCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->sendPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ);
|
||||
sysMonitorInst->sendPLCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE;
|
||||
buffIndx = GetWritable(sysMonitorInst->sendCtrl);
|
||||
sysMonitorInst->sendCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->send[buffIndx].data, buff, len);
|
||||
sysMonitorInst->send[buffIndx].dataId++;
|
||||
sysMonitorInst->sendCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sendCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get send FLJ payload as raw data.
|
||||
* Get the latest send payload.
|
||||
*/
|
||||
void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff)
|
||||
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendPLCtrl.rBusy;
|
||||
buffIndex_old = sysMonitorInst->sendCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sendPLCtrl);
|
||||
sysMonitorInst->sendPLCtrl.rBusy = buffIndx;
|
||||
memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ);
|
||||
sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old;
|
||||
buffIndx = GetReadable(sysMonitorInst->sendCtrl);
|
||||
sysMonitorInst->sendCtrl.rBusy = buffIndx;
|
||||
if (sysMonitorInst->send[buffIndx].dataId != DATA_ID_NONE)
|
||||
{
|
||||
memcpy(buff, sysMonitorInst->send[buffIndx].data, len);
|
||||
}
|
||||
*id = sysMonitorInst->send[buffIndx].dataId;
|
||||
sysMonitorInst->sendCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Receive Payload
|
||||
/**
|
||||
* Update LJ send payload by raw data.
|
||||
* Update receive payload.
|
||||
*/
|
||||
void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff)
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sendPLCtrl);
|
||||
sysMonitorInst->sendPLCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->sendPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ);
|
||||
sysMonitorInst->sendPLCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE;
|
||||
buffIndx = GetWritable(sysMonitorInst->recvCtrl);
|
||||
sysMonitorInst->recvCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->recv[buffIndx].data, buff, len);
|
||||
sysMonitorInst->recv[buffIndx].dataId++;
|
||||
sysMonitorInst->recvCtrl.latest = buffIndx;
|
||||
sysMonitorInst->recvCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get send LJ payload as raw data.
|
||||
* Get the latest receive payload.
|
||||
*/
|
||||
void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff)
|
||||
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendPLCtrl.rBusy;
|
||||
buffIndex_old = sysMonitorInst->recvCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sendPLCtrl);
|
||||
sysMonitorInst->sendPLCtrl.rBusy = buffIndx;
|
||||
memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ);
|
||||
sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old;
|
||||
buffIndx = GetReadable(sysMonitorInst->recvCtrl);
|
||||
sysMonitorInst->recvCtrl.rBusy = buffIndx;
|
||||
if (sysMonitorInst->recv[buffIndx].dataId != DATA_ID_NONE)
|
||||
{
|
||||
memcpy(buff, sysMonitorInst->recv[buffIndx].data, len);
|
||||
}
|
||||
*id = sysMonitorInst->recv[buffIndx].dataId;
|
||||
sysMonitorInst->recvCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Receive Payload
|
||||
// @Link layer log
|
||||
/**
|
||||
* Update receive FLJ payload by raw data.
|
||||
* Update link layer log
|
||||
*/
|
||||
void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff)
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->recvPLCtrl);
|
||||
sysMonitorInst->recvPLCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->recvPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ);
|
||||
sysMonitorInst->recvPLCtrl.latest = buffIndx;
|
||||
sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE;
|
||||
buffIndx = GetWritable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->linkLog[buffIndx]), log, sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->linkLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get send FLJ payload as raw data.
|
||||
* Get the latest link layer log
|
||||
*/
|
||||
void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff)
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->recvPLCtrl.rBusy;
|
||||
buffIndex_old = sysMonitorInst->linkLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->recvPLCtrl);
|
||||
sysMonitorInst->recvPLCtrl.rBusy = buffIndx;
|
||||
memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ);
|
||||
sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old;
|
||||
buffIndx = GetReadable(sysMonitorInst->linkLogCtrl);
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->linkLog[buffIndx]), sizeof(LINKLOG));
|
||||
sysMonitorInst->linkLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Physical layer log
|
||||
/**
|
||||
* Update receive LJ payload by raw data.
|
||||
* Update physical layer log
|
||||
*/
|
||||
void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff)
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->recvPLCtrl);
|
||||
sysMonitorInst->recvPLCtrl.wBusy = buffIndx;
|
||||
memcpy(sysMonitorInst->recvPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ);
|
||||
sysMonitorInst->recvPLCtrl.latest = buffIndx;
|
||||
sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE;
|
||||
buffIndx = GetWritable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->phyLog[buffIndx]), log, sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->phyLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get send LJ payload as raw data.
|
||||
* Get the latest physical layer log
|
||||
*/
|
||||
void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff)
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->recvPLCtrl.rBusy;
|
||||
buffIndex_old = sysMonitorInst->phyLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->recvPLCtrl);
|
||||
sysMonitorInst->recvPLCtrl.rBusy = buffIndx;
|
||||
memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ);
|
||||
sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old;
|
||||
buffIndx = GetReadable(sysMonitorInst->phyLogCtrl);
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->phyLog[buffIndx]), sizeof(PHYLOG));
|
||||
sysMonitorInst->phyLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Send Slot log
|
||||
/**
|
||||
* Log send slot information
|
||||
*/
|
||||
void SysMonitor_UpdateSendSlotLog(SLOTLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->sendLogCtrl);
|
||||
sysMonitorInst->sendLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->sendLog[buffIndx]), log, sizeof(SLOTLOG));
|
||||
sysMonitorInst->sendLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->sendLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest send slot log
|
||||
*/
|
||||
void SysMonitor_GetSendSlotLog(SLOTLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sendLogCtrl);
|
||||
sysMonitorInst->sendLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->sendLog[buffIndx]), sizeof(SLOTLOG));
|
||||
sysMonitorInst->sendLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest send slot log as raw data
|
||||
*/
|
||||
void SysMonitor_GetSendSlotLogRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->sendLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->sendLogCtrl);
|
||||
sysMonitorInst->sendLogCtrl.rBusy = buffIndx;
|
||||
|
||||
// Encapsulate log
|
||||
SLOTLOG *logEntry = &(sysMonitorInst->sendLog[buffIndx]);
|
||||
memcpy(buff, &(logEntry->tuNo), sizeof(logEntry->tuNo));
|
||||
buff += sizeof(logEntry->tuNo);
|
||||
memcpy(buff, &(logEntry->slotNo), sizeof(logEntry->slotNo));
|
||||
buff += sizeof(logEntry->slotNo);
|
||||
memcpy(buff, &(logEntry->frameType), sizeof(logEntry->frameType));
|
||||
buff += sizeof(logEntry->frameType);
|
||||
memcpy(buff, &(logEntry->payload), sizeof(logEntry->payload));
|
||||
buff += sizeof(logEntry->payload);
|
||||
memcpy(buff, &(logEntry->tmStamp), sizeof(logEntry->tmStamp));
|
||||
buff += sizeof(logEntry->tmStamp);
|
||||
memcpy(buff, &(logEntry->tmDevi), sizeof(logEntry->tmDevi));
|
||||
buff += sizeof(logEntry->tmDevi);
|
||||
memcpy(buff, &(logEntry->freqDevi), sizeof(logEntry->freqDevi));
|
||||
sysMonitorInst->sendLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Receive Slot log
|
||||
/**
|
||||
* Log receive slot information
|
||||
*/
|
||||
void SysMonitor_UpdateRecvSlotLog(SLOTLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->recvLogCtrl);
|
||||
sysMonitorInst->recvLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->recvLog[buffIndx]), log, sizeof(SLOTLOG));
|
||||
sysMonitorInst->recvLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->recvLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest receive slot information
|
||||
*/
|
||||
void SysMonitor_GetRecvSlotLog(SLOTLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->recvLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->recvLogCtrl);
|
||||
sysMonitorInst->recvLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->recvLog[buffIndx]), sizeof(SLOTLOG));
|
||||
sysMonitorInst->recvLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest receive slot information as raw data
|
||||
*/
|
||||
void SysMonitor_GetRecvSlotLogRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->recvLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->recvLogCtrl);
|
||||
sysMonitorInst->recvLogCtrl.rBusy = buffIndx;
|
||||
|
||||
// Encapsulate log
|
||||
SLOTLOG *logEntry = &(sysMonitorInst->recvLog[buffIndx]);
|
||||
memcpy(buff, &(logEntry->tuNo), sizeof(logEntry->tuNo));
|
||||
buff += sizeof(logEntry->tuNo);
|
||||
memcpy(buff, &(logEntry->slotNo), sizeof(logEntry->slotNo));
|
||||
buff += sizeof(logEntry->slotNo);
|
||||
memcpy(buff, &(logEntry->frameType), sizeof(logEntry->frameType));
|
||||
buff += sizeof(logEntry->frameType);
|
||||
memcpy(buff, &(logEntry->payload), sizeof(logEntry->payload));
|
||||
buff += sizeof(logEntry->payload);
|
||||
memcpy(buff, &(logEntry->tmStamp), sizeof(logEntry->tmStamp));
|
||||
buff += sizeof(logEntry->tmStamp);
|
||||
memcpy(buff, &(logEntry->tmDevi), sizeof(logEntry->tmDevi));
|
||||
buff += sizeof(logEntry->tmDevi);
|
||||
memcpy(buff, &(logEntry->freqDevi), sizeof(logEntry->freqDevi));
|
||||
sysMonitorInst->recvLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Protocol log
|
||||
/**
|
||||
* Log protocol running status.
|
||||
*/
|
||||
void SysMonitor_UpdateProtocolLog(PRTCLLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
buffIndx = GetWritable(sysMonitorInst->protocolLogCtrl);
|
||||
sysMonitorInst->protocolLogCtrl.wBusy = buffIndx;
|
||||
memcpy(&(sysMonitorInst->protocolLog[buffIndx]), log, sizeof(PRTCLLOG));
|
||||
sysMonitorInst->protocolLogCtrl.latest = buffIndx;
|
||||
sysMonitorInst->protocolLogCtrl.wBusy = BUFF_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol running log.
|
||||
*/
|
||||
void SysMonitor_GetProtocolLog(PRTCLLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->protocolLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->protocolLogCtrl);
|
||||
sysMonitorInst->protocolLogCtrl.rBusy = buffIndx;
|
||||
memcpy(log, &(sysMonitorInst->protocolLog[buffIndx]), sizeof(PRTCLLOG));
|
||||
sysMonitorInst->protocolLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the protocol running log as raw data.
|
||||
*/
|
||||
void SysMonitor_GetProtocolLogRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->protocolLogCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->protocolLogCtrl);
|
||||
sysMonitorInst->protocolLogCtrl.rBusy = buffIndx;
|
||||
|
||||
// Encapsulate log
|
||||
PRTCLLOG *logEntry = &(sysMonitorInst->protocolLog[buffIndx]);
|
||||
memcpy(buff, &(logEntry->tmSys), sizeof(logEntry->tmSys));
|
||||
buff += sizeof(logEntry->tmSys);
|
||||
memcpy(buff, &(logEntry->phySt), sizeof(logEntry->phySt));
|
||||
buff += sizeof(logEntry->phySt);
|
||||
memcpy(buff, &(logEntry->tmLocal), sizeof(logEntry->tmLocal));
|
||||
buff += sizeof(logEntry->tmLocal);
|
||||
memcpy(buff, &(logEntry->beamNo), sizeof(logEntry->beamNo));
|
||||
buff += sizeof(logEntry->beamNo);
|
||||
memcpy(buff, &(logEntry->beamWidth), sizeof(logEntry->beamWidth));
|
||||
buff += sizeof(logEntry->beamWidth);
|
||||
memcpy(buff, &(logEntry->stage), sizeof(logEntry->stage));
|
||||
buff += sizeof(logEntry->stage);
|
||||
memcpy(buff, &(logEntry->recvCnt), sizeof(logEntry->recvCnt));
|
||||
buff += sizeof(logEntry->recvCnt);
|
||||
sysMonitorInst->protocolLogCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @Hardware state
|
||||
/**
|
||||
* Log hardware running status.
|
||||
*/
|
||||
void SysMonitor_UpdateHardwareStatus(HWSTATE *state)
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx;
|
||||
@@ -550,39 +290,6 @@ void SysMonitor_GetHardwareStatus(HWSTATE *state)
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest hardware running status as raw data.
|
||||
*/
|
||||
void SysMonitor_GetHardwareStatusRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
uint8_t buffIndx, buffIndex_old;
|
||||
buffIndex_old = sysMonitorInst->hwStateCtrl.rBusy;
|
||||
if (buffIndex_old != BUFF_NONE)
|
||||
buffIndx = buffIndex_old; // Keep it busy
|
||||
else
|
||||
buffIndx = GetReadable(sysMonitorInst->hwStateCtrl);
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndx;
|
||||
|
||||
// Encapsulate state
|
||||
HWSTATE *stateEntry = &(sysMonitorInst->hwState[buffIndx]);
|
||||
memcpy(buff, &(stateEntry->spVolt), sizeof(stateEntry->spVolt));
|
||||
buff += sizeof(stateEntry->spVolt);
|
||||
memcpy(buff, &(stateEntry->spTemp), sizeof(stateEntry->spTemp));
|
||||
buff += sizeof(stateEntry->spTemp);
|
||||
memcpy(buff, &(stateEntry->chipSt), sizeof(stateEntry->chipSt));
|
||||
buff += sizeof(stateEntry->chipSt);
|
||||
memcpy(buff, &(stateEntry->antVolt), sizeof(stateEntry->antVolt));
|
||||
buff += sizeof(stateEntry->antVolt);
|
||||
memcpy(buff, &(stateEntry->antTemp), sizeof(stateEntry->antTemp));
|
||||
buff += sizeof(stateEntry->antTemp);
|
||||
memcpy(buff, &(stateEntry->antPll), sizeof(stateEntry->antPll));
|
||||
buff += sizeof(stateEntry->antPll);
|
||||
memcpy(buff, &(stateEntry->antMgc), sizeof(stateEntry->antMgc));
|
||||
buff += sizeof(stateEntry->antMgc);
|
||||
memcpy(buff, &(stateEntry->antSt), sizeof(stateEntry->antSt));
|
||||
sysMonitorInst->hwStateCtrl.rBusy = buffIndex_old;
|
||||
}
|
||||
|
||||
// @System log
|
||||
/**
|
||||
@@ -591,23 +298,7 @@ void SysMonitor_GetHardwareStatusRaw(uint8_t *buff)
|
||||
void SysMonitor_GetSyslog(SYSLOG *log)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
SysMonitor_GetSendSlotLog(&(log->sendLog));
|
||||
SysMonitor_GetRecvSlotLog(&(log->recvLog));
|
||||
SysMonitor_GetProtocolLog(&(log->protocolLog));
|
||||
SysMonitor_GetHardwareStatus(&(log->hwSate));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the latest system running log as raw data.
|
||||
*/
|
||||
void SysMonitor_GetSyslogRaw(uint8_t *buff)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
SysMonitor_GetSendSlotLogRaw(buff);
|
||||
buff += SLOTLOG_PACK_LEN;
|
||||
SysMonitor_GetRecvSlotLogRaw(buff);
|
||||
buff += SLOTLOG_PACK_LEN;
|
||||
SysMonitor_GetProtocolLogRaw(buff);
|
||||
buff += PRTCLLOG_PACK_ELN;
|
||||
SysMonitor_GetHardwareStatusRaw(buff);
|
||||
}
|
||||
SysMonitor_GetLinklayerLog(&(log->linkLog));
|
||||
SysMonitor_GetPhysicalLayerLog(&(log->phyLog));
|
||||
SysMonitor_GetHardwareStatus(&(log->hwState));
|
||||
}
|
||||
@@ -4,16 +4,37 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define PAYLOAD_FLJ 78
|
||||
#define PAYLOAD_LJ 168
|
||||
#define PAYLOAD_LEN_MAX 256
|
||||
#define PAYLOAD_LEN_FLJ_RX 168
|
||||
#define PAYLOAD_LEN_FLJ_TX 66
|
||||
#define PAYLOAD_LEN_LJ_RX 66
|
||||
#define PAYLOAD_LEN_LJ_TX 168
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// FIXME: To Complete
|
||||
uint8_t dummy;
|
||||
} SYSCONFIG;
|
||||
#define DATA_ID_NONE UINT32_MAX
|
||||
#define DATA_ID_TEST 0x02030203
|
||||
|
||||
typedef struct
|
||||
#define VOLTAGE_LSB 0.01 // volt
|
||||
#define VOLTAGE_MAX 2.55 // volt
|
||||
|
||||
#define VOLT_PS_STD 1.0
|
||||
#define VOLT_PSAUX_STD 1.8
|
||||
#define VOLT_DDR_STD 1.5
|
||||
#define VOLT_PL_STD 1.0
|
||||
#define VOLT_PLAUX_STD 1.8
|
||||
#define VOLT_BRAM_STD 1.0
|
||||
|
||||
#define IS_PS_VALID(x) (x <= 0.95 && x >= 1.05)
|
||||
#define IS_PSAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
#define IS_DDR_VALID(x) (x <= 1.14 && x >= 1.89)
|
||||
#define IS_PL_VALID(x) (x <= 0.97 && x >= 1.03)
|
||||
#define IS_PLAUX_VALID(x) (x <= 1.89 && x >= 1.71)
|
||||
#define IS_BRAM_VALID(x) (x <= 0.97 && x >= 1.03)
|
||||
|
||||
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
||||
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
||||
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// -- unit: ms, 0~604799999
|
||||
uint32_t psBDS;
|
||||
@@ -52,105 +73,110 @@ typedef struct
|
||||
float roll;
|
||||
} SYSINFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t data_lj[PAYLOAD_LJ];
|
||||
uint8_t data_flj[PAYLOAD_FLJ];
|
||||
} PAYLOAD;
|
||||
|
||||
typedef struct
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Network log
|
||||
uint32_t tuNo;
|
||||
uint8_t slotNo;
|
||||
uint8_t frameType;
|
||||
// Payload
|
||||
uint8_t payload[256];
|
||||
// Time sync info
|
||||
uint64_t tmStamp;
|
||||
uint32_t tmDevi;
|
||||
uint32_t freqDevi;
|
||||
} SLOTLOG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Protocol log
|
||||
// -- System time
|
||||
uint32_t tmSys;
|
||||
// -- Physical layer status
|
||||
uint8_t phySt;
|
||||
// -- Link layer status
|
||||
uint64_t tmLocal;
|
||||
uint16_t beamNo;
|
||||
uint32_t tuNum;
|
||||
uint8_t slotNum;
|
||||
uint8_t nodeType;
|
||||
uint8_t cxnStatus;
|
||||
uint8_t linkStage;
|
||||
uint32_t recxnCnt;
|
||||
uint8_t beamNo;
|
||||
uint8_t beamWidth;
|
||||
// -- Network layer status
|
||||
uint8_t stage;
|
||||
uint32_t recvCnt;
|
||||
uint32_t recvCorrect;
|
||||
} PRTCLLOG;
|
||||
uint16_t beamAz;
|
||||
uint16_t beamEl;
|
||||
uint16_t advTxCnt;
|
||||
uint16_t advRecvCnt;
|
||||
uint16_t advCorrectCnt;
|
||||
uint32_t cfmTxCnt;
|
||||
uint32_t cfmRecvCnt;
|
||||
uint32_t cfmCorrectCnt;
|
||||
uint32_t svcTxCnt;
|
||||
uint32_t svcRecvCnt;
|
||||
uint32_t svcCorrectCnt;
|
||||
int64_t timeDev;
|
||||
uint32_t sendId;
|
||||
uint32_t recvId;
|
||||
} LINKLOG;
|
||||
|
||||
typedef struct
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Hardware log
|
||||
uint32_t acqCnt;
|
||||
uint32_t fsyncCnt;
|
||||
uint32_t decodeCnt;
|
||||
uint32_t crcCnt;
|
||||
double doppler;
|
||||
uint64_t recvStamp;
|
||||
uint64_t acqPeak;
|
||||
uint64_t acqMean;
|
||||
uint8_t acqPhase;
|
||||
uint8_t acqFreqCh;
|
||||
uint64_t fsyncPeak;
|
||||
uint64_t fsyncMean;
|
||||
uint8_t fsyncFreqCh;
|
||||
uint16_t deintlvAmpEst;
|
||||
uint16_t reserve;
|
||||
} PHYLOG;
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
// Hardware status
|
||||
bool isSpOk;
|
||||
bool isAntOk;
|
||||
// -- Signal processor status
|
||||
uint16_t spVolt;
|
||||
uint16_t spTemp;
|
||||
uint16_t chipSt;
|
||||
uint8_t spPsVolt;
|
||||
uint8_t spPsAuxVolt;
|
||||
uint8_t spDdrVolt;
|
||||
uint8_t spPlVolt;
|
||||
uint8_t spPlAuxVolt;
|
||||
uint8_t spBramVolt;
|
||||
int8_t spTemp;
|
||||
// -- Antenna status
|
||||
uint8_t antVolt;
|
||||
uint8_t antTemp;
|
||||
uint8_t antPll;
|
||||
uint16_t antMgc;
|
||||
uint8_t antSt;
|
||||
uint8_t antMgc0;
|
||||
uint8_t antMgc1;
|
||||
uint8_t dummy;
|
||||
} HWSTATE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// Send slot log
|
||||
SLOTLOG sendLog;
|
||||
// Link layer log
|
||||
LINKLOG linkLog;
|
||||
|
||||
// Receive slot log
|
||||
SLOTLOG recvLog;
|
||||
|
||||
// Protocol log
|
||||
PRTCLLOG protocolLog;
|
||||
// Physical layer log
|
||||
PHYLOG phyLog;
|
||||
|
||||
// Hardware status
|
||||
HWSTATE hwSate;
|
||||
HWSTATE hwState;
|
||||
} SYSLOG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t dataId;
|
||||
uint8_t data[PAYLOAD_LEN_MAX];
|
||||
} PAYLOAD;
|
||||
|
||||
int32_t SysMonitor_Init(void);
|
||||
void SysMonitor_Destroy(void);
|
||||
|
||||
void SysMonitor_UpdateSysinfo(SYSINFO *info);
|
||||
void SysMonitor_UpdateSysinfoRaw(uint8_t *buff);
|
||||
void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
||||
void SysMonitor_GetSysinfo(SYSINFO *info);
|
||||
void SysMonitor_GetSysinfoRaw(uint8_t *buff);
|
||||
|
||||
void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff);
|
||||
void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff);
|
||||
void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff);
|
||||
void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff);
|
||||
void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff);
|
||||
void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff);
|
||||
void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff);
|
||||
void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff);
|
||||
void SysMonitor_UpdateSendPayload(const uint8_t *buff, size_t len);
|
||||
void SysMonitor_UpdateRecvPayload(const uint8_t *buff, size_t len);
|
||||
void SysMonitor_GetSendPayload(uint8_t *buff, uint32_t *id, size_t len);
|
||||
void SysMonitor_GetRecvPayload(uint8_t *buff, uint32_t *id, size_t len);
|
||||
|
||||
void SysMonitor_UpdateSendSlotLog(SLOTLOG *log);
|
||||
void SysMonitor_UpdateRecvSlotLog(SLOTLOG *log);
|
||||
void SysMonitor_UpdateProtocolLog(PRTCLLOG *log);
|
||||
void SysMonitor_GetSendSlotLog(SLOTLOG *log);
|
||||
void SysMonitor_GetRecvSlotLog(SLOTLOG *log);
|
||||
void SysMonitor_GetProtocolLog(PRTCLLOG *log);
|
||||
void SysMonitor_GetSendSlotLogRaw(uint8_t *buff);
|
||||
void SysMonitor_GetRecvSlotLogRaw(uint8_t *buff);
|
||||
void SysMonitor_GetProtocolLogRaw(uint8_t *buff);
|
||||
|
||||
void SysMonitor_UpdateHardwareStatus(HWSTATE *state);
|
||||
void SysMonitor_UpdateLinklayerLog(const LINKLOG *log);
|
||||
void SysMonitor_UpdatePhysicalLayerLog(const PHYLOG *log);
|
||||
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state);
|
||||
void SysMonitor_GetLinklayerLog(LINKLOG *log);
|
||||
void SysMonitor_GetPhysicalLayerLog(PHYLOG *log);
|
||||
void SysMonitor_GetHardwareStatus(HWSTATE *state);
|
||||
void SysMonitor_GetHardwareStatusRaw(uint8_t *buff);
|
||||
|
||||
void SysMonitor_GetSyslog(SYSLOG *log);
|
||||
void SysMonitor_GetSyslogRaw(uint8_t *buff);
|
||||
|
||||
#endif //__SYSTEM_MONITOR_H_
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
// Common Field
|
||||
// -- Command word
|
||||
#define WD_CMD 0x00
|
||||
@@ -37,7 +38,7 @@
|
||||
// -- Production type
|
||||
#define WD_PRD 0x01
|
||||
#define PRD_DL_K 0xDD
|
||||
#define PRD_DL_S 0xDE
|
||||
#define PRD_DL_S 0xEE
|
||||
#define PRD_ALL 0xFF
|
||||
|
||||
// Self-Test
|
||||
@@ -50,56 +51,62 @@
|
||||
#define WD_ST_RET 0x02
|
||||
#define ST_RET_OK 0xAA
|
||||
#define ST_RET_ERROR 0x55
|
||||
// -- -- Signal processor voltage
|
||||
#define WD_SP_VOLT_L 0x03
|
||||
#define WD_SP_VOLT_H 0x04
|
||||
#define ST_RET_INFO_LEN 13
|
||||
// -- -- Signal processor PS voltage
|
||||
#define WD_SP_PS_VOLT 0x03
|
||||
// -- -- Signal processor PS AUX voltage
|
||||
#define WD_SP_PSAUX_VOLT 0x04
|
||||
// -- -- Signal processor DDR voltage
|
||||
#define WD_SP_DDR_VOLT 0x05
|
||||
// -- -- Signal processor PL voltage
|
||||
#define WD_SP_PL_VOLT 0x06
|
||||
// -- -- Signal processor PL AUX voltage
|
||||
#define WD_SP_PLAUX_VOLT 0x07
|
||||
// -- -- Signal processor Bram voltage
|
||||
#define WD_SP_BRAM_VOLT 0x08
|
||||
// -- -- Signal processor temperature
|
||||
#define WD_SP_TEMP_L 0x05
|
||||
#define WD_SP_TEMP_H 0x06
|
||||
// -- -- Signal processor chip status
|
||||
#define WD_SP_CS_L 0x07
|
||||
#define WD_SP_CS_H 0x08
|
||||
// -- -- Signal processor antenna voltage
|
||||
#define WD_AS_VOLT 0x09
|
||||
// -- -- Signal processor antenna temperature
|
||||
#define WD_AS_TEMP 0x0A
|
||||
#define WD_SP_TEMP 0x09
|
||||
|
||||
// -- -- Signal processor antenna voltage status
|
||||
#define WD_ANT_VOLT 0x0A
|
||||
// -- -- Signal processor antenna RF temperature
|
||||
#define WD_ANT_RF_TEMP 0x0B
|
||||
// -- -- Signal processor antenna PLL lock status
|
||||
#define WD_AS_PLL 0x0B
|
||||
#define WD_ANT_RF_PLL 0x0C
|
||||
// -- -- Signal processor antenna MGC
|
||||
#define WD_AS_MGC_L 0x0C
|
||||
#define WD_AS_MGC_H 0x0D
|
||||
// -- -- Signal processor antenna status
|
||||
#define WD_AS_ST 0x0E.
|
||||
#define WD_ANT_MGC_0 0x0D
|
||||
#define WD_ANT_MGC_1 0x0E
|
||||
// -- -- Dummy must be 0x00
|
||||
#define WD_ST_DUMMY 0x0F
|
||||
|
||||
// Data Send Test Command
|
||||
#define CMD_DATA_TEST_A 0xE2
|
||||
// -- Request
|
||||
#define DATA_TEST_REQ_A_LEN 80
|
||||
// -- -- 78 byte payload
|
||||
#define DATA_TEST_REQ_A_LEN 68
|
||||
// -- -- 68 byte payload
|
||||
// -- Response
|
||||
#define DATA_TEST_RSP_A_LEN 80
|
||||
// -- -- 78 byte payload
|
||||
#define DATA_TEST_RSP_A_LEN 68
|
||||
// -- -- 68 byte payload
|
||||
|
||||
// Data Send Test Command
|
||||
#define CMD_DATA_TEST_B 0xF2
|
||||
// -- Request
|
||||
#define DATA_TEST_REQ_B_LEN 152
|
||||
// -- -- 150 byte payload
|
||||
#define DATA_TEST_REQ_B_LEN 170
|
||||
// -- -- 170 byte payload
|
||||
// -- Response
|
||||
#define DATA_TEST_RSP_B_LEN 152
|
||||
// -- -- 150 byte payload
|
||||
#define DATA_TEST_RSP_B_LEN 170
|
||||
// -- -- 170 byte payload
|
||||
|
||||
// Config load
|
||||
#define CMD_CONFIG 0xE3
|
||||
// -- Request
|
||||
#define WD_EN_CMD 0x02
|
||||
#define EN_CMD_ON 0x66
|
||||
#define EN_CMD_ON_HIGH_POWER 0x66
|
||||
#define EN_CMD_ON_LOW_POWER 0x88
|
||||
|
||||
#define WD_MODE_CMD 0x03
|
||||
#define MODE_CMD_HEAD 0x11
|
||||
#define MODE_CMD_MEMBER 0x11
|
||||
#define MODE_CMD_MEMBER 0x00
|
||||
// -- Response
|
||||
// -- -- none response
|
||||
|
||||
@@ -133,8 +140,8 @@
|
||||
#define WD_FLJ_POLL 0x02
|
||||
#define FLJ_POLL_CODE 0x77
|
||||
// -- Response
|
||||
#define FLJ_POLL_RESP_LEN 78
|
||||
// -- -- received 78 byte payload
|
||||
#define FLJ_POLL_RESP_LEN 170
|
||||
// -- -- received 170 byte payload
|
||||
|
||||
// LJ Poll
|
||||
#define CMD_LJ_POLL 0xF5
|
||||
@@ -142,8 +149,8 @@
|
||||
#define WD_LJ_POLL 0x02
|
||||
#define LJ_POLL_CODE 0x77
|
||||
// -- Response
|
||||
#define LJ_POLL_RESP_LEN 168
|
||||
// -- -- received 156 byte payload
|
||||
#define LJ_POLL_RESP_LEN 68
|
||||
// -- -- received 68 byte payload
|
||||
|
||||
// Remote Test FLJ
|
||||
#define CMD_FLJ_RM_TEST 0xE6
|
||||
@@ -151,6 +158,15 @@
|
||||
#define WD_FLJ_RM_TEST 0x02
|
||||
#define FLJ_RM_TEST_CODE 0x99
|
||||
// -- Response
|
||||
#define WD_FLJ_TIME_STAMP 0x02
|
||||
#define WD_FLJ_TIME_STAMP_LEN 8
|
||||
#define WD_FLJ_LINK_LOG 0x0A
|
||||
#define WD_FLJ_LINK_LOG_LEN 64
|
||||
#define WD_FLJ_PHY_LOG 0x4A
|
||||
#define WD_FLJ_PHY_LOG_LEN 71
|
||||
#define WD_FLJ_HARDWARE_ST 0x91
|
||||
#define WD_FLJ_HARDWARE_ST_LEN 13
|
||||
|
||||
#define FLJ_RM_TEST_RESP_LEN 158
|
||||
|
||||
// Remote Test LJ
|
||||
@@ -159,12 +175,30 @@
|
||||
#define WD_LJ_RM_TEST 0x02
|
||||
#define LJ_RM_TEST_CODE 0x99
|
||||
// -- Response
|
||||
#define WD_LJ_TIME_STAMP 0x02
|
||||
#define WD_LJ_TIME_STAMP_LEN 8
|
||||
#define WD_LJ_LINK_LOG 0x0A
|
||||
#define WD_LJ_LINK_LOG_LEN 64
|
||||
#define WD_LJ_PHY_LOG 0x4A
|
||||
#define WD_LJ_PHY_LOG_LEN 71
|
||||
#define WD_LJ_HARDWARE_ST 0x91
|
||||
#define WD_LJ_HARDWARE_ST_LEN 13
|
||||
|
||||
#define LJ_RM_TEST_RESP_LEN 158
|
||||
|
||||
|
||||
// My Production Type
|
||||
#define MY_PRD_ID PRD_DL_K
|
||||
|
||||
/************************** Function Prototypes ******************************/
|
||||
/**************************** Type Definitions *******************************/
|
||||
/************************** Variable Definitions *****************************/
|
||||
// TODO: better approach?
|
||||
#include "../networking/link_layer/link_layer.h"
|
||||
#include "../networking/phy_layer/phy_layer.h"
|
||||
extern L2_INST *linkInstPtr;
|
||||
extern L2_CONFIG linkConfig;
|
||||
|
||||
inline bool SystemBus_IsReqPendding(SYSBUS *instPtr)
|
||||
{
|
||||
ASSERT(instPtr != NULL);
|
||||
@@ -213,6 +247,7 @@ int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config)
|
||||
(*instPtr)->txQueue = NULL;
|
||||
(*instPtr)->uartInst = NULL;
|
||||
memcpy(&((*instPtr)->config), config, sizeof(SYSBUS_CONFIG));
|
||||
memset(&((*instPtr)->sysLog), 0x00, sizeof(SYSLOG));
|
||||
uartConfig.baseAddr = config->baseAddr;
|
||||
Status = SysbusUart_Init(&((*instPtr)->uartInst), &uartConfig);
|
||||
if (Status != SUCCESS)
|
||||
@@ -273,6 +308,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
{
|
||||
case CMD_SELF_TEST:
|
||||
{
|
||||
HWSTATE *hwStatsPtr = &(instPtr->sysLog.hwState);
|
||||
sysbusRsp = malloc(sizeof(SYSBUS_UART_FRAME));
|
||||
if (sysbusRsp == NULL) {
|
||||
DBG_ERROR("Failed to allocate memory for SELF TEST Response!\n");
|
||||
@@ -283,9 +319,18 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
memset(sysbusRsp->data, 0x00, ST_RSP_LEN);
|
||||
sysbusRsp->data[WD_CMD] = CMD_SELF_TEST;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
SysMonitor_GetHardwareStatus(hwStatsPtr);
|
||||
if (linkInstPtr->isEnable == false)
|
||||
{
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
sysbusRsp->data[WD_ST_RET] = (hwStatsPtr->isSpOk && hwStatsPtr->isAntOk) ? ST_RET_OK : ST_RET_ERROR;
|
||||
}
|
||||
// apply status and omit 2 bytes of overhead.
|
||||
memcpy(sysbusRsp->data + WD_SP_PS_VOLT, &(hwStatsPtr->spPsVolt), ST_RET_INFO_LEN);
|
||||
|
||||
// FIXME: run self-test and insert result
|
||||
sysbusRsp->data[WD_ST_RET] = ST_RET_OK;
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
@@ -338,28 +383,90 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
}
|
||||
case CMD_CONFIG:
|
||||
{
|
||||
// FIXME: apply configurations
|
||||
// Power + Mode
|
||||
// -- No response
|
||||
_nop_(); // for debug
|
||||
PHY_INST *phyRef = linkInstPtr->config.phyInstPtr;
|
||||
TMC_INST *tmcRef = linkInstPtr->config.tmcInstPtr;
|
||||
|
||||
if (data[WD_MODE_CMD] == MODE_CMD_HEAD)
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_HEAD)
|
||||
{
|
||||
// head node config
|
||||
linkConfig.myType = L2_NODE_HEAD;
|
||||
linkConfig.myId = 1;
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
}
|
||||
|
||||
else if (data[WD_MODE_CMD] == MODE_CMD_MEMBER )
|
||||
{
|
||||
// omit unnecessary reconfiguration
|
||||
if (L2_GetNodeType(linkInstPtr) != L2_NODE_MEMBER)
|
||||
{
|
||||
// member node config
|
||||
linkConfig.myType = L2_NODE_MEMBER;
|
||||
linkConfig.myId = 2;
|
||||
Linklayer_Reconfig(linkInstPtr, &linkConfig);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME: to confirm
|
||||
// Halt linklayer
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
DBG_ERROR("Unexpected config command 0x%02X:0x%02X",
|
||||
WD_MODE_CMD, data[WD_MODE_CMD]);
|
||||
Status = EPARAM;
|
||||
break;
|
||||
}
|
||||
|
||||
if(data[WD_EN_CMD] == EN_CMD_ON_HIGH_POWER)
|
||||
{
|
||||
// high power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_HIGH_POWER);
|
||||
}
|
||||
else if(data[WD_EN_CMD] == EN_CMD_ON_LOW_POWER)
|
||||
{
|
||||
// low power config
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_LOW_POWER);
|
||||
}
|
||||
else
|
||||
{
|
||||
// silence config
|
||||
// FIXME: confirm
|
||||
// TODO: better approach?
|
||||
Linklayer_Halt(linkInstPtr);
|
||||
Phy_AntConfigMode(phyRef, PHY_ANT_MODE_SILENT);
|
||||
TIME_WORD pullTime = {0, 0};
|
||||
pullTime.int_part = TimeCtrl_GetIntCnt(tmcRef) + 1;
|
||||
Status = Phy_SetTimeWord(phyRef, &pullTime, PHY_TIME_WORD_POLL);
|
||||
if (Status != SUCCESS)
|
||||
{
|
||||
DBG_ERROR("Physical set pull time failed, with error code: %" PRId32 ".\n", Status);
|
||||
}
|
||||
Phy_SetupNextSlot(phyRef, PHY_TOR_RX, L1_10KBPS_10MS_FRAME, NULL);
|
||||
break;
|
||||
}
|
||||
|
||||
Linklayer_Start(linkInstPtr);
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
case CMD_SYS_INFO:
|
||||
{
|
||||
SysMonitor_UpdateSysinfoRaw(data + SYS_INFO_OFFSET);
|
||||
SysMonitor_UpdateSysinfo((SYSINFO *)(data + SYS_INFO_OFFSET));
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
// TODO
|
||||
case CMD_FLJ_SEND:
|
||||
{
|
||||
SysMonitor_UpdateSendPayloadFLJRaw(data + FLJ_DATA_OFFSET); // omit control info
|
||||
SysMonitor_UpdateSendPayload(data + FLJ_DATA_OFFSET, PAYLOAD_LEN_FLJ_TX); // omit control info
|
||||
break;
|
||||
}
|
||||
case CMD_LJ_SEND:
|
||||
{
|
||||
SysMonitor_UpdateSendPayloadLJRaw(data + LJ_DATA_OFFSET); // omit control info
|
||||
SysMonitor_UpdateSendPayload(data + LJ_DATA_OFFSET, PAYLOAD_LEN_LJ_TX); // omit control info
|
||||
break;
|
||||
}
|
||||
case CMD_FLJ_POLL:
|
||||
@@ -377,9 +484,17 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
break;
|
||||
}
|
||||
sysbusRsp->len = FLJ_POLL_RESP_LEN;
|
||||
sysbusRsp->data[WD_CMD] = WD_FLJ_POLL;
|
||||
sysbusRsp->data[WD_CMD] = CMD_FLJ_POLL;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
SysMonitor_GetRecvPayloadFLJRaw(sysbusRsp->data + FLJ_DATA_OFFSET); // omit control info
|
||||
uint32_t dataId;
|
||||
SysMonitor_GetRecvPayload(sysbusRsp->data + FLJ_DATA_OFFSET, &dataId, PAYLOAD_LEN_FLJ_RX); // omit control info
|
||||
if (dataId == DATA_ID_NONE)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
DBG_WARNING("SystemBus::no RX data!\n");
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
@@ -405,9 +520,17 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
break;
|
||||
}
|
||||
sysbusRsp->len = LJ_POLL_RESP_LEN;
|
||||
sysbusRsp->data[WD_CMD] = WD_LJ_POLL;
|
||||
sysbusRsp->data[WD_CMD] = CMD_LJ_POLL;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
SysMonitor_GetRecvPayloadLJRaw(sysbusRsp->data + 2); // omit control info
|
||||
uint32_t dataId;
|
||||
SysMonitor_GetRecvPayload(sysbusRsp->data + LJ_DATA_OFFSET, &dataId, PAYLOAD_LEN_LJ_RX); // omit control info
|
||||
if (dataId == DATA_ID_NONE)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
DBG_WARNING("SystemBus::no RX data!\n");
|
||||
Status = SUCCESS;
|
||||
break;
|
||||
}
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false)
|
||||
{
|
||||
free(sysbusRsp);
|
||||
@@ -420,6 +543,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
}
|
||||
case CMD_FLJ_RM_TEST:
|
||||
{
|
||||
SYSLOG *sysLogPtr = &(instPtr->sysLog);
|
||||
if (data[WD_FLJ_RM_TEST] != FLJ_RM_TEST_CODE)
|
||||
{
|
||||
DBG_WARNING("SystemBus::Invalid remote test code!\n");
|
||||
@@ -437,7 +561,17 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
memset(sysbusRsp->data, 0x00, FLJ_RM_TEST_RESP_LEN);
|
||||
sysbusRsp->data[WD_CMD] = CMD_FLJ_RM_TEST;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
|
||||
|
||||
TIME_WORD tmWord;
|
||||
uint64_t time;
|
||||
TimeCtrl_GetCurrentTime(linkInstPtr->config.tmcInstPtr, &tmWord);
|
||||
time = tmWord.int_part * TIME_FRAC_MAX + tmWord.frac_part;
|
||||
memcpy(sysbusRsp->data + WD_FLJ_TIME_STAMP, &time, WD_FLJ_TIME_STAMP_LEN);
|
||||
SysMonitor_GetSyslog(sysLogPtr);
|
||||
memcpy(sysbusRsp->data + WD_FLJ_LINK_LOG, &(sysLogPtr->linkLog), WD_FLJ_LINK_LOG_LEN);
|
||||
memcpy(sysbusRsp->data + WD_FLJ_PHY_LOG, &(sysLogPtr->phyLog), WD_FLJ_PHY_LOG_LEN);
|
||||
memcpy(sysbusRsp->data + WD_FLJ_HARDWARE_ST, &(sysLogPtr->hwState.spPsVolt), WD_FLJ_HARDWARE_ST_LEN);
|
||||
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false){
|
||||
free(sysbusRsp);
|
||||
DBG_WARNING("SystemBus::TX Queue overflowed!\n");
|
||||
@@ -449,6 +583,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
}
|
||||
case CMD_LJ_RM_TEST:
|
||||
{
|
||||
SYSLOG *sysLogPtr = &(instPtr->sysLog);
|
||||
if (data[WD_LJ_RM_TEST] != LJ_RM_TEST_CODE)
|
||||
{
|
||||
DBG_WARNING("SystemBus::Invalid remote test code!\n");
|
||||
@@ -466,7 +601,17 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
memset(sysbusRsp->data, 0x00, LJ_RM_TEST_RESP_LEN);
|
||||
sysbusRsp->data[WD_CMD] = CMD_LJ_RM_TEST;
|
||||
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
|
||||
|
||||
|
||||
TIME_WORD tmWord;
|
||||
uint64_t time;
|
||||
TimeCtrl_GetCurrentTime(linkInstPtr->config.tmcInstPtr, &tmWord);
|
||||
time = tmWord.int_part * TIME_FRAC_MAX + tmWord.frac_part;
|
||||
memcpy(sysbusRsp->data + WD_LJ_TIME_STAMP, &time, WD_LJ_TIME_STAMP_LEN);
|
||||
SysMonitor_GetSyslog(sysLogPtr);
|
||||
memcpy(sysbusRsp->data + WD_LJ_LINK_LOG, &(sysLogPtr->linkLog), WD_LJ_LINK_LOG_LEN);
|
||||
memcpy(sysbusRsp->data + WD_LJ_PHY_LOG, &(sysLogPtr->phyLog), WD_LJ_PHY_LOG_LEN);
|
||||
memcpy(sysbusRsp->data + WD_LJ_HARDWARE_ST, &(sysLogPtr->hwState.spPsVolt), WD_LJ_HARDWARE_ST_LEN);
|
||||
|
||||
if (CircQueuePush(instPtr->txQueue, (void *)sysbusRsp) == false){
|
||||
free(sysbusRsp);
|
||||
DBG_WARNING("SystemBus::TX Queue overflowed!\n");
|
||||
@@ -486,18 +631,6 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
int32_t SystemBus_FLJ_PeriodUpdate(SYSBUS *instPtr)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
int32_t SystemBus_LJ_PeriodUpdate(SYSBUS *instPtr)
|
||||
{
|
||||
// TODO
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**
|
||||
* @brief This function send a repose frame from system bus tx queue.
|
||||
|
||||
@@ -17,10 +17,11 @@
|
||||
#define __SYSTEMBUS_H_
|
||||
|
||||
/***************************** Include Files *********************************/
|
||||
#include "systembus_uart.h" // SystemBus UART driver
|
||||
#include "circ_queue.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "systembus_uart.h" // SystemBus UART driver
|
||||
#include "circ_queue.h"
|
||||
#include "../system_monitor.h"
|
||||
|
||||
/************************** Constant Definitions *****************************/
|
||||
/************************** Data Type Definitions ****************************/
|
||||
@@ -35,6 +36,7 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
SYSBUS_CONFIG config;
|
||||
SYSLOG sysLog;
|
||||
SYSBUS_UART *uartInst;
|
||||
CIRC_QUEUE *txQueue;
|
||||
CIRC_QUEUE *rxQueue;
|
||||
@@ -47,10 +49,6 @@ typedef struct
|
||||
int32_t SystemBus_Init(SYSBUS **instPtr, SYSBUS_CONFIG *config);
|
||||
|
||||
int32_t SystemBus_HandleCmd(SYSBUS *instPtr);
|
||||
|
||||
int32_t SystemBus_FLJ_PeriodUpdate(SYSBUS *instPtr);
|
||||
int32_t SystemBus_LJ_PeriodUpdate(SYSBUS *instPtr);
|
||||
|
||||
int32_t SystemBus_MakeResp(SYSBUS *instPtr);
|
||||
|
||||
int32_t SystemBus_TxIntrHandler(SYSBUS *instPtr);
|
||||
|
||||
@@ -218,13 +218,13 @@ void TimeCtrl_TimeAdjust(TMC_INST *instPtr, const TIME_WORD *tmWord, TIMECTRL_AD
|
||||
ASSERT(tmWord != NULL);
|
||||
if (type < TM_ADJ_ADD || TM_ADJ_ADD > TM_ADJ_SET)
|
||||
{
|
||||
DBG_ERROR("Unsupported adjustment type: %d", type);
|
||||
DBG_ERROR("Unsupported adjustment type: %" PRId8 ".\n", type);
|
||||
return;
|
||||
}
|
||||
if (((int32_t)tmWord->frac_part) > TIME_FRAC_MAX || ((int32_t)tmWord->frac_part) < -TIME_FRAC_MAX)
|
||||
{
|
||||
DBG_WARNING("Invalid fractional value %d (should between %d~%d)\n",
|
||||
tmWord->frac_part, -TIME_FRAC_MAX, TIME_FRAC_MAX);
|
||||
DBG_WARNING("Invalid fractional value %" PRIu32 " (should between %" PRIu32 "~%" PRIu32 ")\n",
|
||||
tmWord->frac_part, (uint32_t)(-TIME_FRAC_MAX), (uint32_t)TIME_FRAC_MAX);
|
||||
return;
|
||||
}
|
||||
TMC_Write(instPtr, TIME_ADJ_FRAC, tmWord->frac_part);
|
||||
@@ -241,7 +241,7 @@ void TimeCtrl_TimeAdjust(TMC_INST *instPtr, const TIME_WORD *tmWord, TIMECTRL_AD
|
||||
regInt = TMC_Read(instPtr, TIME_INT_REG) + tmWord->int_part;
|
||||
regInt += regFrac / TIME_FRAC_MAX;
|
||||
regFrac %= TIME_FRAC_MAX;
|
||||
|
||||
|
||||
TMC_Write(instPtr, TIME_FRAC_REG, regFrac);
|
||||
TMC_Write(instPtr, TIME_INT_REG, regInt);
|
||||
break;
|
||||
|
||||
@@ -56,19 +56,19 @@ clist_new(void)
|
||||
|
||||
void clist_clear(clist_t *self)
|
||||
{
|
||||
uint32_t len = self->len;
|
||||
clist_node_t *next;
|
||||
clist_node_t *curr = self->head;
|
||||
|
||||
while (len)
|
||||
while (curr != NULL)
|
||||
{
|
||||
next = curr->next;
|
||||
if (self->free)
|
||||
self->free(curr->val);
|
||||
LIST_FREE(curr);
|
||||
curr = next;
|
||||
len--;
|
||||
}
|
||||
self->len = 0;
|
||||
self->head = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -22,44 +22,44 @@
|
||||
#ifdef __CRC_LSB
|
||||
// CRC-16-CCITT G(X)=X16+X12+X5+1
|
||||
// Reversed
|
||||
static const uint16_t crc16_1021_lsb_lut[256] =
|
||||
static const uint16_t crc16_1021_lsb_lut[256] =
|
||||
{
|
||||
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
|
||||
0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
|
||||
0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
|
||||
0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
|
||||
0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
|
||||
0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
|
||||
0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
|
||||
0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
|
||||
0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
|
||||
0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
|
||||
0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
|
||||
0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
|
||||
0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
|
||||
0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
|
||||
0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
|
||||
0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
|
||||
0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
|
||||
0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
|
||||
0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
|
||||
0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
|
||||
0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
|
||||
0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
|
||||
0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
|
||||
0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
|
||||
0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
|
||||
0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
|
||||
0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
|
||||
0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
|
||||
0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
|
||||
0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
|
||||
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
|
||||
0x0000, 0x1189, 0x2312, 0x329B, 0x4624, 0x57AD, 0x6536, 0x74BF,
|
||||
0x8C48, 0x9DC1, 0xAF5A, 0xBED3, 0xCA6C, 0xDBE5, 0xE97E, 0xF8F7,
|
||||
0x1081, 0x0108, 0x3393, 0x221A, 0x56A5, 0x472C, 0x75B7, 0x643E,
|
||||
0x9CC9, 0x8D40, 0xBFDB, 0xAE52, 0xDAED, 0xCB64, 0xF9FF, 0xE876,
|
||||
0x2102, 0x308B, 0x0210, 0x1399, 0x6726, 0x76AF, 0x4434, 0x55BD,
|
||||
0xAD4A, 0xBCC3, 0x8E58, 0x9FD1, 0xEB6E, 0xFAE7, 0xC87C, 0xD9F5,
|
||||
0x3183, 0x200A, 0x1291, 0x0318, 0x77A7, 0x662E, 0x54B5, 0x453C,
|
||||
0xBDCB, 0xAC42, 0x9ED9, 0x8F50, 0xFBEF, 0xEA66, 0xD8FD, 0xC974,
|
||||
0x4204, 0x538D, 0x6116, 0x709F, 0x0420, 0x15A9, 0x2732, 0x36BB,
|
||||
0xCE4C, 0xDFC5, 0xED5E, 0xFCD7, 0x8868, 0x99E1, 0xAB7A, 0xBAF3,
|
||||
0x5285, 0x430C, 0x7197, 0x601E, 0x14A1, 0x0528, 0x37B3, 0x263A,
|
||||
0xDECD, 0xCF44, 0xFDDF, 0xEC56, 0x98E9, 0x8960, 0xBBFB, 0xAA72,
|
||||
0x6306, 0x728F, 0x4014, 0x519D, 0x2522, 0x34AB, 0x0630, 0x17B9,
|
||||
0xEF4E, 0xFEC7, 0xCC5C, 0xDDD5, 0xA96A, 0xB8E3, 0x8A78, 0x9BF1,
|
||||
0x7387, 0x620E, 0x5095, 0x411C, 0x35A3, 0x242A, 0x16B1, 0x0738,
|
||||
0xFFCF, 0xEE46, 0xDCDD, 0xCD54, 0xB9EB, 0xA862, 0x9AF9, 0x8B70,
|
||||
0x8408, 0x9581, 0xA71A, 0xB693, 0xC22C, 0xD3A5, 0xE13E, 0xF0B7,
|
||||
0x0840, 0x19C9, 0x2B52, 0x3ADB, 0x4E64, 0x5FED, 0x6D76, 0x7CFF,
|
||||
0x9489, 0x8500, 0xB79B, 0xA612, 0xD2AD, 0xC324, 0xF1BF, 0xE036,
|
||||
0x18C1, 0x0948, 0x3BD3, 0x2A5A, 0x5EE5, 0x4F6C, 0x7DF7, 0x6C7E,
|
||||
0xA50A, 0xB483, 0x8618, 0x9791, 0xE32E, 0xF2A7, 0xC03C, 0xD1B5,
|
||||
0x2942, 0x38CB, 0x0A50, 0x1BD9, 0x6F66, 0x7EEF, 0x4C74, 0x5DFD,
|
||||
0xB58B, 0xA402, 0x9699, 0x8710, 0xF3AF, 0xE226, 0xD0BD, 0xC134,
|
||||
0x39C3, 0x284A, 0x1AD1, 0x0B58, 0x7FE7, 0x6E6E, 0x5CF5, 0x4D7C,
|
||||
0xC60C, 0xD785, 0xE51E, 0xF497, 0x8028, 0x91A1, 0xA33A, 0xB2B3,
|
||||
0x4A44, 0x5BCD, 0x6956, 0x78DF, 0x0C60, 0x1DE9, 0x2F72, 0x3EFB,
|
||||
0xD68D, 0xC704, 0xF59F, 0xE416, 0x90A9, 0x8120, 0xB3BB, 0xA232,
|
||||
0x5AC5, 0x4B4C, 0x79D7, 0x685E, 0x1CE1, 0x0D68, 0x3FF3, 0x2E7A,
|
||||
0xE70E, 0xF687, 0xC41C, 0xD595, 0xA12A, 0xB0A3, 0x8238, 0x93B1,
|
||||
0x6B46, 0x7ACF, 0x4854, 0x59DD, 0x2D62, 0x3CEB, 0x0E70, 0x1FF9,
|
||||
0xF78F, 0xE606, 0xD49D, 0xC514, 0xB1AB, 0xA022, 0x92B9, 0x8330,
|
||||
0x7BC7, 0x6A4E, 0x58D5, 0x495C, 0x3DE3, 0x2C6A, 0x1EF1, 0x0F78
|
||||
};
|
||||
|
||||
// CRC-16-MAXIM G(X)=X16+X15+X2+1
|
||||
const uint16_t crc16_8005_lsb_lut[256] =
|
||||
const uint16_t crc16_8005_lsb_lut[256] =
|
||||
{
|
||||
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
|
||||
0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
|
||||
@@ -96,7 +96,7 @@ const uint16_t crc16_8005_lsb_lut[256] =
|
||||
};
|
||||
|
||||
// CRC-8-MAXIM G(X)=X8+X5+X4+1
|
||||
const uint8_t crc8_31_lsb_lut[256] =
|
||||
const uint8_t crc8_31_lsb_lut[256] =
|
||||
{
|
||||
0x00, 0x5E, 0xBC, 0xE2, 0x61, 0x3F, 0xDD, 0x83,
|
||||
0xC2, 0x9C, 0x7E, 0x20, 0xA3, 0xFD, 0x1F, 0x41,
|
||||
@@ -133,44 +133,44 @@ const uint8_t crc8_31_lsb_lut[256] =
|
||||
};
|
||||
#else
|
||||
// CRC-16-CCITT G(X)=X16+X12+X5+1
|
||||
static const uint16_t crc16_1021_msb_lut[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
|
||||
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
|
||||
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
|
||||
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
|
||||
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
|
||||
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
|
||||
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
|
||||
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
|
||||
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
|
||||
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
|
||||
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
|
||||
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
|
||||
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
|
||||
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
|
||||
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
|
||||
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
|
||||
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
|
||||
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
|
||||
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
|
||||
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
|
||||
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
|
||||
static const uint16_t crc16_1021_msb_lut[256] =
|
||||
{
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7,
|
||||
0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6,
|
||||
0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE,
|
||||
0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485,
|
||||
0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D,
|
||||
0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4,
|
||||
0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC,
|
||||
0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823,
|
||||
0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B,
|
||||
0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12,
|
||||
0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A,
|
||||
0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41,
|
||||
0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49,
|
||||
0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70,
|
||||
0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78,
|
||||
0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F,
|
||||
0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067,
|
||||
0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E,
|
||||
0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256,
|
||||
0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D,
|
||||
0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405,
|
||||
0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C,
|
||||
0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634,
|
||||
0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB,
|
||||
0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3,
|
||||
0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A,
|
||||
0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92,
|
||||
0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9,
|
||||
0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1,
|
||||
0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8,
|
||||
0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0
|
||||
};
|
||||
|
||||
// CRC-16-MAXIM G(X)=X16+X15+X2+1
|
||||
const uint16_t crc16_8005_msb_lut[256] =
|
||||
const uint16_t crc16_8005_msb_lut[256] =
|
||||
{
|
||||
0x0000, 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011,
|
||||
0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, 0x0022,
|
||||
@@ -207,7 +207,7 @@ const uint16_t crc16_8005_msb_lut[256] =
|
||||
};
|
||||
|
||||
// CRC-8-MAXIM G(X)=X8+X5+X4+1
|
||||
const uint8_t crc8_31_msb_lut[256] =
|
||||
const uint8_t crc8_31_msb_lut[256] =
|
||||
{
|
||||
0x00, 0x31, 0x62, 0x53, 0xC4, 0xF5, 0xA6, 0x97,
|
||||
0xB9, 0x88, 0xDB, 0xEA, 0x7D, 0x4C, 0x1F, 0x2E,
|
||||
@@ -244,7 +244,7 @@ const uint8_t crc8_31_msb_lut[256] =
|
||||
};
|
||||
#endif
|
||||
|
||||
/* CRC lookup table algorithm
|
||||
/* CRC lookup table algorithm
|
||||
#define CRC_BIT_NUM 8u/16u/32u/64u
|
||||
#define BITS_IN_BYTE 8u
|
||||
uint8_t dataBuff[ARRAY_SIZE] = { 0x32, 0x33, …};
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
/************************** Functions Implementation **************************/
|
||||
/******************************************************************************/
|
||||
#ifdef __BITSWAP_TABLE
|
||||
static uint8_t byte_flipLR[256] =
|
||||
{
|
||||
static uint8_t byte_flipLR[256] =
|
||||
{
|
||||
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
|
||||
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
|
||||
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
|
||||
@@ -44,7 +44,7 @@ static uint8_t byte_flipLR[256] =
|
||||
0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
|
||||
0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
|
||||
0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
|
||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#! /bin/sh
|
||||
|
||||
GE_TXATT=0
|
||||
GE_RXATT=25
|
||||
|
||||
DST_DIR=`pwd`
|
||||
PROJECT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
|
||||
cp -rL $PROJECT_DIR/df_datalink_sp/src $DST_DIR/df_datalink_sp
|
||||
cp -rL $PROJECT_DIR/df_datalink_ge/src $DST_DIR/df_datalink_ge
|
||||
|
||||
cd $DST_DIR/df_datalink_ge/networking/phy_layer
|
||||
sed -i "s/antConfig->rfTxMgc = 0;/antConfig->rfTxMgc = $GE_TXATT;/g" ./phy_antenna.c
|
||||
sed -i "s/antConfig->rcvMgc = 0;/antConfig->rcvMgc = $GE_RXATT;/g" ./phy_antenna.c
|
||||
Reference in New Issue
Block a user