1 /* TPU window control routines for Layer 1 */
3 /* (C) 2010 by Harald Welte <laforge@gnumonks.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <calypso/tpu.h>
29 #include <calypso/tsp.h>
30 #include <abb/twl3025.h>
31 #include <rf/trf6151.h>
33 #include <layer1/tpu_window.h>
35 /* all units in GSM quarter-bits (923.1ns) */
36 #define L1_TDMA_LENGTH_Q 5000
37 #define L1_BURST_LENGTH_Q 625 /* L1_TDMA_LENGTH_Q/8 */
39 #define L1_NB_MARGIN_Q (3 * 4)
40 #define L1_SB_MARGIN_Q (23 * 4)
41 #define L1_TAIL_DURATION_Q (3 * 4)
43 /* Sample length as required by the Calypso DSP */
44 #define L1_NB_DURATION_Q (L1_BURST_LENGTH_Q + 2 * L1_NB_MARGIN_Q - L1_TAIL_DURATION_Q)
45 #define L1_SB_DURATION_Q (L1_BURST_LENGTH_Q + 2 * L1_SB_MARGIN_Q - L1_TAIL_DURATION_Q)
46 #define L1_FB_DURATION_Q (11 * L1_TDMA_LENGTH_Q + 2057) /* more than 11 full slots */
47 #define L1_FB26_DURATION_Q (L1_TDMA_LENGTH_Q + 798)
48 #define L1_PW_DURATION_Q 289
50 #define DSP_SETUP_TIME 66
52 static const uint16_t rx_burst_duration[_NUM_L1_RXWIN] = {
53 [L1_RXWIN_PW] = L1_PW_DURATION_Q,
54 [L1_RXWIN_FB] = L1_FB_DURATION_Q,
55 [L1_RXWIN_SB] = L1_SB_DURATION_Q,
56 [L1_RXWIN_NB] = L1_NB_DURATION_Q,
59 void l1s_rx_win_ctrl(uint16_t arfcn, enum l1_rxwin_type wtype)
61 int16_t start = DSP_SETUP_TIME;
62 int16_t stop = start + rx_burst_duration[wtype] - 1;
67 /* window open for TRF6151 */
68 /* FIXME: why do we need the magic value 100 ? */
69 rffe_mode(gsm_arfcn2band(arfcn), 0);
70 trf6151_rx_window(start - 100, arfcn, 40, 0);
72 /* Window open for ABB */
73 twl3025_downlink(1, start);
75 /* Delay 11 full TDMA frames */
76 if (wtype == L1_RXWIN_FB) {
78 for (i = 0; i < 11; i++)
81 stop -= 11 * L1_TDMA_LENGTH_Q;
84 /* Window close for ABB */
85 twl3025_downlink(0, stop);
87 /* FIXME: window close for TRF6151 */
90 void tpu_end_scenario(void)