summaryrefslogtreecommitdiff
path: root/cesar/bsu/aclf
diff options
context:
space:
mode:
authorlaranjeiro2010-07-22 08:40:39 +0000
committerlaranjeiro2010-07-22 08:40:39 +0000
commitc28228fbc5c05a9e489d6a05bf931471357b880d (patch)
treee5b6674e1bfed856634c19dff91306c9a7cc9ee5 /cesar/bsu/aclf
parent52b333286f88ee9869b3d056c90dffe21ed81417 (diff)
cesar/bsu/aclf: add a function to get the beacon period in ATU
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7304 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/bsu/aclf')
-rw-r--r--cesar/bsu/aclf/aclf.h12
-rw-r--r--cesar/bsu/aclf/src/bpsd.c9
-rw-r--r--cesar/bsu/aclf/test/utest/src/bpsd.c22
-rw-r--r--cesar/bsu/aclf/test/utest/src/misc.c8
4 files changed, 45 insertions, 6 deletions
diff --git a/cesar/bsu/aclf/aclf.h b/cesar/bsu/aclf/aclf.h
index 5b0319c29c..f4a2df5294 100644
--- a/cesar/bsu/aclf/aclf.h
+++ b/cesar/bsu/aclf/aclf.h
@@ -174,7 +174,17 @@ bsu_aclf_beacon_period_start_date_next (bsu_aclf_t *ctx);
* \return the beacon period duration.
*/
u32
-bsu_aclf_beacon_period (bsu_aclf_t *ctx);
+bsu_aclf_beacon_period_tck (bsu_aclf_t *ctx);
+
+/**
+ * Get the current beacon period duration in ATU.
+ * \param ctx the module context.
+ * \return the beacon period duration.
+ *
+ * Rounded up i.e. 3906.25 == 3907
+ */
+u32
+bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx);
/**
* ACLF must synchronise on the ACL frequency.
diff --git a/cesar/bsu/aclf/src/bpsd.c b/cesar/bsu/aclf/src/bpsd.c
index 853ac9d9f3..273bf58c74 100644
--- a/cesar/bsu/aclf/src/bpsd.c
+++ b/cesar/bsu/aclf/src/bpsd.c
@@ -36,8 +36,15 @@ bsu_aclf_beacon_period_start_date_next (bsu_aclf_t *ctx)
}
u32
-bsu_aclf_beacon_period (bsu_aclf_t *ctx)
+bsu_aclf_beacon_period_tck (bsu_aclf_t *ctx)
{
dbg_assert (ctx);
return ctx->bpsd[1] - ctx->bpsd[0];
}
+
+u32
+bsu_aclf_beacon_period_atu (bsu_aclf_t *ctx)
+{
+ dbg_assert (ctx);
+ return MAC_TCK_TO_ATU (ctx->bpsd[1] - ctx->bpsd[0]);
+}
diff --git a/cesar/bsu/aclf/test/utest/src/bpsd.c b/cesar/bsu/aclf/test/utest/src/bpsd.c
index f26ee9381f..efcebf8959 100644
--- a/cesar/bsu/aclf/test/utest/src/bpsd.c
+++ b/cesar/bsu/aclf/test/utest/src/bpsd.c
@@ -268,6 +268,27 @@ test_case_aclf_shift_compute_shift_bpsd (test_t t)
}
void
+test_case_aclf_beacon_period (test_t t)
+{
+ test_case_begin (t, "Beacon period read from aclf in TCK and ATU");
+ test_begin (t, "test")
+ {
+ uint i;
+ bsu_aclf_test_t test;
+ bsu_aclf_test_init (&test);
+ bsu_aclf_acl_frequency_detection (test.aclf);
+ for (i = 0; i < COUNT (test.aclf->bpsd); i++)
+ test.aclf->bpsd[i] = i * BSU_ACLF_BP_50HZ_TCK;
+ test_fail_unless (bsu_aclf_beacon_period_atu (test.aclf) == 3907);
+ for (i = 0; i < COUNT (test.aclf->bpsd); i++)
+ test.aclf->bpsd[i] = i * 999936;
+ test_fail_unless (bsu_aclf_beacon_period_atu (test.aclf) == 3906);
+ bsu_aclf_test_uninit (&test);
+ }
+ test_end;
+}
+
+void
test_suite_aclf__bpsd_accurate (test_t t)
{
test_suite_begin (t, "Beacon Period Start Date accurate");
@@ -275,4 +296,5 @@ test_suite_aclf__bpsd_accurate (test_t t)
test_case_aclf_compute_bto (t);
test_case_aclf_shift_bpsd (t);
test_case_aclf_shift_compute_shift_bpsd (t);
+ test_case_aclf_beacon_period (t);
}
diff --git a/cesar/bsu/aclf/test/utest/src/misc.c b/cesar/bsu/aclf/test/utest/src/misc.c
index 18ecd83849..811c112d3e 100644
--- a/cesar/bsu/aclf/test/utest/src/misc.c
+++ b/cesar/bsu/aclf/test/utest/src/misc.c
@@ -37,7 +37,7 @@ test_case_aclf__beacon_period (test_t test)
for (i = 0; i < COUNT(bpsd) - 1; i++)
{
test_fail_unless (bpsd[i+1] - bpsd[i]
- == bsu_aclf_beacon_period (t.aclf));
+ == bsu_aclf_beacon_period_tck (t.aclf));
bsu_aclf_shift_beacon_period_start_date (t.aclf);
}
bsu_aclf_test_uninit (&t);
@@ -60,7 +60,7 @@ test_case_aclf__timer (test_t test)
/* Already in tracker mode. */
for (i = 0; i < COUNT (bpsd) - 1; i++)
test_fail_unless (bpsd[i+1] - bpsd[i]
- == bsu_aclf_beacon_period (ctx.aclf));
+ == bsu_aclf_beacon_period_tck (ctx.aclf));
u32 old = bpsd[0];
ctx.phy->phy = bpsd[1];
bsu_aclf_timer_event (ctx.aclf);
@@ -68,7 +68,7 @@ test_case_aclf__timer (test_t test)
/* Already in tracker mode. */
for (i = 0; i < COUNT (bpsd) - 1; i++)
test_fail_unless (bpsd[i+1] - bpsd[i]
- == bsu_aclf_beacon_period (ctx.aclf));
+ == bsu_aclf_beacon_period_tck (ctx.aclf));
test_fail_unless (old + ctx.aclf->bp == bpsd[0]);
}
test_end;
@@ -82,7 +82,7 @@ test_case_aclf__timer (test_t test)
/* Already in tracker mode. */
for (i = 0; i < COUNT (bpsd) - 1; i++)
test_fail_unless (bpsd[i+1] - bpsd[i]
- == bsu_aclf_beacon_period (ctx.aclf));
+ == bsu_aclf_beacon_period_tck (ctx.aclf));
test_fail_unless (old + ctx.aclf->bp == bpsd[0]);
}
test_end;