/* Cesar project {{{ * * Copyright (C) 2010 Spidcom * * <<>> * * }}} */ /** * \file bsu/aclf/test/utest/src/freq.c * \brief Frequency test error. * \ingroup bsu_aclf */ #include "common/std.h" #include "mac/common/timings.h" #include "lib/test.h" #include "lib/rnd.h" #include "bsu/aclf/test/utest/common.h" #include "bsu/aclf/test/utest/obj/zc_cross.h" /** Will be used for the zc cross detection simulation. */ static bsu_aclf_test_t test; void test_case_aclf_all_frequencies (test_t t) { test_case_begin (t, "All frequency possible"); test_begin (t, "Frequency increase.") { u32 acl_zc; lib_rnd_t rnd; lib_rnd_init (&rnd, 0x12324); bsu_aclf_test_init (&test); for (test.phy.frequency = 40, test.phy.zc_cross_index = 0; test.phy.frequency <= 80; test.phy.frequency++, test.phy.zc_cross_index++) { if (test.phy.frequency) acl_zc = MAC_MS_TO_TCK (1000 / test.phy.frequency) / 2; else acl_zc = 0; test.phy.phy = lib_rnd32 (&rnd); test.phy.zc = test.phy.phy - acl_zc + 1000; bsu_aclf_acl_frequency_detection (test.aclf); if (test.phy.frequency < 56) test_fail_unless (test.aclf->frequency == BSU_ACLF_FREQ_50HZ); else test_fail_unless (test.aclf->frequency == BSU_ACLF_FREQ_60HZ); } bsu_aclf_test_uninit (&test); } test_end; } void test_suite_aclf__frequency (test_t t) { test_suite_begin (t, "Frequency tests"); test_case_aclf_all_frequencies (t); } static void phy_zero_cross (bsu_aclf_test_phy_t *test) { u32 last_zc; /* Compute last ZC. */ if (test->frequency) { last_zc = test->zc + zero_cross[test->zc_cross_index]; if (lesseq_mod2p32 (last_zc, test->phy)) test->zc = last_zc; } } u32 phy_date (void) { phy_zero_cross (&test.phy); test.phy.phy += 100; return test.phy.phy; }