summaryrefslogtreecommitdiff
path: root/cesar/cp2/beacon/ntb/src/ntb_clock_sync.c
diff options
context:
space:
mode:
authorchertier2008-04-17 15:40:03 +0000
committerchertier2008-04-17 15:40:03 +0000
commitcb7107e5fb9cc7806ea144fd2953239feb59a18d (patch)
tree3d622389ee49dbdcf7a6faeee4827f693ba95fed /cesar/cp2/beacon/ntb/src/ntb_clock_sync.c
parent9fc6f0644e0790c04f11a6e6cdd10c7c93dee250 (diff)
update
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1843 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2/beacon/ntb/src/ntb_clock_sync.c')
-rwxr-xr-xcesar/cp2/beacon/ntb/src/ntb_clock_sync.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/cesar/cp2/beacon/ntb/src/ntb_clock_sync.c b/cesar/cp2/beacon/ntb/src/ntb_clock_sync.c
index e3c8744fe9..8b97e48dda 100755
--- a/cesar/cp2/beacon/ntb/src/ntb_clock_sync.c
+++ b/cesar/cp2/beacon/ntb/src/ntb_clock_sync.c
@@ -112,8 +112,8 @@ cp_beacon_ntb_update_offset_in_mac_config(cp_t *cp_ctx, signed long offset)
* following contexts are needed and found in the CP context passed in argument
* pointer to phy context (phy_t *phy_ctx)
* pointer to mac config (mac_config_t *mac_config)
- * ntb context pointer returned shall be saved in the CP context
- * by calling application to be retrieved through the CP context pointer
+ * returned pointer to allocated ntb context shall be saved in the CP context
+ * by the calling application to be retrieved through the CP context pointer
* passed in argument to other NTB API function calls
*/
ntb_t *
@@ -154,11 +154,18 @@ cp_beacon_ntb_init(cp_t *cp_ctx)
* Uninitialise the NTB clock synchronization manager.
*
* \param cp_ctx pointer to CP context.
+ *
+ * reset the history of beacon timestamps / NTB data samples
+ * free the NTB context allocated at init()
*/
void
cp_beacon_ntb_uninit( cp_t * cp_ctx )
{
+ dbg_assert(cp_ctx);
+ dbg_assert(cp_ctx->ntb_ctx);
+
cp_beacon_ntb_reset_histo(cp_ctx);
+ free(cp_ctx->ntb_ctx);
}
/**
@@ -232,20 +239,21 @@ cp_beacon_ntb_record_sample( ntb_t * cp_ctx, unsigned long beacon_bts, unsigned
}
/**
- * Synchronize local STA clock by adjusting its clock divisor as needed
- * depending on
+ * Synchronize local clock to be as close as possible to estimated value
+ * of the NTB clock reference.
*
- * - current beacon timestamp (BTS),
- * - SYS-base local receive time of current beacon (SYS LTmr, based on 25 Mhz local clock frequency not adjusted onto CCo clock frequency),
- * - STA-base local receive time of current beacon (STA LTmr, based on 25 Mhz local clock frequency adjusted onto CCo clock frequency).
- *
* \param cp_ctx pointer to CP context
* \param beacon_bts beacon time stamp
* \param beacon_sys_ltmr SYS local time captured when receiving beacon
* \param beacon_sta_ltmr STA local time captured when receiving beacon
*
* pointer to NTB context (ntb_t *ntb_ctx) is needed and found in the CP context passed in argument
- * local STA clock is synchronized by adjusting its clock divisor
+ * local STA clock is synchronized by adjusting its clock divisor as needed,
+ * depending on
+ *
+ * - current beacon timestamp (BTS),
+ * - SYS-base local receive time of current beacon (SYS LTmr, based on 25 Mhz local clock frequency not adjusted onto CCo clock frequency),
+ * - STA-base local receive time of current beacon (STA LTmr, based on 25 Mhz local clock frequency adjusted onto CCo clock frequency).
*/
void
cp_beacon_ntb_clk_sync(cp_t *cp_ctx, unsigned long beacon_bts, unsigned long beacon_sys_ltmr, unsigned long beacon_sta_ltmr)