summaryrefslogtreecommitdiff
path: root/cesar/bsu/aclf
diff options
context:
space:
mode:
authorlaranjeiro2010-05-17 09:08:06 +0000
committerlaranjeiro2010-05-17 09:08:06 +0000
commit05e9041696ed5816d4cb57bd15b99d3ca8d35c09 (patch)
tree8985e13f95cb9cf6ca7684db43fc315e73ca4800 /cesar/bsu/aclf
parent75e65578cc26ec84491d43fdb824634cec6e2e0e (diff)
cesar/bsu: add BSU and sub module headers
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@7015 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/bsu/aclf')
-rw-r--r--cesar/bsu/aclf/aclf.h174
1 files changed, 174 insertions, 0 deletions
diff --git a/cesar/bsu/aclf/aclf.h b/cesar/bsu/aclf/aclf.h
new file mode 100644
index 0000000000..dcd2911a66
--- /dev/null
+++ b/cesar/bsu/aclf/aclf.h
@@ -0,0 +1,174 @@
+#ifndef bsu_aclf_aclf_h
+#define bsu_aclf_aclf_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2010 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file bsu/aclf/aclf.h
+ * \brief AC Line Frequency.
+ * \ingroup bsu
+ *
+ * All functions needed to track the frequency variation of the AC Line.
+ */
+#include "hal/phy/phy.h"
+#include "mac/common/config.h"
+#include "mac/common/timings.h"
+#include "common/defs/homeplugAV.h"
+
+/** Number of beacon period start date handled.
+ * The value is computed to allow the CCo to compute the four next BTOs. */
+#define BSU_ACLF_BPSD_NB (HPAV_BEACON_BTO_NB + 2)
+
+/** Frequency possibility. */
+enum bsu_aclf_frequency_t
+{
+ BSU_ACLF_FREQ_50,
+ BSU_ACLF_FREQ_60
+};
+typedef enum bsu_aclf_frequency_t bsu_aclf_frequency_t;
+
+/** Conversion of the frequency to ticks. */
+enum bsu_aclf_bp_t
+{
+ BSU_ACLF_BP_50 = 1000000,
+ BSU_ACLF_BP_60 = 833333
+};
+typedef enum bsu_aclf_bp_t bsu_aclf_bp_t;
+
+/** Zero cross values. */
+enum bsu_aclf_zc_t
+{
+ BSU_ACLF_ZC_50 = (BSU_ACLF_BP_50 / 4),
+ BSU_ACLF_ZC_60 = (BSU_ACLF_BP_60 / 4)
+};
+typedef enum bsu_aclf_zc_t bsu_aclf_zc_t;
+
+/** ACLF context structure. */
+struct bsu_aclf_t
+{
+ /** Phy context. */
+ phy_t *phy;
+ /** Mac configuration, */
+ mac_config_t *mac_config;
+ /**
+ * Inform on the frequency of the PWL. Only two values are possible
+ * the 50 and 60 Hz.
+ */
+ const bsu_aclf_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 bsu_aclf_bp_t bp;
+ /**
+ * The zero cross theoretical value of the beacon period. Based on
+ * the frequency detection. It corresponds to a quarter of the bp
+ * value.
+ */
+ const bsu_aclf_zc_t zc;
+ /**
+ * Table of the beacon period start in date. The first value of the array
+ * is the beacon period start date of the current beacon period, the next
+ * value is the next one and so on.
+ */
+ u32 bpsd [BSU_ACLF_BPSD_NB];
+ /**
+ * Current beacon period value of the ACLF. Use to estimate the beacon
+ * period.
+ */
+ uint beacon_period;
+ /**
+ * The next four beacon period offset values. Those values can be set to
+ * invalid HPAV_BEACON_BTO_INVALID.
+ */
+ s16 bto[HPAV_BEACON_BTO_NB];
+ /**
+ * Last value read in PRATIC register.
+ */
+ u32 date;
+};
+typedef struct bsu_aclf_t bsu_aclf_t;
+
+BEGIN_DECLS
+
+/**
+ * Initialise the module.
+ * \param ctx the module context.
+ * \param phy the phy context.
+ * \param mac_config the mac config structure.
+ */
+void
+bsu_aclf_init (bsu_aclf_t *ctx, phy_t *phy, mac_config_t *mac_config);
+
+/**
+ * Uninitialise the module.
+ * \param ctx the module context.
+ */
+void
+bsu_aclf_uninit (bsu_aclf_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 BSU_ACLF_ZC_50. This
+ * function shall update the data in the object.
+ *
+ * \warn If the medium is a coaxial cable, the 50Hz will be chosen.
+ */
+void
+bsu_aclf_acl_frequency_detection (bsu_aclf_t *ctx);
+
+/**
+ * Compute the beacon period start date from the data contained in the
+ * beacon.
+ * \param ctx the module context.
+ * \param bts_ntb the beacon time stamp in CCo's 25Mhz clock.
+ * \param bto the four BTO present in the beacon.
+ * \param bpsto the beacon period start time offset.
+ */
+void
+bsu_aclf_compute_beacon_period_start_date (bsu_aclf_t *ctx, const u32 bts_ntb,
+ const s16 bto[HPAV_BEACON_BTO_NB],
+ const u32 bpsto);
+
+/**
+ * Compute the beacon period start date from the AC Line.
+ * \param ctx the module context.
+ */
+void
+bsu_aclf_ac_compute_beacon_period_start_date (bsu_aclf_t *ctx);
+
+/**
+ * Get the beacon period start time.
+ * \param ctx the module context.
+ * \param bpsd the array to store the beacon period start time values.
+ * \param nb the number of entries in the array.
+ */
+void
+bsu_aclf_beacon_period_start_date (bsu_aclf_t *ctx, u32 **bpsd, uint *nb);
+
+/**
+ * Get the BTOs computed.
+ * \param ctx the module context.
+ * \param btos the array to store the BTO's values.
+ * \param nb the number of entries in the array.
+ */
+void
+bsu_aclf_bto (bsu_aclf_t *ctx, s16 **btos, uint *nb);
+
+/**
+ * Return the next beacon period start date.
+ * \param ctx the module context.
+ */
+u32
+bsu_aclf_beacon_period_start_date_next (bsu_aclf_t *ctx);
+
+END_DECLS
+
+#endif /* bsu_aclf_aclf_h */