summaryrefslogtreecommitdiff
path: root/cesar/ce
diff options
context:
space:
mode:
authordufour2009-09-17 12:54:21 +0000
committerdufour2009-09-17 12:54:21 +0000
commit35487e616a9ca59fa4b777aa3eb27397611e60f8 (patch)
treea14bfffbdb46d0429996f124b677a08e191d095a /cesar/ce
parent5918a869c073c99384af22a112d08fc429813178 (diff)
* ce/rx/bitloading:
- add a generic function to handle the starting of the initial bit loading. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@5593 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce')
-rw-r--r--cesar/ce/rx/bitloading/Module2
-rw-r--r--cesar/ce/rx/bitloading/inc/common.h39
-rw-r--r--cesar/ce/rx/bitloading/src/common.c37
-rw-r--r--cesar/ce/rx/bitloading/src/transition.c29
4 files changed, 82 insertions, 25 deletions
diff --git a/cesar/ce/rx/bitloading/Module b/cesar/ce/rx/bitloading/Module
index aab705a128..45fb3c6576 100644
--- a/cesar/ce/rx/bitloading/Module
+++ b/cesar/ce/rx/bitloading/Module
@@ -1 +1 @@
-SOURCES := nsr.c ber.c transition.c initial.c
+SOURCES := nsr.c ber.c transition.c initial.c common.c
diff --git a/cesar/ce/rx/bitloading/inc/common.h b/cesar/ce/rx/bitloading/inc/common.h
new file mode 100644
index 0000000000..97e54bdfc2
--- /dev/null
+++ b/cesar/ce/rx/bitloading/inc/common.h
@@ -0,0 +1,39 @@
+#ifndef ce_rx_bitloading_inc_common_h
+#define ce_rx_bitloading_inc_common_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/bitloading/inc/common.h
+ * \brief Common transition functions
+ * \ingroup ce_rx
+ *
+ * Transitions can look the same. This module contains some global transition
+ * functions to prevent code duplication.
+ */
+
+#include "mac/common/sta.h"
+#include "mac/common/tonemask.h"
+#include "ce/rx/inc/rx.h"
+
+BEGIN_DECLS
+
+/**
+ * Start initial bit loading when we receive a sound complete flag.
+ * \param ce_rx the ce_rx context.
+ * \param sta the peer station.
+ * \param ts the tone mask.
+ *
+ * This function compute the tone map, set it and send the required MME to the
+ * peer.
+ */
+void
+ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts);
+
+END_DECLS
+
+#endif /* ce_rx_bitloading_inc_common_h */
diff --git a/cesar/ce/rx/bitloading/src/common.c b/cesar/ce/rx/bitloading/src/common.c
new file mode 100644
index 0000000000..0b01083202
--- /dev/null
+++ b/cesar/ce/rx/bitloading/src/common.c
@@ -0,0 +1,37 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2009 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/rx/bitloading/src/common.c
+ * \brief Common transition functions
+ * \ingroup ce_rx
+ */
+#include "common/std.h"
+
+#include "ce/rx/bitloading/inc/initial.h"
+#include "ce/rx/cp/inc/cp.h"
+
+void
+ce_rx_bl_start_bl (ce_rx_t *ce_rx, sta_t *sta, tonemask_info_t *ts)
+{
+ /* Check parameters. */
+ dbg_assert (sta);
+ /* Not using ts directly. */
+ /* Not using ce_rx directly. */
+
+ /* Compute initial tone map. */
+ tonemap_t *initial_tm = ce_rx_bl_initial_opitmized_iterative
+ (ts, &sta->ce_rx_bt);
+ /* Set it. */
+ u8 tmi = tonemaps_set_first_free_tmi (sta->rx_tonemaps, initial_tm);
+ /* This assert is required because this is the first time we ever
+ * set a tone map in the life of this STA. So we MUST have an
+ * empty tone map index available! */
+ dbg_assert (tmi != 0);
+ sta->rx_tonemaps->default_tmi = tmi;
+ ce_rx_cp_send_mme_new_tone_map (ce_rx, sta, tmi, 0, true);
+}
diff --git a/cesar/ce/rx/bitloading/src/transition.c b/cesar/ce/rx/bitloading/src/transition.c
index ec337cba81..b2c66f3bd2 100644
--- a/cesar/ce/rx/bitloading/src/transition.c
+++ b/cesar/ce/rx/bitloading/src/transition.c
@@ -17,6 +17,7 @@
#include "ce/rx/bitloading/inc/transition.h"
#include "ce/rx/bitloading/inc/nsr.h"
#include "ce/rx/bitloading/inc/initial.h"
+#include "ce/rx/bitloading/inc/common.h"
#include "ce/rx/inc/measure.h"
#include "ce/rx/cp/inc/cp.h"
#include "ce/rx/inc/rx.h"
@@ -40,18 +41,8 @@ ce_rx_bl__IDLE__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
/* Sound complete? */
if (chan_data.measure->rx_params.sound_complete)
{
- /* Compute initial tone map. */
- tonemap_t *initial_tm =
- ce_rx_bl_initial_opitmized_iterative
- (&ce_rx->mac_config->tonemask_info, &sta->ce_rx_bt);
- /* Set it. */
- u8 tmi = tonemaps_set_first_free_tmi (sta->rx_tonemaps, initial_tm);
- /* This assert is required because this is the first time we ever
- * set a tone map in the life of this STA. So we MUST have an
- * empty tone map index available! */
- dbg_assert (tmi != 0);
- sta->rx_tonemaps->default_tmi = tmi;
- ce_rx_cp_send_mme_new_tone_map (ce_rx, sta, tmi, 0, true);
+ /* Start initial tone map. */
+ ce_rx_bl_start_bl (ce_rx, sta, &ce_rx->mac_config->tonemask_info);
return ce_rx_bl_fsm_next_branch (IDLE, channel_data_received, sound_last);
}
else
@@ -84,18 +75,8 @@ ce_rx_bl__INITIAL__channel_data_received (ce_rx_t *ce_rx, sta_t *sta,
{
/* Compute NSR mean. */
ce_rx_bl_nsr_compute_mean (&sta->ce_rx_bt);
- /* Compute initial tone map. */
- tonemap_t *initial_tm =
- ce_rx_bl_initial_opitmized_iterative
- (&ce_rx->mac_config->tonemask_info, &sta->ce_rx_bt);
- /* Set it. */
- u8 tmi = tonemaps_set_first_free_tmi (sta->rx_tonemaps, initial_tm);
- /* This assert is required because this is the first time we ever
- * set a tone map in the life of this STA. So we MUST have an
- * empty tone map index available! */
- dbg_assert (tmi != 0);
- sta->rx_tonemaps->default_tmi = tmi;
- ce_rx_cp_send_mme_new_tone_map (ce_rx, sta, tmi, 0, true);
+ /* Start initial tone map. */
+ ce_rx_bl_start_bl (ce_rx, sta, &ce_rx->mac_config->tonemask_info);
return ce_rx_bl_fsm_next_branch (INITIAL, channel_data_received,
sound_last);
}