summaryrefslogtreecommitdiff
path: root/cesar
diff options
context:
space:
mode:
authordufour2009-07-21 13:06:36 +0000
committerdufour2009-07-21 13:06:36 +0000
commit668637cb2d92f55355d703b24ddcae5f3fdc28b4 (patch)
treeb79e8fb651ec03e25c160546168301a48df989ad /cesar
parented1b1fe4cfecca1013f2904ef93a4159eecbb53e (diff)
* ce/rx/bitloading:
- move, rename and fix the function to initialize the computation of the mean on the NSR. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5042 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar')
-rw-r--r--cesar/ce/rx/bitloading/Module2
-rw-r--r--cesar/ce/rx/bitloading/inc/bitloading.h16
-rw-r--r--cesar/ce/rx/bitloading/inc/nsr.h21
-rw-r--r--cesar/ce/rx/bitloading/src/bitloading.c54
-rw-r--r--cesar/ce/rx/bitloading/src/nsr.c73
5 files changed, 96 insertions, 70 deletions
diff --git a/cesar/ce/rx/bitloading/Module b/cesar/ce/rx/bitloading/Module
index dac1d89b1d..5049dfc398 100644
--- a/cesar/ce/rx/bitloading/Module
+++ b/cesar/ce/rx/bitloading/Module
@@ -1 +1 @@
-SOURCES := initial.c bitloading.c
+SOURCES := initial.c bitloading.c nsr.c
diff --git a/cesar/ce/rx/bitloading/inc/bitloading.h b/cesar/ce/rx/bitloading/inc/bitloading.h
index f856aeccb1..273c88a600 100644
--- a/cesar/ce/rx/bitloading/inc/bitloading.h
+++ b/cesar/ce/rx/bitloading/inc/bitloading.h
@@ -25,11 +25,6 @@
#include "mac/common/sta.h"
/**
- * Size of the mean for each tone for the noise NRJ, in bytes.
- */
-#define CE_RX_BITLOADING_NOISE_NRJ_SIZE (sizeof (u32))
-
-/**
* Number of intervals.
* For the moment, this is a fixed number.
*/
@@ -46,17 +41,6 @@ void
ce_rx_bitloading_update (ce_rx_t *ce_rx, ce_rx_measure_mbox_t *measure);
/**
- * Allocate internal data for the bit loading state.
- * \param ce_rx the CE RX context.
- * \param bt the bit loading state structure.
- * \param chan_data the channel data.
- * \param chan_data_count the number of channel data.
- */
-void
-ce_rx_bitloading_allocate (ce_rx_t *ce_rx, ce_rx_bitloading_t *bt,
- phy_chandata_t *chan_data, uint chan_data_count);
-
-/**
* Initial channel estimation procedure (when receiving first sound frame).
* \param ce_rx the CE RX context.
* \param chan_data the channel data.
diff --git a/cesar/ce/rx/bitloading/inc/nsr.h b/cesar/ce/rx/bitloading/inc/nsr.h
index 95af92198e..dbedfe5099 100644
--- a/cesar/ce/rx/bitloading/inc/nsr.h
+++ b/cesar/ce/rx/bitloading/inc/nsr.h
@@ -15,6 +15,14 @@
* This header contains the functions relative to the NSR.
*/
+#include "ce/rx/bitloading/bitloading.h"
+#include "hal/phy/pbdma.h"
+
+/**
+ * Size of the mean for each tone for the noise NRJ, in bytes.
+ */
+#define CE_RX_BITLOADING_NOISE_NRJ_SIZE (sizeof (u32))
+
BEGIN_DECLS
/**
@@ -47,6 +55,19 @@ ce_rx_bl_nsr_mean (u32 sum, u8 nsr_count)
return sum * (u64) k / (1 << m);
}
+/**
+ * Initialize the NSR mean to the given channel data.
+ * \param bl the bit loading context of the station.
+ * \param chan_data the channel data (with the NSR).
+ * \param chan_data_count the number of channel data.
+ *
+ * This function just 'copy' the NSR from the channel data measure to the
+ * internal storage of the bit loading.
+ */
+void
+ce_rx_bl_nsr_init (ce_rx_bitloading_t *bl, phy_chandata_t *chan_data,
+ uint chan_data_count);
+
END_DECLS
#endif /* ce_rx_bitloading_inc_nsr_h */
diff --git a/cesar/ce/rx/bitloading/src/bitloading.c b/cesar/ce/rx/bitloading/src/bitloading.c
index 768a8e59d6..83505dcb34 100644
--- a/cesar/ce/rx/bitloading/src/bitloading.c
+++ b/cesar/ce/rx/bitloading/src/bitloading.c
@@ -14,59 +14,7 @@
#include "lib/slab.h"
#include "ce/rx/bitloading/inc/bitloading.h"
-
-void
-ce_rx_bitloading_allocate (ce_rx_t *ce_rx, ce_rx_bitloading_t *bt,
- phy_chandata_t *chan_data, uint chan_data_count)
-{
- /* Check parameters. */
- dbg_assert (ce_rx);
- dbg_assert (bt);
- dbg_assert (chan_data);
- dbg_assert (chan_data_count);
-
- /* Look for noise NRJ. */
- uint count = 0, noise_nrj_blk_count = 0;
- bool finished = false;
- phy_chandata_t *cur = chan_data;
- /* While not finished. */
- while (!finished)
- {
- dbg_assert (cur);
- /* Noise NRJ block. */
- if (cur->conf.type == PHY_CHANDATA_TYPE_NRJ)
- {
- /* First block. */
- if (cur->conf.address == 0)
- bt->noise_nrj = cur->blk;
- noise_nrj_blk_count++;
- blk_addref_desc (&cur->blk);
- }
- /* Get next channel data block. */
- if (++count < chan_data_count)
- cur = PARENT_OF (phy_chandata_t, blk, cur->blk.next);
- else
- finished = true;
- }
- {
- /* Sanity check. */
- if (PHY_CARRIER_NB % (BLK_SIZE / CE_RX_BITLOADING_NOISE_NRJ_SIZE))
- {
- dbg_assert (count ==
- PHY_CARRIER_NB / (BLK_SIZE /
- CE_RX_BITLOADING_NOISE_NRJ_SIZE)
- + 1);
- }
- else
- {
- dbg_assert (count ==
- PHY_CARRIER_NB / (BLK_SIZE /
- CE_RX_BITLOADING_NOISE_NRJ_SIZE));
- }
- }
- bt->noise_nrj_blk_count = noise_nrj_blk_count;
- bt->mean_count = 0;
-}
+#include "ce/rx/bitloading/inc/nsr.h"
void
ce_rx_bitloading_initial (ce_rx_t *ce_rx, ce_rx_bitloading_t *bt,
diff --git a/cesar/ce/rx/bitloading/src/nsr.c b/cesar/ce/rx/bitloading/src/nsr.c
new file mode 100644
index 0000000000..878ce09506
--- /dev/null
+++ b/cesar/ce/rx/bitloading/src/nsr.c
@@ -0,0 +1,73 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/bitloading/src/nsr.c
+ * \brief Noise / Signal Ratio.
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+
+#include "ce/rx/bitloading/inc/nsr.h"
+#include "hal/phy/defs.h"
+
+void
+ce_rx_bl_nsr_init (ce_rx_bitloading_t *bl, phy_chandata_t *chan_data,
+ uint chan_data_count)
+{
+ /* Check parameters. */
+ dbg_assert (bl);
+ dbg_assert (chan_data);
+ dbg_assert (chan_data_count != 0);
+
+ /* No block should have been previously allocated. */
+ dbg_assert (bl->noise_nrj_blk_count == 0);
+
+ /* Look for NSR. */
+ uint count = 0;
+ bool finished = false;
+ phy_chandata_t *cur = chan_data;
+ /* While not finished. */
+ while (!finished)
+ {
+ dbg_assert (cur);
+ /* Noise NRJ block. */
+ if (cur->conf.type == PHY_CHANDATA_TYPE_NRJ)
+ {
+ /* First block. */
+ if (cur->conf.address == 0)
+ bl->noise_nrj = cur->blk;
+ bl->noise_nrj_blk_count++;
+ /* Add a reference to the block. */
+ blk_addref_desc (&cur->blk);
+ }
+ /* Get next channel data block. */
+ if (++count < chan_data_count)
+ cur = PARENT_OF (phy_chandata_t, blk, cur->blk.next);
+ else
+ /* No more, it's finished. */
+ finished = true;
+ }
+ {
+ /* Sanity check. */
+ if (PHY_CARRIER_NB % (BLK_SIZE / CE_RX_BITLOADING_NOISE_NRJ_SIZE))
+ {
+ dbg_assert (bl->noise_nrj_blk_count ==
+ PHY_CARRIER_NB / (BLK_SIZE /
+ CE_RX_BITLOADING_NOISE_NRJ_SIZE)
+ + 1);
+ }
+ else
+ {
+ dbg_assert (bl->noise_nrj_blk_count ==
+ PHY_CARRIER_NB / (BLK_SIZE /
+ CE_RX_BITLOADING_NOISE_NRJ_SIZE));
+ }
+ }
+ /* One NSR acquired. */
+ bl->mean_count = 1;
+}