summaryrefslogtreecommitdiff
path: root/cesar/cp
diff options
context:
space:
mode:
authorNicolas Schodet2010-09-06 09:38:44 +0200
committerNicolas Schodet2010-09-06 15:12:11 +0200
commitd70a7b9f684cca8eb6b6f29fa5b03db164ddc79d (patch)
treea90a8121d2f758bcfd7b6311f28530c01fc19065 /cesar/cp
parent5aa3eae9f1d517a70d4f110eec880e5a4692f98c (diff)
cesar/cp/beacon: add configurable SPOC update interval, closes #1838
Diffstat (limited to 'cesar/cp')
-rw-r--r--cesar/cp/beacon/inc/beacon.h2
-rw-r--r--cesar/cp/beacon/src/beacon.c17
-rw-r--r--cesar/cp/beacon/test/Config1
3 files changed, 16 insertions, 4 deletions
diff --git a/cesar/cp/beacon/inc/beacon.h b/cesar/cp/beacon/inc/beacon.h
index d615393dd4..54ac3a103e 100644
--- a/cesar/cp/beacon/inc/beacon.h
+++ b/cesar/cp/beacon/inc/beacon.h
@@ -169,6 +169,8 @@ struct cp_beacon_t
u32 last_countdown_date;
/** SPOC coefficients update date. */
u32 spoc_update_date;
+ /** SPOC coefficients update interval, or 0 to disable. */
+ u32 spoc_update_interval_ms;
};
#endif /* cp_beacon_inc_beacon_h */
diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c
index f61258266b..46581f425a 100644
--- a/cesar/cp/beacon/src/beacon.c
+++ b/cesar/cp/beacon/src/beacon.c
@@ -18,6 +18,7 @@
#include "common/std.h"
#include "lib/fixed.h"
#include "lib/slist.h"
+#include "lib/stats.h"
#include "string.h"
#include "hal/arch/arch.h"
#include "cp/defs.h"
@@ -35,8 +36,8 @@
#include "bsu/beacon/beacon.h"
#include "bsu/bsu.h"
-/** Update SPOC coefficients. */
-#define CP_BEACON_SPOC_UPDATE_DELAY_MS 1000
+/** Default interval between SPOC updates. */
+#define CP_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS 0
/** Timer expires.
* \param ctx the CP context.
@@ -584,6 +585,13 @@ cp_beacon_init (cp_t *ctx)
bsu_init_beacon_cb (cp_beacon_receive, ctx);
/* Store the current date for SPOC update coefficients. */
ctx->beacon.spoc_update_date = phy_date ();
+ /* Initialise tunable parameters. */
+ ctx->beacon.spoc_update_interval_ms =
+ CP_BEACON_SPOC_UPDATE_INTERVAL_DEFAULT_MS;
+ lib_stats_set_stat_value_notype ("SPOC_UPDATE_INTERVAL_MS",
+ &ctx->beacon.spoc_update_interval_ms,
+ LIB_STATS_ACCESS_WRITE_ONLY,
+ LIB_STATS_DEBUG);
}
/**
@@ -742,11 +750,12 @@ cp_beacon_get_and_process_beacon (cp_t *ctx)
ctx->beacon.eks.kbc = beacon_data.bmis.eks.kbc;
ctx->beacon.eks.new_eks = beacon_data.bmis.eks.new_eks;
}
- if (less_mod2p32 (ctx->beacon.spoc_update_date, phy_date ()))
+ if (ctx->beacon.spoc_update_interval_ms
+ && less_mod2p32 (ctx->beacon.spoc_update_date, phy_date ()))
{
cp_beacon_clk_sync_call_spoc (ctx, bsu_params->frequency_error);
ctx->beacon.spoc_update_date = phy_date ()
- + MAC_MS_TO_TCK (CP_BEACON_SPOC_UPDATE_DELAY_MS);
+ + MAC_MS_TO_TCK (ctx->beacon.spoc_update_interval_ms);
}
/** Update the schedules. */
cp_beacon_sta_compute_schedules (ctx, &beacon_data);
diff --git a/cesar/cp/beacon/test/Config b/cesar/cp/beacon/test/Config
new file mode 100644
index 0000000000..b711c51e0f
--- /dev/null
+++ b/cesar/cp/beacon/test/Config
@@ -0,0 +1 @@
+CONFIG_STATS = n