summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/target/firmware/include/layer1/rfch.h9
-rw-r--r--src/target/firmware/layer1/Makefile2
-rw-r--r--src/target/firmware/layer1/prim_rx_nb.c17
-rw-r--r--src/target/firmware/layer1/prim_tx_nb.c8
-rw-r--r--src/target/firmware/layer1/rfch.c49
5 files changed, 77 insertions, 8 deletions
diff --git a/src/target/firmware/include/layer1/rfch.h b/src/target/firmware/include/layer1/rfch.h
new file mode 100644
index 00000000..344523c3
--- /dev/null
+++ b/src/target/firmware/include/layer1/rfch.h
@@ -0,0 +1,9 @@
+#ifndef _L1_RFCH_H
+#define _L1_RFCH_H
+
+struct gsm_time;
+
+void rfch_get_params(struct gsm_time *t,
+ uint16_t *arfcn_p, uint8_t *tsc_p, uint8_t *tn_p);
+
+#endif /* _L1_RFCH_H */
diff --git a/src/target/firmware/layer1/Makefile b/src/target/firmware/layer1/Makefile
index 93edab02..dd3fcf1f 100644
--- a/src/target/firmware/layer1/Makefile
+++ b/src/target/firmware/layer1/Makefile
@@ -2,7 +2,7 @@
LIBRARIES+=layer1
layer1_DIR=layer1
layer1_SRCS=avg.c agc.c afc.c sync.c tdma_sched.c tpu_window.c init.c l23_api.c \
- mframe_sched.c sched_gsmtime.c async.c
+ mframe_sched.c sched_gsmtime.c async.c rfch.c
layer1_SRCS += prim_pm.c prim_rach.c prim_tx_nb.c prim_rx_nb.c prim_fbsb.c
diff --git a/src/target/firmware/layer1/prim_rx_nb.c b/src/target/firmware/layer1/prim_rx_nb.c
index cf6df48f..92e07d68 100644
--- a/src/target/firmware/layer1/prim_rx_nb.c
+++ b/src/target/firmware/layer1/prim_rx_nb.c
@@ -45,6 +45,7 @@
#include <layer1/mframe_sched.h>
#include <layer1/tpu_window.h>
#include <layer1/l23_api.h>
+#include <layer1/rfch.h>
#include <l1a_l23_interface.h>
@@ -60,12 +61,17 @@ static struct l1s_rxnb_state rxnb;
static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
{
+ struct gsm_time rx_time;
uint8_t mf_task_id = p3 & 0xff;
uint8_t mf_task_flags = p3 >> 8;
- uint16_t rf_arfcn = l1s.serving_cell.arfcn;
+ uint16_t rf_arfcn;
+ uint8_t tsc, tn;
putchart('n');
+ gsm_fn2gsmtime(&rx_time, l1s.current_time.fn - 4);
+ rfch_get_params(&rx_time, &rf_arfcn, &tsc, &tn);
+
/* just for debugging, d_task_d should not be 0 */
if (dsp_api.db_r->d_task_d == 0) {
puts("EMPTY\n");
@@ -98,7 +104,7 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
int32_t avg_dbm8 = 0;
/* Set Channel Number depending on MFrame Task ID */
- rxnb.dl->chan_nr = mframe_task2chan_nr(mf_task_id, 0); /* FIXME: TS */
+ rxnb.dl->chan_nr = mframe_task2chan_nr(mf_task_id, tn);
/* Set SACCH indication in Link IDentifier */
if (mf_task_flags & MF_F_SACCH)
@@ -148,7 +154,8 @@ static int l1s_nb_resp(__unused uint8_t p1, uint8_t burst_id, uint16_t p3)
static int l1s_nb_cmd(__unused uint8_t p1, uint8_t burst_id,
__unused uint16_t p3)
{
- uint8_t tsc = l1s.serving_cell.bsic & 0x7;
+ uint16_t arfcn;
+ uint8_t tsc, tn;
putchart('N');
@@ -166,10 +173,12 @@ static int l1s_nb_cmd(__unused uint8_t p1, uint8_t burst_id,
rxnb.di = (struct l1ctl_data_ind *) msgb_put(rxnb.msg, sizeof(*rxnb.di));
}
+ rfch_get_params(&l1s.next_time, &arfcn, &tsc, &tn);
+
dsp_load_rx_task(ALLC_DSP_TASK, burst_id, tsc);
dsp_end_scenario();
- l1s_rx_win_ctrl(l1s.serving_cell.arfcn, L1_RXWIN_NB);
+ l1s_rx_win_ctrl(arfcn, L1_RXWIN_NB);
tpu_end_scenario();
return 0;
diff --git a/src/target/firmware/layer1/prim_tx_nb.c b/src/target/firmware/layer1/prim_tx_nb.c
index b721a864..8a9f93e9 100644
--- a/src/target/firmware/layer1/prim_tx_nb.c
+++ b/src/target/firmware/layer1/prim_tx_nb.c
@@ -46,6 +46,7 @@
#include <layer1/mframe_sched.h>
#include <layer1/tpu_window.h>
#include <layer1/l23_api.h>
+#include <layer1/rfch.h>
#include <l1a_l23_interface.h>
@@ -91,7 +92,8 @@ static int l1s_tx_resp(__unused uint8_t p1, __unused uint8_t burst_id,
/* p1: type of operation (0: one NB, 1: one RACH burst, 2: four NB */
static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3)
{
- uint8_t tsc;
+ uint16_t arfcn;
+ uint8_t tsc, tn;
uint8_t mf_task_id = p3 & 0xff;
uint8_t mf_task_flags = p3 >> 8;
@@ -151,12 +153,12 @@ static int l1s_tx_cmd(uint8_t p1, uint8_t burst_id, uint16_t p3)
msgb_free(msg);
}
- tsc = 7; // !!!!! nanoBTS configuration for SDCCH 0 !!!!!!!!
+ rfch_get_params(&l1s.next_time, &arfcn, &tsc, &tn);
dsp_load_tx_task(DUL_DSP_TASK, burst_id, tsc);
dsp_end_scenario();
- l1s_tx_win_ctrl(l1s.serving_cell.arfcn, L1_TXWIN_NB, 0);
+ l1s_tx_win_ctrl(arfcn, L1_TXWIN_NB, 0);
tpu_end_scenario();
return 0;
diff --git a/src/target/firmware/layer1/rfch.c b/src/target/firmware/layer1/rfch.c
new file mode 100644
index 00000000..995cea4a
--- /dev/null
+++ b/src/target/firmware/layer1/rfch.c
@@ -0,0 +1,49 @@
+/* RF Channel utilities */
+
+/* (C) 2010 by Sylvain Munaut <tnt@246tNt.com>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdint.h>
+
+#include <layer1/sync.h>
+
+
+/* RF Channel parameters */
+void rfch_get_params(struct gsm_time *t,
+ uint16_t *arfcn_p, uint8_t *tsc_p, uint8_t *tn_p)
+{
+ if (l1s.dedicated.type == GSM_DCHAN_NONE) {
+ /* Serving cell only */
+ *arfcn_p = l1s.serving_cell.arfcn;
+ *tsc_p = l1s.serving_cell.bsic & 0x7;
+ *tn_p = 0;
+ } else {
+ /* Dedicated channel */
+ if (l1s.dedicated.h) {
+ /* Not supported yet */
+ } else {
+ *arfcn_p = l1s.dedicated.h0.arfcn;
+ }
+
+ *tsc_p = l1s.dedicated.tsc;
+ *tn_p = l1s.dedicated.tn;
+ }
+}
+