summaryrefslogtreecommitdiffstats
path: root/src/target/firmware/layer1/prim_rach.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/target/firmware/layer1/prim_rach.c')
-rw-r--r--src/target/firmware/layer1/prim_rach.c121
1 files changed, 115 insertions, 6 deletions
diff --git a/src/target/firmware/layer1/prim_rach.c b/src/target/firmware/layer1/prim_rach.c
index e6ea6568..97736ec9 100644
--- a/src/target/firmware/layer1/prim_rach.c
+++ b/src/target/firmware/layer1/prim_rach.c
@@ -50,6 +50,10 @@
#include <l1ctl_proto.h>
+int hando_access_flag = 0;
+int16_t hando_arfcn = 0;
+int ho_flag = 0;
+
struct {
uint32_t fn;
uint16_t band_arfcn;
@@ -60,11 +64,18 @@ static int l1s_tx_rach_cmd(__unused uint8_t p1, __unused uint8_t p2, __unused ui
{
uint16_t *info_ptr;
uint16_t arfcn;
+ uint8_t tsc, tn;
uint8_t data[2];
putchart('T');
- l1s_tx_apc_helper(l1s.serving_cell.arfcn);
+ if (hando_access_flag == 1)
+ arfcn = hando_arfcn;
+ else
+ arfcn = l1s.serving_cell.arfcn;
+
+ //l1s_tx_apc_helper(l1s.serving_cell.arfcn);
+ l1s_tx_apc_helper(arfcn);
data[0] = l1s.serving_cell.bsic << 2;
data[1] = l1s.rach.ra;
@@ -72,7 +83,11 @@ static int l1s_tx_rach_cmd(__unused uint8_t p1, __unused uint8_t p2, __unused ui
info_ptr = &dsp_api.ndb->d_rach;
info_ptr[0] = ((uint16_t)(data[0])) | ((uint16_t)(data[1])<<8);
- arfcn = l1s.serving_cell.arfcn;
+ //rfch_get_params(&l1s.next_time, &arfcn, &tsc, &tn); //MTZ - ADDED LATER - POSSIBLY REMOVE
+
+ //hando_access_flag = 0;
+
+ printf("\n\nMTZ - arfcn in l1s_tx_rach_cmd = %d, serving cell arfcn = %d\n\n", arfcn, l1s.serving_cell.arfcn);
dsp_api.db_w->d_task_ra = dsp_task_iq_swap(RACH_DSP_TASK, arfcn, 1);
@@ -85,14 +100,50 @@ static int l1s_tx_rach_cmd(__unused uint8_t p1, __unused uint8_t p2, __unused ui
static int l1s_tx_rach_resp(__unused uint8_t p1, __unused uint8_t burst_id,
__unused uint16_t p3)
{
+ uint16_t arfcn;
+
+ if (hando_access_flag == 1)
+ arfcn = hando_arfcn;
+ else
+ arfcn = l1s.serving_cell.arfcn;
+
+ hando_access_flag = 0;
+
putchart('t');
dsp_api.r_page_used = 1;
+ if (ho_flag == 1) {
+ ho_flag = 0;
+ int ii = 0;
+ for (ii =0; ii<64; ii++) {
+ if (l1s.tpu_offsets_arfcn[ii] == arfcn) {
+ if (l1s.nb_sb_snr[ii] > 0)
+ afc_input(l1s.nb_sb_freq_diff[ii], arfcn, 1);
+ else
+ afc_input(l1s.nb_sb_freq_diff[ii], arfcn, 0);
+
+
+ //mframe_disable(MF_TASK_TCH_F_EVEN);
+ //mframe_disable(MF_TASK_TCH_F_ODD);
+ //mframe_disable(MF_TASK_TCH_H_0);
+ //mframe_disable(MF_TASK_TCH_H_1);
+
+ //mframe_disable(MF_TASK_NEIGH_PM51_C0T0);
+ //mframe_disable(MF_TASK_NEIGH_PM51);
+ //mframe_disable(MF_TASK_NEIGH_PM26E);
+ //mframe_disable(MF_TASK_NEIGH_PM26O);
+
+ //mframe_enable(MF_TASK_BCCH_NORM);
+
+ }
+ }
+ }
+
/* schedule a confirmation back indicating the GSM time at which
* the RACH burst was transmitted to the BTS */
last_rach.fn = l1s.current_time.fn - 1;
- last_rach.band_arfcn = l1s.serving_cell.arfcn;
+ last_rach.band_arfcn = arfcn;
l1s_compl_sched(L1_COMPL_RACH);
return 0;
@@ -111,6 +162,7 @@ static void l1a_rach_compl(__unused enum l1_compl c)
{
struct msgb *msg;
+ printf("\n\nMTZ: L1CTL_RACH_CONF message being sent!\n\n\n");
msg = l1_create_l2_msg(L1CTL_RACH_CONF, last_rach.fn, 0,
last_rach.band_arfcn);
l1_queue_for_l2(msg);
@@ -131,16 +183,72 @@ static uint8_t rach_to_t3_comb[27] = {
25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
45, 46};
-/* request a RACH request at the next multiframe T3 = fn51 */
-void l1a_rach_req(uint16_t offset, uint8_t combined, uint8_t ra)
+/* schedule access burst */
+void l1a_rach_req(uint16_t offset, uint8_t combined, uint8_t ra, uint16_t arfcn)
{
uint32_t fn_sched;
unsigned long flags;
+ if (arfcn > 0) {
+ hando_arfcn = arfcn;
+ hando_access_flag = 1;
+ //printf("\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\nMTZ: CP1\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n");
+ uint32_t new_fn;
+ if (l1s.new_dm) {
+ int ii = 0;
+ for (ii =0; ii<64; ii++) {
+ if (l1s.tpu_offsets_arfcn[ii] == arfcn) {
+ printf("\n\n\n\n\n\n\n-------------------------------------------\n\n\n\n\nMTZ: SYNCHING TO NEW ARFCN %d\n\n\n\n\n-------------------------------------------\n\n\n\n\n\n\n\n", arfcn);
+ //printf("\n\n\n\n\n\n\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!MTZ: SYNCHING TO NEW ARFCN %d (offset=%d, freq_diff=%d, sb_fb_freq_diff=%d, sb_snr=%d, frame_diff=%d)!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n\n\n\n\n\n\n", arfcn, l1s.tpu_offsets[ii], l1s.nb_freq_diff[ii], l1s.nb_sb_freq_diff[ii], l1s.nb_sb_snr[ii], l1s.nb_frame_diff[ii]);
+
+ //MTZ - Setting tpu_offset for frame start synchronization as well as doing frequency compensation
+ l1s.orig_tpu_offset = l1s.tpu_offset;
+ l1s.tpu_offset = l1s.tpu_offsets[ii];
+ afc_correct(l1s.nb_freq_diff[ii], arfcn);
+
+ //if (l1s.nb_sb_snr[ii] > 0)
+ // afc_input(l1s.nb_sb_freq_diff[ii], arfcn, 1);
+ //else
+ // afc_input(l1s.nb_sb_freq_diff[ii], arfcn, 0);
+
+ //MTZ - Setting frame number using the difference computed before
+ new_fn = l1s.current_time.fn + l1s.nb_frame_diff[ii];
+ while (new_fn < 0)
+ new_fn += 2715647;
+ new_fn = new_fn % 2715647;
+ gsm_fn2gsmtime(&l1s.current_time, new_fn);
+ /* compute next time from new current time */
+ l1s.next_time = l1s.current_time;
+ l1s_time_inc(&l1s.next_time, 1);
+
+ tdma_sched_reset();
+
+ ho_flag = 1;
+
+ }
+ }
+ l1s.new_dm = 0;
+ }
+ }
+
offset += 3;
+ //printf("\n\nMTZ: In l1a_rach_req, serving cell = %d\n\n", l1s.serving_cell.arfcn);
+
local_firq_save(flags);
- if (combined) {
+ if (l1s.dedicated.type == GSM_DCHAN_TCH_F) {
+ fn_sched = l1s.current_time.fn + offset;
+ /* go next DCCH frame TCH/F channel */
+ if ((fn_sched % 13) == 12)
+ fn_sched++;
+ } else if (l1s.dedicated.type == GSM_DCHAN_TCH_H) {
+ fn_sched = l1s.current_time.fn + offset;
+ /* go next DCCH frame of TCH/H channel */
+ if ((fn_sched % 13) == 12)
+ fn_sched++;
+ if ((l1s.dedicated.chan_nr & 1) != ((fn_sched % 13) & 1))
+ fn_sched++;
+ } else if (combined) {
/* add elapsed RACH slots to offset */
offset += t3_to_rach_comb[l1s.current_time.t3];
/* offset is the number of RACH slots in the future */
@@ -150,6 +258,7 @@ void l1a_rach_req(uint16_t offset, uint8_t combined, uint8_t ra)
} else
fn_sched = l1s.current_time.fn + offset;
l1s.rach.ra = ra;
+ fn_sched %= 2715648;
sched_gsmtime(rach_sched_set_ul, fn_sched, 0);
local_irq_restore(flags);