summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cesar/cp/beacon/ntb/src/ntb.c21
-rw-r--r--cesar/cp/inc/trace.h4
-rw-r--r--cesar/cp/src/trace.c5
3 files changed, 20 insertions, 10 deletions
diff --git a/cesar/cp/beacon/ntb/src/ntb.c b/cesar/cp/beacon/ntb/src/ntb.c
index ff1a5fdaee..b40b02b26b 100644
--- a/cesar/cp/beacon/ntb/src/ntb.c
+++ b/cesar/cp/beacon/ntb/src/ntb.c
@@ -17,10 +17,12 @@
#include "cp/beacon/ntb/inc/context.h"
#include "cp/inc/context.h"
+#include "cp/inc/trace.h"
#include "string.h"
-#define CP_BEACON_NTB_DEFAULT_FACTOR 1000000.0
+#define CP_BEACON_NTB_FE_PPM(fe) \
+ ((u32) ((fe) * 1000000.0))
/** Compute the frequency error.
* \param ctx module context.
@@ -73,6 +75,7 @@ cp_beacon_ntb_offset (cp_t *ctx)
/* Get the delay in system ticks. */
delay_systck = phy_sysdate (ctx->phy) - ctx->ntb.preamble_sysdate [0];
+ CP_TRACE (NTB_SYNC_PROC_DELAY, delay_systck);
if (ctx->ntb.preamble_sysdate[1])
{
@@ -81,7 +84,7 @@ cp_beacon_ntb_offset (cp_t *ctx)
- (ctx->ntb.fe[1] * delay_systck));
}
else
- offset = 0;
+ offset = (s32) (ctx->ntb.bts[0] - ctx->ntb.preamble_date[0]);
return offset;
}
@@ -115,21 +118,23 @@ cp_beacon_ntb_clk_sync (cp_t * ctx, u32 beacon_bts,
cp_beacon_ntb_frequency_error (ctx, beacon_bts, beacon_sys_ltmr);
offset = cp_beacon_ntb_offset (ctx);
+ CP_TRACE (NTB_SYNC, beacon_bts, beacon_sys_ltmr, beacon_sta_ltmr,
+ CP_BEACON_NTB_FE_PPM(ctx->ntb.fe[0]), offset);
+
+ /* Update the u32 "ntb_offset_tck" field (NTB offset). */
+ ctx->mac_config->ntb_offset_tck = (u32) offset;
+
if (ctx->ntb.preamble_sysdate[1])
{
- /* Update the u32 "ntb_offset_tck" field (NTB offset). */
- ctx->mac_config->ntb_offset_tck = offset;
-
/* Update the frequency error in the Phy. */
/* FIXME this should call a SPOC module function to compute all the
* coefficients needed by SPOC.
phy_sysclock_set_freqerror (ctx->phy,
- ctx->ntb.fe[0]
- * CP_BEACON_NTB_DEFAULT_FACTOR);
+ CP_BEACON_NTB_FE_PPM(ctx->ntb.fe[0]));
*/
/* Compute the new numerator. */
- decimal_num = CP_BEACON_NTB_DEFAULT_FACTOR * (ctx->ntb.fe[0] + 1.0);
+ decimal_num = CP_BEACON_NTB_FE_PPM(ctx->ntb.fe[0] + 1.0);
numerator = decimal_num + 0.5;
if (numerator != ctx->ntb.sta_numerator)
{
diff --git a/cesar/cp/inc/trace.h b/cesar/cp/inc/trace.h
index 72aa4053e7..94c66efaf8 100644
--- a/cesar/cp/inc/trace.h
+++ b/cesar/cp/inc/trace.h
@@ -51,7 +51,9 @@ enum
CP_TRACE_CL_INTERF_MME_RX,
CP_TRACE_CCO_ASSOC,
CP_TRACE_CCO_ASSOC_RENEW,
- CP_TRACE_CCO_TEI_EXPIRED
+ CP_TRACE_CCO_TEI_EXPIRED,
+ CP_TRACE_NTB_SYNC,
+ CP_TRACE_NTB_SYNC_PROC_DELAY
};
BEGIN_DECLS
diff --git a/cesar/cp/src/trace.c b/cesar/cp/src/trace.c
index d5821a5f27..ab13a8001a 100644
--- a/cesar/cp/src/trace.c
+++ b/cesar/cp/src/trace.c
@@ -127,7 +127,10 @@ cp_trace_init (cp_t *ctx)
TRACE_EVENT (CP_TRACE_CCO_ASSOC_RENEW,
"[CCo] Assoc renew, Mac addr : %m, tei : %x"),
TRACE_EVENT (CP_TRACE_CCO_TEI_EXPIRED,
- "[CCo] tei expired, Mac addr : %m, tei : %x")
+ "[CCo] tei expired, Mac addr : %m, tei : %x"),
+ TRACE_EVENT (CP_TRACE_NTB_SYNC,
+ "[NTB SYNC] bts : %x, sysdate : %x, stadate : %x, fe : %d ppm, offset : %d"),
+ TRACE_EVENT (CP_TRACE_NTB_SYNC_PROC_DELAY, "[NTB] Processing delay : %d")
};
dbg_assert (ctx);
trace_namespace_init (&namespace, event_ids, COUNT (event_ids));