blob: b9d771abcd542bc45df4c505c03f401a2d1f70a0 [file] [log] [blame]
Vadim Yanitskiyca25d142019-01-19 12:29:19 +07001#!/usr/bin/env python2
2# -*- coding: utf-8 -*-
3
4# GR-GSM based transceiver
5# Radio interface for Lime devices
6#
7# (C) 2019 by Vadim Yanitskiy <axilirator@gmail.com>
8#
9# All Rights Reserved
10#
11# This program is free software; you can redistribute it and/or modify
12# it under the terms of the GNU General Public License as published by
13# the Free Software Foundation; either version 2 of the License, or
14# (at your option) any later version.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License along
22# with this program; if not, write to the Free Software Foundation, Inc.,
23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24
25import limesdr
26
27from radio_if import RadioInterface
28
29class RadioInterfaceLMS(RadioInterface):
30 lms_len_tag_name = "packet_len"
31 lms_dev_serial = ""
32 lms_dev_ch_mode = 1
33
34 # Human-readable description
35 def __str__(self):
36 return "LMS"
37
38 @property # Signal processing delay of PHY
39 def phy_proc_delay(self):
40 # FIXME: the current value is measured for USRP B2X0 at 26e6,
41 # we should measure it for LimeSDR separately!
42 return (285.616 + 2 * self.GSM_SYM_PERIOD_uS) * 1e-6
43
44 def phy_init_source(self):
45 self._phy_src = limesdr.source(self.lms_dev_serial,
46 self.lms_dev_ch_mode, "")
47
48 self._phy_src.set_sample_rate(self.sample_rate)
49 self._phy_src.set_gain(self.rx_gain, 0)
50
51 def phy_init_sink(self):
52 self._phy_sink = limesdr.sink(self.lms_dev_serial,
53 self.lms_dev_ch_mode, "",
54 self.lms_len_tag_name)
55
56 self._phy_sink.set_sample_rate(self.sample_rate)
57 self._phy_sink.set_gain(self.tx_gain, 0)
58
59 def phy_set_rx_freq(self, freq):
60 self._phy_src.set_center_freq(freq, 0)
61
62 def phy_set_tx_freq(self, freq):
63 self._phy_sink.set_center_freq(freq, 0)
64
65 def phy_set_rx_gain(self, gain):
66 self._phy_src.set_gain(gain, 0)
67
68 def phy_set_tx_gain(self, gain):
69 self._phy_sink.set_gain(gain, 0)