summaryrefslogtreecommitdiff
path: root/cesar/bsu/ntb
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/bsu/ntb')
-rw-r--r--cesar/bsu/ntb/ntb_sync.h2
-rw-r--r--cesar/bsu/ntb/src/ntb.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/cesar/bsu/ntb/ntb_sync.h b/cesar/bsu/ntb/ntb_sync.h
index e578e91215..9afe12db8c 100644
--- a/cesar/bsu/ntb/ntb_sync.h
+++ b/cesar/bsu/ntb/ntb_sync.h
@@ -38,6 +38,8 @@ struct bsu_ntb_sync_t
u32 sta_numerator;
/** NTB clock tick offset. */
u32 ntb_offset_tck;
+ /** Delay before processing the beacon. */
+ u32 delay_systck;
};
typedef struct bsu_ntb_sync_t bsu_ntb_sync_t;
diff --git a/cesar/bsu/ntb/src/ntb.c b/cesar/bsu/ntb/src/ntb.c
index 23a15e4763..c7ace04fa9 100644
--- a/cesar/bsu/ntb/src/ntb.c
+++ b/cesar/bsu/ntb/src/ntb.c
@@ -58,19 +58,21 @@ bsu_ntb_frequency_error (bsu_ntb_sync_t *ctx, double freq_err, u32 bts,
* \param phy the phy context.
* \param freq_error last frequency error computed.
* \param bts the last beacon time stamp received in the last beacon.
+ * \param preamble_stadata the sta date preamble corresponding to the last
+ * beacon received.
* \param preamble_sysdate the system date preamble corresponding to the
* last beacon received.
*/
static s32
bsu_ntb_offset (bsu_ntb_sync_t *ctx, phy_t *phy, double freq_error,
- u32 bts, u32 preamble_stadate)
+ u32 bts, u32 preamble_stadate, u32 preamble_sysdate)
{
s32 offset;
- u32 delay_systck;
dbg_assert (ctx);
dbg_assert (phy);
/* Get the delay in system ticks. */
- delay_systck = phy_sysdate () - preamble_stadate;
+ ctx->delay_systck = phy_sysdate () - preamble_sysdate;
+ dbg_assert ((s32) ctx->delay_systck >= 0);
if (ctx->init)
{
offset = (s32) (bts - preamble_stadate)
@@ -106,7 +108,7 @@ bsu_ntb_clk_sync (bsu_ntb_sync_t * ctx, phy_t *phy, u32 beacon_bts,
freq_error = ctx->fe;
bsu_ntb_frequency_error (ctx, freq_error, beacon_bts, beacon_sys_ltmr);
ctx->ntb_offset_tck= bsu_ntb_offset (ctx, phy, freq_error, beacon_bts,
- beacon_sta_ltmr);
+ beacon_sta_ltmr, beacon_sys_ltmr);
ctx->preamble_sysdate = beacon_sys_ltmr;
ctx->preamble_stadate = beacon_sta_ltmr;
ctx->bts = beacon_bts;