diff options
-rw-r--r-- | include/l1a_l23_interface.h | 2 | ||||
-rw-r--r-- | src/host/layer23/src/app_phone.c | 2 | ||||
-rw-r--r-- | src/host/layer23/src/bcch_scan.c | 58 | ||||
-rw-r--r-- | src/host/layer23/src/gsm322.c | 14 | ||||
-rw-r--r-- | src/host/layer23/src/l1ctl.c | 17 | ||||
-rw-r--r-- | src/host/layer23/src/support.c | 2 | ||||
-rw-r--r-- | src/target/firmware/include/layer1/sync.h | 5 | ||||
-rw-r--r-- | src/target/firmware/layer1/prim_fbsb.c | 169 | ||||
-rw-r--r-- | src/target/firmware/layer1/sync.c | 2 |
9 files changed, 150 insertions, 121 deletions
diff --git a/include/l1a_l23_interface.h b/include/l1a_l23_interface.h index e1e7ccd5..76e0c313 100644 --- a/include/l1a_l23_interface.h +++ b/include/l1a_l23_interface.h @@ -71,7 +71,6 @@ struct l1ctl_info_dl { /* new CCCH was found. This is following the header */ struct l1ctl_fbsb_resp { - uint16_t band_arfcn; int16_t initial_freq_err; uint8_t result; uint8_t bsic; @@ -117,6 +116,7 @@ struct l1ctl_fbsb_req { #define L1CTL_FBSB_F_FB0 (1 << 0) #define L1CTL_FBSB_F_FB1 (1 << 1) #define L1CTL_FBSB_F_SB (1 << 2) +#define L1CTL_FBSB_F_FB01SB (L1CTL_FBSB_F_FB0|L1CTL_FBSB_F_FB1|L1CTL_FBSB_F_SB) /* the l1_info_ul header is in front */ struct l1ctl_rach_req { diff --git a/src/host/layer23/src/app_phone.c b/src/host/layer23/src/app_phone.c index 1c4f16a3..17083d78 100644 --- a/src/host/layer23/src/app_phone.c +++ b/src/host/layer23/src/app_phone.c @@ -44,7 +44,7 @@ static int signal_cb(unsigned int subsys, unsigned int signal, switch (signal) { case S_L1CTL_RESET: ms = signal_data; - return l1ctl_tx_fbsb_req(ms, ms->test_arfcn, 0x07, 100, 0); + return l1ctl_tx_fbsb_req(ms, ms->test_arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); break; } return 0; diff --git a/src/host/layer23/src/bcch_scan.c b/src/host/layer23/src/bcch_scan.c index e6238237..a8bd11cf 100644 --- a/src/host/layer23/src/bcch_scan.c +++ b/src/host/layer23/src/bcch_scan.c @@ -132,7 +132,7 @@ static int get_next_arfcn(struct full_power_scan *fps) best_arfcn = i; } } - printf("arfcn=%u rxlev=%u\n", best_arfcn, best_rxlev); + printf("arfcn=%d rxlev=%u\n", best_arfcn, best_rxlev); return best_arfcn; } @@ -154,7 +154,7 @@ static int _cinfo_start_arfcn(unsigned int band_arfcn) /* ask L1 to try to tune to new ARFCN */ /* FIXME: decode band */ - rc = l1ctl_tx_fbsb_req(fps.ms, band_arfcn, 0x01, 100, 0); + rc = l1ctl_tx_fbsb_req(fps.ms, band_arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); if (rc < 0) return rc; @@ -169,27 +169,35 @@ static int _cinfo_start_arfcn(unsigned int band_arfcn) return 0; } -static void cinfo_timer_cb(void *data) + +static void cinfo_next_cell(void *data) { int rc; + /* we've been waiting for BCCH info */ + fps.arfcn_state[fps.cur_arfcn].flags |= AFS_F_TESTED; + /* if there is a BCCH, we need to add the collected BCCH + * information to our list */ + + if (fps.arfcn_state[fps.cur_arfcn].flags & AFS_F_BCCH) + llist_add(&fps.cur_cell->list, &fps.cell_list); + else + cell_info_free(fps.cur_cell); + + rc = get_next_arfcn(&fps); + if (rc < 0) { + fps.state = BSCAN_S_DONE; + return; + } + /* start syncing to the next ARFCN */ + _cinfo_start_arfcn(rc); +} + +static void cinfo_timer_cb(void *data) +{ switch (fps.state) { case BSCAN_S_WAIT_DATA: - /* we've been waiting for BCCH info */ - fps.arfcn_state[fps.cur_arfcn].flags |= AFS_F_TESTED; - /* if there is a BCCH, we need to add the collected BCCH - * information to our list */ - if (fps.arfcn_state[fps.cur_arfcn].flags & AFS_F_BCCH) - llist_add(&fps.cur_cell->list, &fps.cell_list); - else - cell_info_free(fps.cur_cell); - rc = get_next_arfcn(&fps); - if (rc < 0) { - fps.state = BSCAN_S_DONE; - return; - } - /* start syncing to the next ARFCN */ - _cinfo_start_arfcn(rc); + cinfo_next_cell(data); break; } } @@ -230,6 +238,7 @@ static int rx_sch_info() static int bscan_sig_cb(unsigned int subsys, unsigned int signal, void *handler_data, void *signal_data) { + struct cell_info *ci = fps.cur_cell; struct osmocom_ms *ms; struct osmobb_meas_res *mr; uint16_t arfcn; @@ -272,6 +281,19 @@ static int bscan_sig_cb(unsigned int subsys, unsigned int signal, break; } break; + case S_L1CTL_FBSB_RESP: + /* We actually got a FCCH/SCH burst */ +#if 0 + fps.arfcn_state[ci->band_arfcn].flags |= AFS_F_BCCH; + /* fallthrough */ +#else + break; +#endif + case S_L1CTL_FBSB_ERR: + /* We timed out, move on */ + if (fps.state == BSCAN_S_WAIT_DATA) + cinfo_next_cell(NULL); + break; } return 0; } diff --git a/src/host/layer23/src/gsm322.c b/src/host/layer23/src/gsm322.c index 0480037f..f88bf6de 100644 --- a/src/host/layer23/src/gsm322.c +++ b/src/host/layer23/src/gsm322.c @@ -1594,7 +1594,7 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) LOGP(DCS, LOGL_INFO, "Tuning back to frequency %d (rxlev " "%d).\n", cs->arfcn, cs->list[cs->arfcn].rxlev_db); cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); start_cs_timer(cs, ms->support.sync_to, 0); return 0; @@ -1625,7 +1625,7 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) cs->arfcn = found; cs->si = cs->list[cs->arfcn].sysinfo; cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); /* selected PLMN (manual) or any PLMN (auto) */ switch (plmn->mode) { @@ -1694,7 +1694,7 @@ static int gsm322_cs_scan(struct osmocom_ms *ms) LOGP(DCS, LOGL_INFO, "Scanning frequency %d (rxlev %d).\n", cs->arfcn, cs->list[cs->arfcn].rxlev_db); cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); start_cs_timer(cs, ms->support.sync_to, 0); /* Allocate/clean system information. */ @@ -1815,7 +1815,7 @@ static int gsm322_cs_store(struct osmocom_ms *ms) cs->arfcn = found; cs->si = cs->list[cs->arfcn].sysinfo; cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); /* selected PLMN (manual) or any PLMN (auto) */ switch (plmn->mode) { @@ -2211,7 +2211,7 @@ static int gsm322_cs_powerscan(struct osmocom_ms *ms) "%d (rxlev %d).\n", cs->arfcn, cs->list[cs->arfcn].rxlev_db); cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); start_cs_timer(cs, ms->support.sync_to, 0); } else @@ -2710,7 +2710,7 @@ static int gsm322_c_conn_mode_1(struct osmocom_ms *ms, struct msgb *msg) /* be sure to go to current camping frequency on return */ LOGP(DCS, LOGL_INFO, "Going to camping frequency %d.\n", cs->arfcn); cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); cs->si = cs->list[cs->arfcn].sysinfo; return 0; @@ -2728,7 +2728,7 @@ static int gsm322_c_conn_mode_2(struct osmocom_ms *ms, struct msgb *msg) /* be sure to go to current camping frequency on return */ LOGP(DCS, LOGL_INFO, "Going to camping frequency %d.\n", cs->arfcn); cs->ccch_state = GSM322_CCCH_ST_INIT; - l1ctl_tx_ccch_req(ms, cs->arfcn); + l1ctl_tx_fbsb_req(ms, cs->arfcn, L1CTL_FBSB_F_FB01SB, 100, 0); cs->si = cs->list[cs->arfcn].sysinfo; return 0; diff --git a/src/host/layer23/src/l1ctl.c b/src/host/layer23/src/l1ctl.c index 9a846ee4..b2f2eec1 100644 --- a/src/host/layer23/src/l1ctl.c +++ b/src/host/layer23/src/l1ctl.c @@ -77,7 +77,7 @@ static int rx_l1_fbsb_resp(struct osmocom_ms *ms, struct msgb *msg) struct gsm_time tm; if (msgb_l3len(msg) < sizeof(*dl) + sizeof(*sb)) { - LOGP(DL1C, LOGL_ERROR, "MSG too short for FBSB RESP: %u\n", + LOGP(DL1C, LOGL_ERROR, "FBSB RESP: MSG too short %u\n", msgb_l3len(msg)); return -1; } @@ -85,8 +85,14 @@ static int rx_l1_fbsb_resp(struct osmocom_ms *ms, struct msgb *msg) dl = (struct l1ctl_info_dl *) msg->l1h; sb = (struct l1ctl_fbsb_resp *) dl->payload; - if (sb->result != 0) + printf("snr=%04x, arfcn=%u result=%u\n", dl->snr, ntohs(dl->band_arfcn), + sb->result); + + if (sb->result != 0) { + LOGP(DL1C, LOGL_ERROR, "FBSB RESP: result=%u\n", sb->result); dispatch_signal(SS_L1CTL, S_L1CTL_FBSB_ERR, ms); + return 0; + } gsm_fn2gsmtime(&tm, ntohl(dl->frame_nr)); DEBUGP(DL1C, "SCH: SNR: %u TDMA: (%.4u/%.2u/%.2u) bsic: %d\n", @@ -217,13 +223,6 @@ int tx_ph_data_req(struct osmocom_ms *ms, struct msgb *msg, return osmo_send_l1(ms, msg); } -/* FIXME: remove this after all code has been ported */ -int l1ctl_tx_ccch_req(struct osmocom_ms *ms, uint16_t arfcn) -{ - LOGP(DL1C, LOGL_ERROR, "CCCH REQ no longer implemented!!!\n"); - return -EINVAL; -} - /* Transmit FBSB_REQ */ int l1ctl_tx_fbsb_req(struct osmocom_ms *ms, uint16_t arfcn, uint8_t flags, uint16_t timeout, uint8_t sync_info_idx) diff --git a/src/host/layer23/src/support.c b/src/host/layer23/src/support.c index 64507ac9..6f728ce2 100644 --- a/src/host/layer23/src/support.c +++ b/src/host/layer23/src/support.c @@ -71,7 +71,7 @@ void gsm_support_init(struct osmocom_ms *ms) sup->r_gsm = 0; /* R-GSM */ sup->r_capa = 0; sup->low_capa = 4; /* p,e,r power class */ - sup->dcs_1800 = 0; + sup->dcs_1800 = 1; /* set supported frequencies */ if (sup->e_gsm || sup->r_gsm) sup->freq_map[0] |= 1; diff --git a/src/target/firmware/include/layer1/sync.h b/src/target/firmware/include/layer1/sync.h index 4b2de31d..4c055d20 100644 --- a/src/target/firmware/include/layer1/sync.h +++ b/src/target/firmware/include/layer1/sync.h @@ -71,11 +71,6 @@ struct l1s_state { } fb; struct { - unsigned int count; - unsigned int synced; - } sb; - - struct { /* power measurement l1 task */ unsigned int mode; union { diff --git a/src/target/firmware/layer1/prim_fbsb.c b/src/target/firmware/layer1/prim_fbsb.c index eaa55d04..2e5afade 100644 --- a/src/target/firmware/layer1/prim_fbsb.c +++ b/src/target/firmware/layer1/prim_fbsb.c @@ -87,7 +87,7 @@ static void dump_mon_state(struct mon_state *fb) fb->snr, l1s_snr_int(fb->snr), l1s_snr_fract(fb->snr), tpu_get_offset(), tpu_get_synchro()); #else - printf("(%u:%u): TOA=%5u, Power=%4ddBm, Angle=%5dHz ", + printf("(%u:%u): TOA=%5u, Power=%4ddBm, Angle=%5dHz\n", fb->fnr_report, fb->attempt, fb->toa, agc_inp_dbm8_by_pm(fb->pm)/8, ANGLE_TO_FREQ(fb->angle)); #endif @@ -98,14 +98,16 @@ static int l1ctl_fbsb_resp(uint8_t res) struct msgb *msg; struct l1ctl_fbsb_resp *resp; - msg = l1ctl_msgb_alloc(L1CTL_FBSB_RESP); + msg = l1_create_l2_msg(L1CTL_FBSB_RESP, fbs.mon.time.fn, + l1s_snr_int(fbs.mon.snr), + fbs.req.band_arfcn); if (!msg) return -ENOMEM; resp = (struct l1ctl_fbsb_resp *) msgb_put(msg, sizeof(*resp)); - resp->band_arfcn = htons(fbs.req.band_arfcn); resp->initial_freq_err = htons(fbs.initial_freq_err); resp->result = res; + resp->bsic = fbs.mon.bsic; /* no need to set BSIC, as it is never used here */ l1_queue_for_l2(msg); @@ -179,25 +181,24 @@ static int l1s_sbdet_resp(__unused uint8_t p1, uint8_t attempt, dsp_api.r_page_used = 1; /* after 2nd attempt, we failed */ - if (attempt == 2) - return l1ctl_fbsb_resp(255); + if (attempt == 2) { + last_fb->attempt = 13; + l1s_compl_sched(L1_COMPL_FB); + } /* after 1st attempt, we simply wait for 2nd */ return 0; } - l1s.sb.count++; - printf("SB%d ", attempt); - read_sb_result(last_fb, dsp_api.frame_ctr); + read_sb_result(last_fb, attempt); sb = dsp_api.db_r->a_sch[3] | dsp_api.db_r->a_sch[4] << 16; fbs.mon.bsic = l1s_decode_sb(&fbs.mon.time, sb); printf("=> SB 0x%08x: BSIC=%u ", sb, fbs.mon.bsic); l1s_time_dump(&fbs.mon.time); -#if 0 - l1s.serving_cell.bsic = bsic; + l1s.serving_cell.bsic = fbs.mon.bsic; /* calculate synchronisation value (TODO: only complete for qbits) */ last_fb->toa -= 23; @@ -225,25 +226,14 @@ static int l1s_sbdet_resp(__unused uint8_t p1, uint8_t attempt, else printf(" qbits=%u\n", qbits); - if (l1s.sb.count > 5 && l1s.sb.synced == 0) { - synchronize_tdma(&l1s.serving_cell); - l1s.sb.synced = 1; - } + synchronize_tdma(&l1s.serving_cell); /* if we have recived a SYNC burst, update our local GSM time */ - gsm_fn2gsmtime(&l1s.current_time, sb_time.fn + SB2_LATENCY); + gsm_fn2gsmtime(&l1s.current_time, fbs.mon.time.fn + SB2_LATENCY); /* compute next time from new current time */ l1s.next_time = l1s.current_time; l1s_time_inc(&l1s.next_time, 1); - /* place it in the queue for the layer2 */ - msg = l1_create_l2_msg(L1CTL_NEW_CCCH_RESP, sb_time.fn, - last_fb->snr, rf_arfcn); - l1 = (struct l1ctl_sync_new_ccch_resp *) msgb_put(msg, sizeof(*l1)); - l1->bsic = bsic; - l1_queue_for_l2(msg); -#endif - /* If we call tdma_sched_reset(), which is only needed if there * are further l1s_sbdet_resp() scheduled, we will bring * dsp_api.db_r and dsp_api.db_w out of sync because we changed @@ -259,18 +249,13 @@ static int l1s_sbdet_resp(__unused uint8_t p1, uint8_t attempt, l1s_dsp_abort(); } -#if 0 - if (l1s.sb.count > 10 && sb_time.t3 == 41) { - l1s_reset_hw(); - /* enable the MF Task for BCCH reading */ - mframe_enable(MF_TASK_BCCH_NORM); - mframe_enable(MF_TASK_CCCH_COMB); - } else { - /* We have just seen a SCH burst, we know the next one - * is not in less than 7 TDMA frames from now */ - l1s_sb_test(7); - } -#endif + l1s_reset_hw(); + /* enable the MF Task for BCCH reading */ + mframe_enable(MF_TASK_BCCH_NORM); + mframe_enable(MF_TASK_CCCH_COMB); + + l1s_compl_sched(L1_COMPL_FB); + return 0; } @@ -279,6 +264,9 @@ static int l1s_sbdet_cmd(__unused uint8_t p1, __unused uint8_t p2, { putchart('S'); + fbs.mon.bsic = 0; + fbs.mon.time.fn = 0; + dsp_api.db_w->d_task_md = SB_DSP_TASK; dsp_api.ndb->d_fb_mode = 0; /* wideband search */ dsp_end_scenario(); @@ -330,6 +318,41 @@ static int read_fb_result(struct mon_state *st, int attempt) return 1; } +static void fbinfo2cellinfo(struct l1_cell_info *cinfo, + const struct mon_state *mon) +{ + int ntdma, qbits, fn_offset, fnr_delta, bits_delta; + + /* FIXME: where did this magic 23 come from? */ + last_fb->toa -= 23; + + if (last_fb->toa < 0) { + qbits = (last_fb->toa + BITS_PER_TDMA) * 4; + ntdma = -1; + } else { + ntdma = (last_fb->toa) / BITS_PER_TDMA; + qbits = (last_fb->toa - ntdma * BITS_PER_TDMA) * 4; + } + + fn_offset = l1s.current_time.fn - last_fb->attempt + ntdma; + fnr_delta = last_fb->fnr_report - last_fb->attempt; + bits_delta = fnr_delta * BITS_PER_TDMA; + + cinfo->fn_offset = fnr_delta; + cinfo->time_alignment = qbits; + cinfo->arfcn = rf_arfcn; + + if (last_fb->toa > bits_delta) + printf("=> DSP reports FB in bit that is %d bits in " + "the future?!?\n", last_fb->toa - bits_delta); + else { + int fb_fnr = (last_fb->fnr_report - last_fb->attempt) + + last_fb->toa/BITS_PER_TDMA; + printf("=>FB @ FNR %u fn_offset=%d qbits=%u\n", + fb_fnr, fn_offset, qbits); + } +} + /* scheduler callback to issue a FB detection task to the DSP */ static int l1s_fbdet_cmd(__unused uint8_t p1, __unused uint8_t p2, uint16_t fb_mode) @@ -354,6 +377,8 @@ static int l1s_fbdet_cmd(__unused uint8_t p1, __unused uint8_t p2, return 0; } +#define FB0_SNR_THRESH 2000 +#define FB1_SNR_THRESH 3000 static const struct tdma_sched_item fb_sched_set[]; @@ -363,16 +388,7 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt, { putchart('f'); - if (dsp_api.ndb->d_fb_det) { - /* We found a frequency burst, reset everything */ - l1s_reset_hw(); - - printf("FB%u ", dsp_api.ndb->d_fb_mode); - read_fb_result(last_fb, attempt); - /* if this is the first success, save freq err */ - if (!fbs.initial_freq_err) - fbs.initial_freq_err = last_fb->freq_diff; - } else { + if (!dsp_api.ndb->d_fb_det) { /* we did not detect a FB */ /* attempt < 12, do nothing */ @@ -385,8 +401,22 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt, tdma_sched_reset(); last_fb->attempt = 13; + + l1s_compl_sched(L1_COMPL_FB); + + return 0; } + /* We found a frequency burst, reset everything */ + l1s_reset_hw(); + + printf("FB%u ", dsp_api.ndb->d_fb_mode); + read_fb_result(last_fb, attempt); + + /* if this is the first success, save freq err */ + if (!fbs.initial_freq_err) + fbs.initial_freq_err = last_fb->freq_diff; + /* If we don't reset here, we get DSP DMA errors */ tdma_sched_reset(); @@ -398,7 +428,8 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt, /* If we don't reset here, we get DSP DMA errors */ tdma_sched_reset(); /* FIXME: don't only use the last but an average */ - if (abs(last_fb->freq_diff) < fbs.req.freq_err_thresh1) + if (abs(last_fb->freq_diff) < fbs.req.freq_err_thresh1 && + last_fb->snr > FB0_SNR_THRESH) tdma_schedule_set(1, fb_sched_set, 1); else { /* FIXME: check timeout */ @@ -408,6 +439,7 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt, l1s_compl_sched(L1_COMPL_FB); } else if (fb_mode == 1) { if (fbs.req.flags & L1CTL_FBSB_F_SB) { + int ntdma, qbits; /* FIXME: where did this magic 23 come from? */ last_fb->toa -= 23; @@ -423,8 +455,15 @@ static int l1s_fbdet_resp(__unused uint8_t p1, uint8_t attempt, int fn_offset = l1s.current_time.fn - last_fb->attempt + ntdma; int delay = fn_offset + 11 - l1s.current_time.fn - 1; - if (abs(last_fb->freq_diff) < fbs.req.freq_err_thresh2) { + printf(" fn_offset=%d (fn=%u + attempt=%u + ntdma = %d)\m", + fn_offset, l1s.current_time.fn, last_fb->attempt, ntdma); + printf(" delay=%d (fn_offset=%d + 11 - fn=%u - 1\n", delay, + fn_offset, l1s.current_time.fn); + printf(" scheduling next FB/SB detection task with delay %u\n", delay); + if (abs(last_fb->freq_diff) < fbs.req.freq_err_thresh2 && + last_fb->snr > FB1_SNR_THRESH) { /* synchronize before reading SB */ + fbinfo2cellinfo(&l1s.serving_cell, last_fb); synchronize_tdma(&l1s.serving_cell); tdma_schedule_set(delay, sb_sched_set, 0); } else @@ -458,8 +497,6 @@ static const struct tdma_sched_item fb_sched_set[] = { /* Asynchronous completion handler for FB detection */ static void l1a_fb_compl(__unused enum l1_compl c) { - int ntdma, qbits, fn_offset, fnr_delta, bits_delta; - /* FXIME: use l1s.neigh_cell[fbs.cinfo_idx] */ struct l1_cell_info *cinfo = &l1s.serving_cell; if (last_fb->attempt >= 13) { @@ -467,35 +504,10 @@ static void l1a_fb_compl(__unused enum l1_compl c) return l1ctl_fbsb_resp(255); } - /* FIXME: where did this magic 23 come from? */ - last_fb->toa -= 23; - - if (last_fb->toa < 0) { - qbits = (last_fb->toa + BITS_PER_TDMA) * 4; - ntdma = -1; - } else { - ntdma = (last_fb->toa) / BITS_PER_TDMA; - qbits = (last_fb->toa - ntdma * BITS_PER_TDMA) * 4; - } - - fn_offset = l1s.current_time.fn - last_fb->attempt + ntdma; - fnr_delta = last_fb->fnr_report - last_fb->attempt; - bits_delta = fnr_delta * BITS_PER_TDMA; - - cinfo->fn_offset = fnr_delta; - cinfo->time_alignment = qbits; - cinfo->arfcn = rf_arfcn; - - if (last_fb->toa > bits_delta) - printf("=> DSP reports FB in bit that is %d bits in " - "the future?!?\n", last_fb->toa - bits_delta); - else { - int fb_fnr = (last_fb->fnr_report - last_fb->attempt) - + last_fb->toa/BITS_PER_TDMA; - printf("=>FB @ FNR %u fn_offset=%d qbits=%u\n", - fb_fnr, fn_offset, qbits); - } + /* FIME: use l1s.neigh_cell[fbs.cinfo_idx] */ + fbinfo2cellinfo(&l1s.serving_cell, last_fb); + /* send FBSB_RESP success message via L1CTL */ l1ctl_fbsb_resp(0); } @@ -513,6 +525,9 @@ void l1s_fbsb_req(uint8_t base_fn, struct l1ctl_fbsb_req *req) /* clear initial frequency error */ fbs.initial_freq_err = 0; + /* Make sure we start at a 'center' AFCDAC output value */ + afc_reset(); + if (fbs.req.flags & L1CTL_FBSB_F_FB0) tdma_schedule_set(base_fn, fb_sched_set, 0); else if (fbs.req.flags & L1CTL_FBSB_F_FB1) diff --git a/src/target/firmware/layer1/sync.c b/src/target/firmware/layer1/sync.c index bf476438..bb7c6b70 100644 --- a/src/target/firmware/layer1/sync.c +++ b/src/target/firmware/layer1/sync.c @@ -336,8 +336,6 @@ static void frame_irq(__unused enum irq_nr nr) void l1s_reset(void) { l1s.fb.mode = 0; - l1s.sb.synced = 0; - l1s.sb.count = 0; /* reset scheduler and hardware */ mframe_reset(); |