From 6f6331ebad0ad3ceb6b5d5042add257215201714 Mon Sep 17 00:00:00 2001 From: laranjeiro Date: Mon, 17 May 2010 10:02:48 +0000 Subject: cesar/{ce,cp}: remove cp/pwl git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7071 017c9cb6-072f-447c-8318-d5b54f68fe89 --- cesar/ce/tx/src/mme.c | 1 - cesar/cp/av/cco/bw/src/bw.c | 3 +- cesar/cp/av/cco/region/src/region.c | 3 +- cesar/cp/beacon/src/beacon.c | 1 - cesar/cp/cco/action/src/cco_action.c | 1 - cesar/cp/inc/context.h | 5 - cesar/cp/msg/src/msg_cm.c | 1 - cesar/cp/pwl/inc/pwl.h | 85 --- cesar/cp/pwl/pwl.h | 169 ----- cesar/cp/pwl/src/pwl.c | 345 --------- cesar/cp/pwl/test/Makefile | 16 - cesar/cp/pwl/test/doc/Makefile | 20 - cesar/cp/pwl/test/doc/pwl.txt | 92 --- cesar/cp/pwl/test/ecos.ecc.sh | 5 - cesar/cp/pwl/test/inc/result_decrease.h | 1006 --------------------------- cesar/cp/pwl/test/inc/result_increase.h | 1006 --------------------------- cesar/cp/pwl/test/inc/result_stable.h | 1006 --------------------------- cesar/cp/pwl/test/inc/table.h | 1006 --------------------------- cesar/cp/pwl/test/inc/table_decrease.h | 1006 --------------------------- cesar/cp/pwl/test/inc/table_increase.h | 1006 --------------------------- cesar/cp/pwl/test/override/cp/inc/context.h | 30 - cesar/cp/pwl/test/src/pwl.c | 612 ---------------- cesar/cp/pwl/test/src/pwl_new_beacon.c | 103 --- cesar/cp/sta/core/src/core.c | 1 - 24 files changed, 2 insertions(+), 7527 deletions(-) delete mode 100644 cesar/cp/pwl/inc/pwl.h delete mode 100644 cesar/cp/pwl/pwl.h delete mode 100644 cesar/cp/pwl/src/pwl.c delete mode 100644 cesar/cp/pwl/test/Makefile delete mode 100644 cesar/cp/pwl/test/doc/Makefile delete mode 100644 cesar/cp/pwl/test/doc/pwl.txt delete mode 100644 cesar/cp/pwl/test/ecos.ecc.sh delete mode 100644 cesar/cp/pwl/test/inc/result_decrease.h delete mode 100644 cesar/cp/pwl/test/inc/result_increase.h delete mode 100644 cesar/cp/pwl/test/inc/result_stable.h delete mode 100644 cesar/cp/pwl/test/inc/table.h delete mode 100644 cesar/cp/pwl/test/inc/table_decrease.h delete mode 100644 cesar/cp/pwl/test/inc/table_increase.h delete mode 100644 cesar/cp/pwl/test/override/cp/inc/context.h delete mode 100644 cesar/cp/pwl/test/src/pwl.c delete mode 100644 cesar/cp/pwl/test/src/pwl_new_beacon.c (limited to 'cesar') diff --git a/cesar/ce/tx/src/mme.c b/cesar/ce/tx/src/mme.c index 22d938457a..e9c0e7e41c 100644 --- a/cesar/ce/tx/src/mme.c +++ b/cesar/ce/tx/src/mme.c @@ -12,7 +12,6 @@ */ #include "common/std.h" #include "lib/bitstream.h" -#include "cp/pwl/pwl.h" #include "hal/phy/defs.h" #include "cp/inc/context.h" #include "cp/inc/trace.h" diff --git a/cesar/cp/av/cco/bw/src/bw.c b/cesar/cp/av/cco/bw/src/bw.c index 7c62d6ebbe..865b990d81 100644 --- a/cesar/cp/av/cco/bw/src/bw.c +++ b/cesar/cp/av/cco/bw/src/bw.c @@ -15,7 +15,6 @@ #include "mac/common/timings.h" #include "cp/cco/bw/bw.h" #include "cp/av/cco/bw/bw.h" -#include "cp/pwl/pwl.h" #include "cp/inc/context.h" @@ -32,7 +31,7 @@ cp_av_cco_bw_schedules_default (cp_t *ctx) alloc = cp_cco_bw_alloc_init (ctx); alloc->stpf = false; alloc->end_time_atu = - MAC_TCK_TO_ATU(CP_PWL_BP_50 + CP_AV_CCO_BW_ALLOC_MIN_SIZE_TCK); + MAC_TCK_TO_ATU(BSU_ACLF_BP_50HZ_TCK + CP_AV_CCO_BW_ALLOC_MIN_SIZE_TCK); alloc->glid = MAC_LID_SHARED_CSMA; alloc->persistence = CP_CCO_BW_ALLOC_PERSISTENCE_PERSISTENT; alloc->pscd = 0; diff --git a/cesar/cp/av/cco/region/src/region.c b/cesar/cp/av/cco/region/src/region.c index 98673c1bfd..6133098c77 100644 --- a/cesar/cp/av/cco/region/src/region.c +++ b/cesar/cp/av/cco/region/src/region.c @@ -13,7 +13,6 @@ #include "common/std.h" #include "mac/common/timings.h" #include "cp/av/cco/region/region.h" -#include "cp/pwl/pwl.h" #include "cp/inc/context.h" @@ -26,7 +25,7 @@ cp_av_cco_region_default (cp_t *ctx) /* Create a default region. */ region = cp_cco_region_alloc_init (ctx); region->type = CP_CCO_REGION_TYPE_SHARED_CSMA; - region->end_time_atu = MAC_TCK_TO_ATU(CP_PWL_BP_50); + region->end_time_atu = MAC_TCK_TO_ATU(BSU_ACLF_BP_50HZ_TCK); cp_cco_region_alloc_add (ctx, &ctx->region.region_list, region); slab_release (region); } diff --git a/cesar/cp/beacon/src/beacon.c b/cesar/cp/beacon/src/beacon.c index 8f866ca930..f6cc0a5936 100644 --- a/cesar/cp/beacon/src/beacon.c +++ b/cesar/cp/beacon/src/beacon.c @@ -39,7 +39,6 @@ #include "hal/gpio/gpio.h" #include "bsu/beacon/beacon.h" #include "cp/beacon/ntb/ntb.h" -#include "cp/pwl/pwl.h" #include "bsu/bsu.h" /** Timer expires. diff --git a/cesar/cp/cco/action/src/cco_action.c b/cesar/cp/cco/action/src/cco_action.c index 7d1ab6c7fb..e14be7b2b4 100644 --- a/cesar/cp/cco/action/src/cco_action.c +++ b/cesar/cp/cco/action/src/cco_action.c @@ -28,7 +28,6 @@ #include "cp/defs.h" #include "cp/cp.h" -#include "cp/pwl/pwl.h" #include "cp/fsm/fsm.h" #include "cp/msg/msg.h" diff --git a/cesar/cp/inc/context.h b/cesar/cp/inc/context.h index bd8dc960c9..846cef5a35 100644 --- a/cesar/cp/inc/context.h +++ b/cesar/cp/inc/context.h @@ -29,7 +29,6 @@ #include "cp/cco/action/cco_action.h" #include "cp/cco/region/region.h" #include "cp/cco/bw/bw.h" -#include "cp/pwl/pwl.h" #include "cp/beacon/beacon.h" #include "cp/beacon/ntb/ntb.h" #include "cp/conn/conn_mgr.h" @@ -55,7 +54,6 @@ #include "cp/cl_interf/inc/context.h" #include "cp/msg/inc/context.h" #include "cp/fsm/inc/context.h" -#include "cp/pwl/inc/pwl.h" #include "ce/tx/inc/tx.h" enum cp_handover_reason_t @@ -109,9 +107,6 @@ struct cp_t /** Sta action. */ cp_sta_action_t sta_action; - /** PWL Module. */ - cp_pwl_t pwl; - /** Beacon module. */ cp_beacon_t beacon; diff --git a/cesar/cp/msg/src/msg_cm.c b/cesar/cp/msg/src/msg_cm.c index 8c8da32a8d..1ae1ad2db7 100644 --- a/cesar/cp/msg/src/msg_cm.c +++ b/cesar/cp/msg/src/msg_cm.c @@ -21,7 +21,6 @@ #include "cp/msg/inc/msg.h" #include "cp/msg/inc/msg_cm.h" -#include "cp/pwl/pwl.h" #include "mac/common/timings.h" #include "lib/utils.h" #include "cp/sta/core/core.h" diff --git a/cesar/cp/pwl/inc/pwl.h b/cesar/cp/pwl/inc/pwl.h deleted file mode 100644 index ac80884625..0000000000 --- a/cesar/cp/pwl/inc/pwl.h +++ /dev/null @@ -1,85 +0,0 @@ -#ifndef cp_pwl_inc_pwl_h -#define cp_pwl_inc_pwl_h -/* Cesar project {{{ - * - * Copyright (C) 2008 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file cp/pwl/inc/pwl.h - * \brief PWL context. - * \ingroup cp_pwl - */ -#include "cp/pwl/pwl.h" - -/** - * Power line module. Contains all the data concerning the PWL state. - */ -struct cp_pwl_t -{ - /** - * Inform on the frequency of the PWL. Only two values are possible - * the 50 and 60 Hz. - */ - const cp_pwl_frequency_t frequency; - - /** - * Beacon period static value. This value never change it corresponds - * to the value theoretical of the beacon period. (1 000 000 ticks - * for the 50 Hz and 833 333 ticks for the 60Hz) - */ - const cp_pwl_bp_t bp_ntb; - - /** - * The zero cross theoretical value of the beacon period. Based on - * the frequency detection. It corresponds to a quarter of the bp_ntb - * value. - */ - const uint zc_ntb; - - /** - * The value computed once the ACL frequency is done to know how many - * beacon periods it has in 10 seconds. - */ - const uint discover_period_max_bp; - - /** - * The previous, current and next values of the beacon period start in - * the AVLN computed by the CCo. - * This value will be update at each beacon period by the beacon module. - * It contains the date in NTB of the previous, current and next beacon - * period. For example, 1 000 000; 2 000 000; 3 000 000 - */ - u32 bp_avln_ntb [CP_PWL_BP_AVLN_NB]; - - /** - * Current beacon period value of the PWL. Use to estimate the beacon - * period. - */ - uint per_ntb; - - /** - * The next four beacon period offset values. - */ - s16 bto[4]; - - /** - * Values of the PRATIC register. - */ - u32 date_ntb [2]; - - /** - * Indicate if the station is tracking the ACL. - */ - bool tracking; - - /** - * Cable - */ - bool cable; -}; - - -#endif /* cp_pwl_inc_pwl_h */ diff --git a/cesar/cp/pwl/pwl.h b/cesar/cp/pwl/pwl.h deleted file mode 100644 index 0dab3d08bf..0000000000 --- a/cesar/cp/pwl/pwl.h +++ /dev/null @@ -1,169 +0,0 @@ -#ifndef cp_pwl_h -#define cp_pwl_h -/* Cesar project {{{ - * - * Copyright (C) 2008 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file cp/pwl/pwl.h - * \brief The powerline state. - * \ingroup cp_pwl - * - */ -#include "cp/cp.h" - -#define CP_PWL_BTO_NB 4 -#define CP_PWL_BP_AVLN_NB CP_PWL_BTO_NB -#define CP_PWL_TIMER_OFFSET_CCO 500000 -#define CP_PWL_TIMER_OFFSET_STA 250000 - -/** Frequency possibility. */ -enum cp_pwl_frequency_t -{ - CP_PWL_FREQ_50, - CP_PWL_FREQ_60 -}; -typedef enum cp_pwl_frequency_t cp_pwl_frequency_t; - -/** Conversion of the frequency to ticks. */ -enum cp_pwl_bp_t -{ - CP_PWL_BP_50 = 1000000, - CP_PWL_BP_60 = 833333 -}; -typedef enum cp_pwl_bp_t cp_pwl_bp_t; - -/** Zero cross values. */ -enum cp_pwl_zc_t -{ - CP_PWL_ZC_50 = (CP_PWL_BP_50 / 4), - CP_PWL_ZC_60 = (CP_PWL_BP_60 / 4) -}; -typedef enum cp_pwl_zc_t cp_pwl_zc_t; - -/** Forward declaration. */ -typedef struct cp_pwl_t cp_pwl_t; - -BEGIN_DECLS - -/** - * Initialise the pwl module. - * \param ctx the module context. - * - */ -void -cp_pwl_init (cp_t *ctx); - -/** - * Uninitialise the PWL module. - * \param ctx the module context. - * - */ -void -cp_pwl_uninit (cp_t *ctx); - -/** - * Compute the frequency of the power line using the pratic register. - * \param ctx the module context. - * - * It shall read the pratic register twice with a gap of 20 ms. This - * function shall update the data in the object. If the medium is a coaxial - * cable, the 50Hz will be chosen - * - * \warn Only call this function in a Thread. - */ -void -cp_pwl_acl_frequency_detection (cp_t *ctx); - -/** - * Compute the beacon period start time from the data contained in the beacon. - * \param ctx the module context. - * \param bts the beacon time stamp. - * \param bto the four btos present in the beacon. - * \param bpsto the beacon period start time offset. - */ -void -cp_pwl__sta__compute_beacon_period_start_time_ntb (cp_t *ctx, const u32 bts, - const s16 bto[CP_PWL_BTO_NB], - const u32 bpsto); - -/** - * Compute the beacon period start time from the data contained in the beacon. - * \param ctx the module context. - */ -void -cp_pwl__tracker__compute_beacon_period_start_time_ntb (cp_t *ctx); - -/** - * Get the three values of the beacon period start time. - * \param ctx the module context. - * \param pos the current, the future, or the next one. - * \return An array of CP_PWL_BP_AVLN_NB elements. - * - * The current one, the two next ones - */ -u32 -cp_pwl_get_beacon_period_start_ntb (cp_t *ctx, uint pos); - -/** - * Get the three values of the beacon period start time. - * \param ctx the module context. - * \param pos the current, the future, or the next one. - * \return An array of CP_PWL_BP_AVLN_NB elements. - * - * The current one, the two next ones - */ -u32 -cp_pwl_get_beacon_period_start_date (cp_t *ctx, uint pos); - -/** - * Get the estimated value of the beacon period in NTB ticks. - * \param ctx the module context. - * \return the beacon period int NTB ticks estimated. - */ -u32 -cp_pwl_get_beacon_period_ntb (cp_t *ctx); - -/** - * Get the four BTOs estimated. - * \param ctx the module context. - * \return The array of four BTO estimated by the CCo. - */ -const s16 * -cp_pwl_get_bto (cp_t *ctx); - -/** - * Provide the next date to awake. - * \param ctx the module context. - * \param cco If the station is acting as CCo or not (useful when the - * station is Ucco.) - * \return Return the next date to program the timer. - * - * If the station is CCo, it will return a date before the beacon period - * end. It the station is CCo it will return a date a quarter after the - * beacon period start - */ -u32 -cp_pwl_get_next_timer_date (cp_t *ctx, bool cco); - -/** - * Verify the current ntb date it in the new beacon period or not. - * \param ctx the module context. - * - * Example current ntb_date is 1 200 435 ticks, and the current beacon period - * start date is 1 000 000 and the next beacon period start date is 2 000 000, - * this function shall return false, because it is still the current beacon - * period and not a new one. - * - * The beacon period start date are accurate when the station receives the - * AVLN central beacon or when it is CCo and it generate the central beacon. - */ -bool -cp_pwl_is_new_beacon_period (cp_t *ctx); - -END_DECLS - -#endif /* cp_pwl_h */ diff --git a/cesar/cp/pwl/src/pwl.c b/cesar/cp/pwl/src/pwl.c deleted file mode 100644 index 235abc8a81..0000000000 --- a/cesar/cp/pwl/src/pwl.c +++ /dev/null @@ -1,345 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2008 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file cp/pwl/src/pwl.c - * \brief Power Line module. - * \ingroup cp_pwl - * - * The Power line module is responsible to keep the station synchronized with - * the AC Line Power Line. - */ -#include "common/std.h" -#include -#include - -/* Timings, for the macro MAC_MS_TO_TCK*/ -#include "mac/common/timings.h" -#include "mac/common/ntb.h" - -#include "cp/cp.h" - -#include "cp/pwl/pwl.h" -#include "cp/pwl/inc/pwl.h" - -#include "cp/inc/context.h" -#include "cp/inc/trace.h" -#include "string.h" - -/** - * Initialise the pwl module. - * \param ctx the module context. - * - */ -void -cp_pwl_init (cp_t *ctx) -{ - dbg_assert (ctx); - - memset (&ctx->pwl, 0, sizeof (cp_pwl_t)); -} - -/** - * Uninitialise the PWL module. - * \param ctx the module context. - * - */ -void -cp_pwl_uninit (cp_t *ctx) -{ - dbg_assert (ctx); -} - -/** - * Compute the frequency of the power line using the pratic register. - * \param ctx the module context. - * - * It shall read the pratic register twice with a gap of 20 ms. This - * function shall update the data in the object. If the medium is a coaxial - * cable, the 50Hz will be chosen - * - * \warn Only call this function in a Thread. - */ -void -cp_pwl_acl_frequency_detection (cp_t *ctx) -{ - uint bp_width_ntb; - - dbg_assert (ctx); - dbg_assert (ctx->phy); - - ctx->pwl.date_ntb[1] = phy_clock_get_zero_cross_captured_date(ctx->phy); - - cyg_thread_delay (2); - ctx->pwl.date_ntb[0] = phy_clock_get_zero_cross_captured_date(ctx->phy); - - // compute the becon period. - bp_width_ntb = (ctx->pwl.date_ntb[0] - ctx->pwl.date_ntb[1] + 5000) - % CP_PWL_ZC_50; - - if (bp_width_ntb > 6000) - { - *((cp_pwl_frequency_t*) &ctx->pwl.frequency) = CP_PWL_FREQ_60; - *((cp_pwl_bp_t*) &ctx->pwl.bp_ntb) = CP_PWL_BP_60; - *((uint*) &ctx->pwl.zc_ntb) = CP_PWL_ZC_60; - } - else - { - *((cp_pwl_frequency_t*) &ctx->pwl.frequency) = CP_PWL_FREQ_50; - *((cp_pwl_bp_t*) &ctx->pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &ctx->pwl.zc_ntb) = CP_PWL_ZC_50; - } - - ctx->pwl.cable = (ctx->pwl.date_ntb[0] == ctx->pwl.date_ntb[1]); - - ctx->pwl.per_ntb = ctx->pwl.bp_ntb; - *((uint*) &ctx->pwl.discover_period_max_bp) = - MAC_MS_TO_TCK (MAC_SEC_TO_MS(CP_DISCOVER_PERIOD_MAX_S)) - / ctx->pwl.bp_ntb; - - - CP_TRACE (PWL_FREQ, phy_date (), ctx->pwl.cable, ctx->pwl.zc_ntb, - ctx->pwl.bp_ntb); -} - -/** - * Compute the beacon period start time from the data contained in the beacon. - * \param ctx the module context. - * \param bts the beacon time stamp. - * \param bto the four btos present in the beacon. - * \param bpsto the beacon period start time offset. - */ -void -cp_pwl__sta__compute_beacon_period_start_time_ntb (cp_t *ctx, const u32 bts, - const s16 bto[4], - const u32 bpsto) -{ - uint i; - dbg_assert (ctx); - - ctx->pwl.tracking = false; - - /* Update the bto to the next one. */ - ctx->pwl.bto[0] = bto[1]; - ctx->pwl.bto[1] = bto[2]; - ctx->pwl.bto[2] = bto[3]; - ctx->pwl.bto[3] = bto[3]; - - ctx->pwl.bp_avln_ntb[0] = bts - bpsto; - for (i = 1; i < CP_PWL_BP_AVLN_NB; i++) - { - ctx->pwl.bp_avln_ntb[i] = ctx->pwl.bp_avln_ntb[i-1] + ctx->pwl.bto[i] - + ctx->pwl.bp_ntb; - } - - ctx->pwl.per_ntb = ctx->pwl.bp_avln_ntb[1] - ctx->pwl.bp_avln_ntb[0]; - - CP_TRACE_VERBOSE (PWL_STA_COMP_BPS, phy_date (), ctx->pwl.per_ntb, - ctx->pwl.bp_avln_ntb[0], ctx->pwl.bp_avln_ntb[1], - ctx->pwl.bp_avln_ntb[2], ctx->pwl.bp_avln_ntb[3]); - CP_TRACE_VERBOSE (PWL_STA_COMP_BPS_DATA, bts, bto[0], bto[1], bto[2], - bto[3], bpsto); -} - -static inline void -cp_pwl__tracker__compute_period (cp_t *ctx) -{ - uint diff_ntb; - dbg_assert (ctx); - dbg_assert (ctx->mac_config); - - ctx->pwl.date_ntb[1] = ctx->pwl.date_ntb[0]; - ctx->pwl.date_ntb[0] = - phy_clock_get_zero_cross_captured_date (ctx->phy) - + ctx->mac_config->ntb_offset_tck; - - diff_ntb = (ctx->pwl.date_ntb[0] - ctx->pwl.date_ntb[1]) - % (ctx->pwl.bp_ntb + 10000); - - if (diff_ntb <= 3 * ctx->pwl.zc_ntb) - { - float div; - - div = ((float)diff_ntb / (float)ctx->pwl.zc_ntb); - diff_ntb = (4 - div) * ctx->pwl.zc_ntb + diff_ntb; - } - - /* Using a Wp value with k = 4. */ - ctx->pwl.per_ntb += 0.0625 * ((s32) diff_ntb - - (s32)ctx->pwl.per_ntb); -} - -void -cp_pwl__tracker__compute_beacon_period_start_time_ntb (cp_t *ctx) -{ - uint i; - dbg_assert (ctx); - dbg_assert (ctx->pwl.bp_ntb); - - if (lesseq_mod2p32 (ctx->pwl.bp_avln_ntb[1], mac_ntb()) - || (ctx->pwl.bp_avln_ntb[0] == ctx->pwl.bp_avln_ntb[1])) - { - if (!ctx->pwl.cable) - { - cp_pwl__tracker__compute_period (ctx); - - if (ctx->pwl.tracking) - { - /* Update the beacon period start time. */ - for (i = 0; i < CP_PWL_BP_AVLN_NB - 1; i++) - ctx->pwl.bp_avln_ntb[i] = ctx->pwl.bp_avln_ntb[i+1]; - - ctx->pwl.bp_avln_ntb[CP_PWL_BP_AVLN_NB - 1] += - ctx->pwl.per_ntb; - - /* Compute BTO's */ - for (i = 0; i < CP_PWL_BTO_NB - 1; i++) - ctx->pwl.bto[i] = ctx->pwl.bto[i+1]; - - ctx->pwl.bto[CP_PWL_BTO_NB-1] = - ctx->pwl.bp_avln_ntb[CP_PWL_BP_AVLN_NB - 1] - - ctx->pwl.bp_avln_ntb[CP_PWL_BP_AVLN_NB - 2] - - ctx->pwl.bp_ntb; - } - else - { - s16 bto; - uint now = mac_ntb(); - - if (lesseq_mod2p32 (ctx->pwl.bp_avln_ntb[2], now)) - ctx->pwl.bp_avln_ntb[0] = now; - else - ctx->pwl.bp_avln_ntb[0] = ctx->pwl.bp_avln_ntb[1]; - - /* Update the beacon period start time. */ - for (i = 1; i < CP_PWL_BP_AVLN_NB; i++) - ctx->pwl.bp_avln_ntb[i] = ctx->pwl.bp_avln_ntb[i-1] + - ctx->pwl.per_ntb; - - - /* Compute BTO's */ - bto = ctx->pwl.bp_avln_ntb[CP_PWL_BP_AVLN_NB - 1] - - ctx->pwl.bp_avln_ntb[CP_PWL_BP_AVLN_NB - 2] - - ctx->pwl.bp_ntb; - - for (i = 0; i < CP_PWL_BTO_NB; i++) - ctx->pwl.bto[i] = bto; - } - } - else /* Cable mode. */ - { - uint i; - for (i = 0; i < CP_PWL_BTO_NB; i++) - ctx->pwl.bto[i] = 0; - - if (ctx->pwl.tracking) - { - ctx->pwl.bp_avln_ntb[0] += ctx->pwl.bp_ntb; - } - else - { - ctx->pwl.bp_avln_ntb[0] = mac_ntb(); - } - - for (i = 1; i < CP_PWL_BP_AVLN_NB; i++) - ctx->pwl.bp_avln_ntb[i] = ctx->pwl.bp_avln_ntb[i-1] + - ctx->pwl.bp_ntb; - } - CP_TRACE_VERBOSE (PWL_CCO_COMP_BPS, phy_date (), ctx->pwl.per_ntb, - ctx->pwl.bp_avln_ntb[0], ctx->pwl.bp_avln_ntb[1], - ctx->pwl.bp_avln_ntb[2], ctx->pwl.bp_avln_ntb[3]); - } - - ctx->pwl.tracking = true; -} - - -/** - * Get the three values of the beacon period start time. - * \param ctx the module context. - * \return An array of CP_PWL_BP_AVLN_NB elements. - * - * The current one, the two next ones - */ -u32 -cp_pwl_get_beacon_period_start_ntb (cp_t *ctx, uint pos) -{ - dbg_assert (ctx); - dbg_assert (pos < CP_PWL_BP_AVLN_NB); - - return ctx->pwl.bp_avln_ntb[pos]; -} - -u32 -cp_pwl_get_beacon_period_start_date (cp_t *ctx, uint pos) -{ - dbg_assert (ctx); - dbg_assert (ctx->mac_config); - dbg_assert (pos < CP_PWL_BP_AVLN_NB); - - return (u32) (ctx->pwl.bp_avln_ntb[pos] - - ctx->mac_config->ntb_offset_tck); -} - -/** - * Get the estimated value of the beacon period in NTB ticks. - * \param ctx the module context. - * \return the beacon period int NTB ticks estimated. - */ -u32 -cp_pwl_get_beacon_period_ntb (cp_t *ctx) -{ - dbg_assert (ctx); - - return ctx->pwl.per_ntb; -} - -/** - * Get the four BTOs estimated. - * \param ctx the module context. - * \return The array of four BTO estimated by the CCo. - */ -const s16 * -cp_pwl_get_bto (cp_t *ctx) -{ - dbg_assert (ctx); - - return ctx->pwl.bto; -} - -/** - * Provide the next date to awake. - * \param ctx the module context. - * \param cco If the station is acting as CCo or not (useful when the - * station is Ucco.) - * \return Return the next date to program the timer. - * - * If the station is CCo, it will return a date before the beacon period - * end. It the station is CCo it will return a date a quarter after the - * beacon period start - */ -u32 -cp_pwl_get_next_timer_date (cp_t *ctx, bool cco) -{ - dbg_assert (ctx); - dbg_assert (ctx->mac_config); - - if (cco) - return ctx->pwl.bp_avln_ntb[2] - CP_PWL_TIMER_OFFSET_CCO - - ctx->mac_config->ntb_offset_tck; - else - return ctx->pwl.bp_avln_ntb[1] + CP_PWL_TIMER_OFFSET_STA - - ctx->mac_config->ntb_offset_tck; -} - -bool -cp_pwl_is_new_beacon_period (cp_t *ctx) -{ - dbg_assert (ctx); - - return less_mod2p32 (ctx->pwl.bp_avln_ntb[1], mac_ntb()); -} diff --git a/cesar/cp/pwl/test/Makefile b/cesar/cp/pwl/test/Makefile deleted file mode 100644 index e00f1a7229..0000000000 --- a/cesar/cp/pwl/test/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -BASE = ../../.. - -ECOS = y -INCLUDES = cp/pwl/test/override - -TARGET_PROGRAMS = pwl pwl_new_beacon_period - -pwl_SOURCES = pwl.c -pwl_MODULES = lib cp/pwl -pwl_MODULES_CONFIG = mac/common - -pwl_new_beacon_period_SOURCES = pwl_new_beacon.c -pwl_new_beacon_period_MODULES = lib cp/pwl -pwl_new_beacon_period_MODULES_CONFIG = mac/common - -include $(BASE)/common/make/top.mk diff --git a/cesar/cp/pwl/test/doc/Makefile b/cesar/cp/pwl/test/doc/Makefile deleted file mode 100644 index d3db9f86c8..0000000000 --- a/cesar/cp/pwl/test/doc/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -PAGES= pwl.txt - -ODT=$(PAGES:%.txt=%.odt) -HTML=$(PAGES:%.txt=%.html) - -all: $(ODT) $(HTML) - -odt: $(ODT) - -html: $(HTML) - -%.odt: %.txt - rst2odt.py $< $@ - -%.html: %.txt - rst2html $< $@ - -clean: - rm -f $(ODT) - rm -f $(HTML) diff --git a/cesar/cp/pwl/test/doc/pwl.txt b/cesar/cp/pwl/test/doc/pwl.txt deleted file mode 100644 index 7982f71045..0000000000 --- a/cesar/cp/pwl/test/doc/pwl.txt +++ /dev/null @@ -1,92 +0,0 @@ -========== -PWL Module -========== - -Init ----- - -This shall initialise the PWL module. -At the end of this test, the PWL module attributes shall be equal to 0. - -Uninit ------- - -Actually does nothing. - -Frequency detection -------------------- - -Shall detect the 50, 60 Hz or the coaxial cable. - -Environment - This shall be use in a THREAD cause of the cyg_thread_delay function it calls. - -On 50 Hz PWL -~~~~~~~~~~~~ - -It shall read the PRATIC register twice and compute the zero cross gap. -At the end: - - * frequency == CP_PWL_FREQ_50 - * bp_ntb == CP_PWL_BP_50 - * zc_ntb == CP_PWL_ZC_50 - -On 60 Hz PWL -~~~~~~~~~~~~ - -It shall read the PRATIC register twice and compute the zero cross gap. -At the end: - - * frequency == CP_PWL_FREQ_60 - * bp_ntb == CP_PWL_BP_60 - * zc_ntb == CP_PWL_ZC_60 - -On Coaxial -~~~~~~~~~~ - -It shall read the PRATIC register twice and compute the zero cross gap. -At the end: - - * frequency == CP_PWL_FREQ_50 - * bp_ntb == CP_PWL_BP_50 - * zc_ntb == CP_PWL_ZC_50 - -Estimate beacon period ----------------------- - -This test shall provide the same result as the scilab simulation. -see cp/pwl/doc/scilab - -The scilab script is written to produce table to use with the unit test to verify the test. -For that, use the makefile in the scilab directory, it will produce in the res directory three files for each script: - - * table_xxx.h The table to include in the test to compute the period beacon, it correspond to PRATIC register values computed by scilab. - * result_xxx.h The result table of beacon period computed by scilab. It corresponds to the result that should be computed by the PWL module reacting to the table. - * result_xxx.csv the file containing the values computed i.e. the beacon period, the beacon period in ATU, the first zero cross, the next one, the difference between the two. - -Test 1 : AC stable. -~~~~~~~~~~~~~~~~~~~ - -This shall compute the values of the beacon period according with the values computed by scilab. -So this shall use: - - * table.h : entry data simulating the PRATIC register. - * result_stable.h : the beacon period computed by scilab to compare with. - -Test 2 : AC increasing. -~~~~~~~~~~~~~~~~~~~~~~~ - -This shall compute the values of the beacon period according with the values computed by scilab. -So this shall use: - - * table_increase.h : entry data simulating the PRATIC register. - * result_increase.h : the beacon period computed by scilab to compare with. - -Test 3 : AC decreasing. -~~~~~~~~~~~~~~~~~~~~~~~ - -This shall compute the values of the beacon period according with the values computed by scilab. -So this shall use: - - * table_decrease.h : entry data simulating the PRATIC register. - * result_decrease.h : the beacon period computed by scilab to compare with. diff --git a/cesar/cp/pwl/test/ecos.ecc.sh b/cesar/cp/pwl/test/ecos.ecc.sh deleted file mode 100644 index 8253d98c9a..0000000000 --- a/cesar/cp/pwl/test/ecos.ecc.sh +++ /dev/null @@ -1,5 +0,0 @@ -config=${1:-ecos-gen.ecc} -ecosconfig --config=$config new linux default -cat >> $config <>> - * - * }}} */ -/** - * \file overide/cp/inc/context.h - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ -#include "cp/pwl/pwl.h" -#include "hal/phy/phy.h" -#include "mac/common/config.h" - -#include "cp/pwl/inc/pwl.h" - -struct cp_t -{ - cp_pwl_t pwl; - phy_t *phy; - mac_config_t *mac_config; -}; - -#endif /* overide_cp_inc_context_h */ diff --git a/cesar/cp/pwl/test/src/pwl.c b/cesar/cp/pwl/test/src/pwl.c deleted file mode 100644 index a4c4bcfc33..0000000000 --- a/cesar/cp/pwl/test/src/pwl.c +++ /dev/null @@ -1,612 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2008 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file src/pwl.c - * \brief Test the PWL Module. - * \ingroup cp_pwl - * - */ -#include -#include -#include - -#include "common/std.h" -#include "lib/test.h" -#include "mac/common/timings.h" -#include "cp/cp.h" -#include "cp/inc/context.h" - -#include "cp/pwl/test/inc/table.h" -#include "cp/pwl/test/inc/table_increase.h" -#include "cp/pwl/test/inc/table_decrease.h" -#include "cp/pwl/test/inc/result_stable.h" -#include "cp/pwl/test/inc/result_increase.h" -#include "cp/pwl/test/inc/result_decrease.h" - - -enum test_pwl_phy_t -{ - TEST_PWL_PHY_NONE, - TEST_PWL_PHY_AC_STABLE, - TEST_PWL_PHY_AC_INC, - TEST_PWL_PHY_AC_DEC, - TEST_PWL_PHY_AC_CABLE -}; - -cp_t cp; -uint i; -uint zc_desired; -uint phy_type; -bool cco; -uint mac_ntb_cable = 0; - -cyg_handle_t my_thread_handle; -cyg_thread my_thread; -u8 my_thread_stack [CYGNUM_HAL_STACK_SIZE_TYPICAL]; - -/** Init - * \param test the test object. - * - * This shall initialise the PWL module. - * At the end of this test, the PWL module attributes shall be equal to 0. - */ -void -test_case_pwl_init (test_t test) -{ - memset (&cp, 0, sizeof (cp_t)); - cp_pwl_init (&cp); - - test_case_begin (test, "PWL Init"); - - test_begin (test, "verify") - { - test_fail_if (cp.pwl.frequency != 0, "Freq not initialised"); - test_fail_if (cp.pwl.bp_ntb != 0, "BP NTB not initialised"); - test_fail_if (cp.pwl.zc_ntb != 0, "ZC NTB not initialised"); - test_fail_if (cp.pwl.bp_avln_ntb[0] != 0, "BP AVLN not initialised"); - test_fail_if (cp.pwl.bp_avln_ntb[1] != 0, "BP AVLN not initialised"); - test_fail_if (cp.pwl.per_ntb != 0, "Per NTB not initialised"); - test_fail_if (cp.pwl.bto[0] != 0, "BTO 0 not initialised"); - test_fail_if (cp.pwl.bto[1] != 0, "BTO 1 not initialised"); - test_fail_if (cp.pwl.bto[2] != 0, "BTO 2 not initialised"); - test_fail_if (cp.pwl.bto[3] != 0, "BTO 3 not initialised"); - test_fail_if (cp.pwl.date_ntb[0] != 0, "Date ntb 0 not initialised"); - test_fail_if (cp.pwl.date_ntb[1] != 0, "Date ntb 1 not initialised"); - } - test_end; -} - -/** Frequency detection - * \param test the test object. - * - * Shall detect the 50, 60 Hz or the coaxial cable. - * Environment - * This shall be use in a THREAD cause of the cyg_thread_delay function - * it calls. - * - * On 50 Hz PWL - * It shall read the PRATIC register twice and compute the zero cross gap. - * At the end: - * * frequency == CP_PWL_FREQ_50 - * * bp_ntb == CP_PWL_BP_50 - * * zc_ntb == CP_PWL_ZC_50 - * - * On 60 Hz PWL - * It shall read the PRATIC register twice and compute the zero cross gap. - * At the end: - * * frequency == CP_PWL_FREQ_60 - * * bp_ntb == CP_PWL_BP_60 - * * zc_ntb == CP_PWL_ZC_60 - * - * On Coaxial - * It shall read the PRATIC register twice and compute the zero cross gap. - * At the end: - * * frequency == CP_PWL_FREQ_50 - * * bp_ntb == CP_PWL_BP_50 - * * zc_ntb == CP_PWL_ZC_50 - */ -void -test_case_pwl_frequency_detection (test_t test) -{ - memset (&cp, 0, sizeof (cp_t)); - test_case_begin (test, "Frequency detection"); - cp.phy = (phy_t *) &cp; - - test_begin (test, "Frequency 50 Hz") - { - - phy_type = TEST_PWL_PHY_NONE; - zc_desired = CP_PWL_ZC_50; - i = 0; - - cp_pwl_init (&cp); - cp_pwl_acl_frequency_detection (&cp); - - test_fail_if (cp.pwl.frequency != CP_PWL_FREQ_50, "Wrong frequency"); - test_fail_if (cp.pwl.bp_ntb != CP_PWL_BP_50, "Wrong BP"); - test_fail_if (cp.pwl.zc_ntb != CP_PWL_ZC_50, "Wrong ZC NTB"); - test_fail_if (cp.pwl.discover_period_max_bp != 250, "Wrong interval"); - } - test_end; - - test_begin (test, "Frequency 60 Hz") - { - zc_desired = CP_PWL_ZC_60; - i = 0; - - cp_pwl_acl_frequency_detection (&cp); - - test_fail_if (cp.pwl.frequency != CP_PWL_FREQ_60, "Wrong frequency"); - test_fail_if (cp.pwl.bp_ntb != CP_PWL_BP_60, "Wrong BP"); - test_fail_if (cp.pwl.zc_ntb != CP_PWL_ZC_60, "Wrong ZC NTB"); - test_fail_if (cp.pwl.discover_period_max_bp != 300, "Wrong interval"); - } - test_end; - - test_begin (test, "Frequency coaxial") - { - zc_desired = 0; - i = 0; - - cp_pwl_acl_frequency_detection (&cp); - - test_fail_if (cp.pwl.frequency != CP_PWL_FREQ_50, "Wrong frequency"); - test_fail_if (cp.pwl.bp_ntb != CP_PWL_BP_50, "Wrong BP"); - test_fail_if (cp.pwl.zc_ntb != CP_PWL_ZC_50, "Wrong ZC NTB"); - } - test_end; -} - -/** Estimate beacon period - * \param test the test object. - * - * This test shall provide the same result as the scilab simulation. - * see cp/pwl/doc/scilab - */ -void -test_case_pwl_estimate_beacon_period_ac_stable (test_t test) -{ - uint nb_iter; - mac_config_t mac_config; - memset (&cp, 0, sizeof (cp_t)); - - test_case_begin (test, "Beacon period estimation"); - cp_pwl_init (&cp); - - *((uint*) &cp.pwl.frequency) = CP_PWL_FREQ_50; - *((uint*) &cp.pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &cp.pwl.zc_ntb) = CP_PWL_ZC_50; - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.mac_config = &mac_config; - - /* initialise the per_ntb. */ - cp.pwl.per_ntb = cp.pwl.bp_ntb; - - i = 0; - phy_type = TEST_PWL_PHY_AC_STABLE; - - test_begin (test, "AC Stable : Verifying the period computed") - { - for (nb_iter = 0; nb_iter < ac_stable_length; nb_iter ++) - { - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - test_fail_if (cp.pwl.per_ntb != result_ac_stable[nb_iter], - "Estimation is false"); - } - } - test_end; -} - -/** Estimate beacon period, AC increase - * \param test the test object. - * - * This test shall provide the same result as the scilab simulation. - * see cp/pwl/doc/scilab - */ -void -test_case_pwl_estimate_beacon_period_ac_increase (test_t test) -{ - uint nb_iter; - mac_config_t mac_config; - memset (&cp, 0, sizeof (cp_t)); - - test_case_begin (test, "Beacon period estimation"); - cp_pwl_init (&cp); - - *((uint*) &cp.pwl.frequency) = CP_PWL_FREQ_50; - *((uint*) &cp.pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &cp.pwl.zc_ntb) = CP_PWL_ZC_50; - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.mac_config = &mac_config; - - - /* initialise the per_ntb. */ - cp.pwl.per_ntb = cp.pwl.bp_ntb; - - cp.pwl.date_ntb[0] = 0; - cp.pwl.date_ntb[1] = 0; - - i = 0; - phy_type = TEST_PWL_PHY_AC_INC; - - test_begin (test, "AC Increase : Verifying the period computed") - { - for (nb_iter = 0; nb_iter < ac_stable_length; nb_iter ++) - { - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - test_fail_if (cp.pwl.per_ntb != result_ac_increase[nb_iter], - "Estimation is false, i : %d", i); - } - } - test_end; -} - -/** Estimate beacon period, AC decrease - * \param test the test object. - * - * This test shall provide the same result as the scilab simulation. - * see cp/pwl/doc/scilab - */ -void -test_case_pwl_estimate_beacon_period_ac_decrease (test_t test) -{ - uint nb_iter; - mac_config_t mac_config; - memset (&cp, 0, sizeof (cp_t)); - - test_case_begin (test, "Beacon period estimation"); - - cp_pwl_init (&cp); - *((uint*) &cp.pwl.frequency) = CP_PWL_FREQ_50; - *((uint*) &cp.pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &cp.pwl.zc_ntb) = CP_PWL_ZC_50; - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.mac_config = &mac_config; - - - /* initialise the per_ntb. */ - cp.pwl.per_ntb = cp.pwl.bp_ntb; - - cp.pwl.date_ntb[0] = 0; - cp.pwl.date_ntb[1] = 0; - - i = 0; - phy_type = TEST_PWL_PHY_AC_DEC; - - test_begin (test, "AC Decrease : Verifying the period computed") - { - for (nb_iter = 0; nb_iter < ac_stable_length; nb_iter ++) - { - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - test_fail_if (cp.pwl.per_ntb != result_ac_decrease[nb_iter], - "Estimation is false"); - } - } - test_end; -} - -/** Compute the beacon period - * \param test the test object. - */ -void -test_case_pwl_compute_beacon_from_schedules_data (test_t test) -{ - uint i; - mac_config_t mac_config; - memset (&cp, 0, sizeof (cp_t)); - - test_case_begin (test, "Beacon period estimation"); - - *((uint*) &cp.pwl.frequency) = CP_PWL_FREQ_50; - *((uint*) &cp.pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &cp.pwl.zc_ntb) = CP_PWL_ZC_50; - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.mac_config = &mac_config; - - - cp.pwl.date_ntb[0] = 0; - cp.pwl.date_ntb[1] = 0; - - test_begin (test, "update the PWL") - { - s16 bto[4] = {0,0,0,0}; - - cp_pwl__sta__compute_beacon_period_start_time_ntb (&cp, 996451, bto, - 2300); - - for (i = 0; i < 3; i++) - test_fail_if (cp.pwl.bp_avln_ntb[i] != - 994151 + i * 1000000); - - - } - test_end; - - test_begin (test, "with btos") - { - s16 bto[4] = {0, -10, 30, 50}; - - cp_pwl__sta__compute_beacon_period_start_time_ntb (&cp, 1000000, bto, 0); - - test_fail_if (cp.pwl.bp_avln_ntb[0] != 1000000); - test_fail_if (cp.pwl.bp_avln_ntb[1] != 2000030); - test_fail_if (cp.pwl.bp_avln_ntb[2] != 3000080); - test_fail_if (cp.pwl.bp_avln_ntb[3] != 4000130); - } - test_end; - - test_begin (test, "with btos and BPSTO") - { - s16 bto[4] = {0, -10, 30, 50}; - - cp_pwl__sta__compute_beacon_period_start_time_ntb (&cp, 1000000, bto, 250); - - test_fail_if (cp.pwl.bp_avln_ntb[0] != 999750); - test_fail_if (cp.pwl.bp_avln_ntb[1] != 1999780); - test_fail_if (cp.pwl.bp_avln_ntb[2] != 2999830); - test_fail_if (cp.pwl.bp_avln_ntb[3] != 3999880); - } - test_end; - -} - -void -test_case_pwl_get_next_date (test_t test) -{ - test_case_begin (test, "Get the next date depending on the CCo status"); - - test_begin (test, "do it") - { - mac_config_t mac_config; - memset (&cp, 0, sizeof (cp_t)); - memset (&mac_config, 0, sizeof (mac_config_t)); - cp_pwl_init (&cp); - cp.mac_config = &mac_config; - - cp.pwl.bp_avln_ntb[1] = 500000; - cp.pwl.bp_avln_ntb[2] = 1500000; - - cco = true; - test_fail_if (cp_pwl_get_next_timer_date (&cp, cco) != 1500000 - - CP_PWL_TIMER_OFFSET_CCO); - - cco = false; - test_fail_if (cp_pwl_get_next_timer_date (&cp, cco) != 500000 + - CP_PWL_TIMER_OFFSET_STA); - } - test_end; -} - -void -test_case_pwl_cable (test_t test) -{ - test_case_begin (test, "PWL on cable"); - - test_begin (test, "Cable") - { - uint i; - uint val; - uint phy; - phy_type = TEST_PWL_PHY_AC_CABLE; - mac_config_t mac_config; - - memset (&cp, 0, sizeof (cp_t)); - memset (&mac_config, 0, sizeof (mac_config_t)); - cp_pwl_init (&cp); - cp.mac_config = &mac_config; - cp.phy = (phy_t*) &phy; - cp_pwl_acl_frequency_detection (&cp); - - test_fail_unless (cp.pwl.cable == true); - - mac_ntb_cable = 2000000; - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - for (i = 0, val = mac_ntb_cable; - i < CP_PWL_BP_AVLN_NB; - i++, val += 1000000) - { - test_fail_unless (cp.pwl.bp_avln_ntb[i] == val); - test_fail_unless (cp.pwl.bto[i] == 0); - } - - mac_ntb_cable = 3000001; - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - for (i = 0, val = 3000000; - i < CP_PWL_BP_AVLN_NB; - i++, val += 1000000) - { - test_fail_unless (cp.pwl.bp_avln_ntb[i] == val); - test_fail_unless (cp.pwl.bto[i] == 0); - } - - /* Do a Phy date jump. */ - mac_ntb_cable = 13340000; - cp.pwl.tracking = false; - - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - test_fail_unless (cp.pwl.tracking == true); - for (i = 0, val = mac_ntb_cable; - i < CP_PWL_BP_AVLN_NB; - i++, val += 1000000) - { - test_fail_unless (cp.pwl.bp_avln_ntb[i] == val); - test_fail_unless (cp.pwl.bto[i] == 0); - } - - - mac_ntb_cable = 14340001; - val = cp.pwl.bp_avln_ntb[1]; - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - for (i = 0; - i < CP_PWL_BP_AVLN_NB; - i++, val += 1000000) - { - test_fail_unless (cp.pwl.bp_avln_ntb[i] == val); - test_fail_unless (cp.pwl.bto[i] == 0); - } - } - test_end; -} - -void -test_case_pwl_schedule_jump (test_t test) -{ - test_case_begin (test, "Schedule jump"); - - test_begin (test, "tracker to STA.") - { - uint phy = 0; - mac_config_t mac_config; - - memset (&cp, 0, sizeof (cp_t)); - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.phy = (phy_t *) &phy; - cp.mac_config = &mac_config; - - cp_pwl_init (&cp); - cp_pwl_acl_frequency_detection (&cp); - cp.pwl.cable = false; - - cp.pwl.bp_avln_ntb[0] = 0xA3546e60; - cp.pwl.bp_avln_ntb[1] = 0xA363b9a9; - cp.pwl.bp_avln_ntb[2] = 0xA3730080; - cp.pwl.bp_avln_ntb[3] = 0xA3824771; - - cp.pwl.date_ntb[0] = 0x094818a8; - mac_config.ntb_offset_tck = 0x9a0e7a8b; - - phy_type = TEST_PWL_PHY_AC_STABLE; - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - test_fail_unless (cp.pwl.bp_avln_ntb[1] - cp.pwl.bp_avln_ntb[0] == - cp.pwl.per_ntb); - test_fail_unless (cp.pwl.bp_avln_ntb[2] - cp.pwl.bp_avln_ntb[1] == - cp.pwl.per_ntb); - } - test_end; - - test_begin (test, "First track.") - { - uint phy = 0; - mac_config_t mac_config; - - memset (&cp, 0, sizeof (cp_t)); - memset (&mac_config, 0, sizeof (mac_config_t)); - cp.phy = (phy_t *) &phy; - cp.mac_config = &mac_config; - - cp_pwl_init (&cp); - cp_pwl_acl_frequency_detection (&cp); - cp.pwl.cable = false; - - mac_config.ntb_offset_tck = 0x922ee979; - - phy_type = TEST_PWL_PHY_AC_STABLE; - cp_pwl__tracker__compute_beacon_period_start_time_ntb (&cp); - - /* Should be the offset plus the phy_date but this one is override in - * the test and does not add the offset. */ - test_fail_unless (cp.pwl.bp_avln_ntb[1] - cp.pwl.bp_avln_ntb[0] == - cp.pwl.per_ntb); - test_fail_unless (cp.pwl.bp_avln_ntb[2] - cp.pwl.bp_avln_ntb[1] == - cp.pwl.per_ntb); - - } - test_end; - -} - -void -my_thread_entry (cyg_addrword_t data) -{ - test_t test; - - test_init (test, 0, NULL); - - test_case_pwl_init (test); - test_case_pwl_frequency_detection (test); - test_case_pwl_estimate_beacon_period_ac_stable (test); - test_case_pwl_estimate_beacon_period_ac_increase (test); - test_case_pwl_estimate_beacon_period_ac_decrease (test); - test_case_pwl_compute_beacon_from_schedules_data (test); - test_case_pwl_get_next_date (test); - test_case_pwl_cable (test); - test_case_pwl_schedule_jump (test); - - test_result (test); - HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); -} - -int -main (void) -{ - // Create the thread object. - cyg_thread_create( 1, my_thread_entry, 0, "PWL", my_thread_stack, - CYGNUM_HAL_STACK_SIZE_TYPICAL, &my_thread_handle, - &my_thread); - - - // Activate the thread. - cyg_thread_resume (my_thread_handle); - - return 0; -} - -u32 -phy_clock_get_zero_cross_captured_date (phy_t *ctx) -{ - switch (phy_type) - { - case TEST_PWL_PHY_NONE: - if (i == 0) - { - i ++; - return 0; - } - else - { - return zc_desired; - } - break; - case TEST_PWL_PHY_AC_STABLE: - if (i == ac_stable_length) - return 0; - return ac_stable[i++]; - break; - case TEST_PWL_PHY_AC_INC: - if (i == ac_increase_length) - return 0; - return ac_increase[i++]; - break; - case TEST_PWL_PHY_AC_DEC: - if (i == ac_decrease_length) - return 0; - return ac_decrease[i++]; - break; - case TEST_PWL_PHY_AC_CABLE: - return 0; - break; - } - - return 0; -} - -u32 -mac_ntb (void) -{ - if (phy_type == TEST_PWL_PHY_AC_CABLE) - return mac_ntb_cable; - else - return cp.pwl.bp_avln_ntb[1] + 1; -} diff --git a/cesar/cp/pwl/test/src/pwl_new_beacon.c b/cesar/cp/pwl/test/src/pwl_new_beacon.c deleted file mode 100644 index 0caf58aa6f..0000000000 --- a/cesar/cp/pwl/test/src/pwl_new_beacon.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Cesar project {{{ - * - * Copyright (C) 2009 Spidcom - * - * <<>> - * - * }}} */ -/** - * \file src/pwl_new_beacon.c - * \brief « brief description » - * \ingroup « module » - * - * « long description » - */ -#include -#include - -#include "common/std.h" - -#include "lib/test.h" - -#include "cp/cp.h" -#include "cp/pwl/pwl.h" - -#include "cp/inc/context.h" - -enum test_enum -{ - TEST_OLD_BEACON_PERIOD, - TEST_NEW_BEACON_PERIOD -}; - -static enum test_enum period; -static cp_t cp; - -void -test_case_pwl_is_new_beacon_period (test_t test) -{ - cp_pwl_init (&cp); - - /* Configure PWL module. */ - *((cp_pwl_frequency_t*) &cp.pwl.frequency) = CP_PWL_FREQ_50; - *((cp_pwl_bp_t*) &cp.pwl.bp_ntb) = CP_PWL_BP_50; - *((uint*) &cp.pwl.zc_ntb) = CP_PWL_ZC_50; - cp.pwl.per_ntb = 999930; - cp.pwl.bp_avln_ntb[0] = 0; - cp.pwl.bp_avln_ntb[1] = cp.pwl.bp_avln_ntb[0] + cp.pwl.per_ntb; - cp.pwl.bp_avln_ntb[2] = cp.pwl.bp_avln_ntb[1] + cp.pwl.per_ntb; - cp.pwl.bp_avln_ntb[3] = cp.pwl.bp_avln_ntb[2] + cp.pwl.per_ntb; - - test_case_begin (test, "New beacon period"); - - test_begin (test, "Not a new beacon period") - { - period = TEST_OLD_BEACON_PERIOD; - - test_fail_unless (cp_pwl_is_new_beacon_period (&cp) == false); - } - test_end; - - test_begin (test, "New beacon period") - { - period = TEST_NEW_BEACON_PERIOD; - - test_fail_unless (cp_pwl_is_new_beacon_period (&cp) == true); - } - test_end; - - cp_pwl_uninit (&cp); -} - -int -main (void) -{ - test_t test; - - test_init (test, 0, NULL); - - test_case_pwl_is_new_beacon_period (test); - - test_result (test); - HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1); - return (test_nb_failed (test) == 0 ? 0 : 1); -} - -u32 -mac_ntb (void) -{ - if (period == TEST_OLD_BEACON_PERIOD) - { - return cp.pwl.bp_avln_ntb[0] + 800000; - } - else - { - return cp.pwl.bp_avln_ntb[1] + 10000; - } -} - -u32 -phy_clock_get_zero_cross_captured_date (phy_t *ctx) -{ - return 0; -} diff --git a/cesar/cp/sta/core/src/core.c b/cesar/cp/sta/core/src/core.c index d9a8e74597..f94f9ec279 100644 --- a/cesar/cp/sta/core/src/core.c +++ b/cesar/cp/sta/core/src/core.c @@ -52,7 +52,6 @@ #include "cp/sta/action/action.h" #include "cp/cco/action/cco_action.h" #include "cp/sta/mgr/sta_mgr.h" -#include "cp/pwl/pwl.h" #include "ce/rx/cp/cp.h" #include "cp/sta/core/inc/core.h" -- cgit v1.2.3