diff options
Diffstat (limited to 'vrt/include')
-rw-r--r-- | vrt/include/vrt/Makefile.am | 4 | ||||
-rw-r--r-- | vrt/include/vrt/bits.h | 46 | ||||
-rw-r--r-- | vrt/include/vrt/quadradio.h | 143 | ||||
-rw-r--r-- | vrt/include/vrt/types.h | 138 |
4 files changed, 173 insertions, 158 deletions
diff --git a/vrt/include/vrt/Makefile.am b/vrt/include/vrt/Makefile.am index b710547d9..183eaf9ce 100644 --- a/vrt/include/vrt/Makefile.am +++ b/vrt/include/vrt/Makefile.am @@ -25,6 +25,6 @@ vrtinclude_HEADERS = \ bits.h \ copiers.h \ expanded_header.h \ - quadradio.h \ rx.h \ - rx_packet_handler.h + rx_packet_handler.h \ + types.h diff --git a/vrt/include/vrt/bits.h b/vrt/include/vrt/bits.h index bb4227db4..54eeec7b4 100644 --- a/vrt/include/vrt/bits.h +++ b/vrt/include/vrt/bits.h @@ -1,24 +1,20 @@ /* -*- c++ -*- */ /* * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify + * + * 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 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, + * the Free Software Foundation, either version 3 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. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. */ - #ifndef INCLUDED_VRT_BITS_H #define INCLUDED_VRT_BITS_H @@ -53,7 +49,9 @@ #define VRTH_TSF_REAL_TIME_PS (0x2 << 20) #define VRTH_TSF_FREE_RUNNING (0x3 << 20) +#define VRTH_PKT_CNT_SHIFT 16 #define VRTH_PKT_CNT_MASK (0xf << 16) + #define VRTH_PKT_SIZE_MASK 0xffff @@ -69,4 +67,26 @@ vrth_pkt_size(uint32_t h) return h & VRTH_PKT_SIZE_MASK; } +/* + * Trailer bits + */ +#define TR_E (1 << 8) + +#define TR_ENABLE(x) ((x) << 20) +#define TR_STATE(x) ((x) << 8) + +// Use these with TR_ENABLE and TR_STATE +#define TR_CAL_TIME (1 << 11) +#define TR_VALID_DATA (1 << 10) +#define TR_REF_LOCK (1 << 9) +#define TR_AGC (1 << 8) +#define TR_DETECTED_SIG (1 << 7) +#define TR_SPECTRAL_INVERSION (1 << 6) +#define TR_OVER_RANGE (1 << 5) +#define TR_SAMPLE_LOSS (1 << 4) +#define TR_USER_3 (1 << 3) +#define TR_USER_2 (1 << 2) +#define TR_USER_1 (1 << 1) +#define TR_USER_0 (1 << 0) + #endif /* INCLUDED_VRT_BITS_H */ diff --git a/vrt/include/vrt/quadradio.h b/vrt/include/vrt/quadradio.h deleted file mode 100644 index d30ee14f1..000000000 --- a/vrt/include/vrt/quadradio.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio 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 3, or (at your option) - * any later version. - * - * GNU Radio 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. - */ -#ifndef INCLUDED_VRT_QUADRADIO_H -#define INCLUDED_VRT_QUADRADIO_H - -#include <vrt/rx.h> - -#include <arpa/inet.h> -#include <netinet/in.h> -#include <sys/types.h> -#include <sys/socket.h> - -typedef enum{ - VRT_TEST_SIG_NORMAL=0, - VRT_TEST_SIG_ZEROS=1, - VRT_TEST_SIG_ONES=2, - VRT_TEST_SIG_TOGGLE=3, - VRT_TEST_SIG_RAMP=4, - VRT_TEST_SIG_CUSTOM=5, - - } vrt_test_sig_t; - -typedef enum{ - VRT_BAND_SEL_A='A', - VRT_BAND_SEL_B='B', - VRT_BAND_SEL_C='C', - VRT_BAND_SEL_D='D', - - } vrt_band_sel_t; - -namespace vrt { - - /* - * We're not committing to this interface. It's just here so we can make progress... - * - * This implements the ad-hoc control for bringup and has-a vrt::rx - */ - class quadradio - { - int d_ctrl_fd; // socket for control - struct in_addr d_ctrl_port_inaddr; // our ip addr - int d_data_fd; // socket for data (owned by d_rx) - int d_data_port; // our data port number - vrt::rx::sptr d_rx; // has-a rx - - vrt_band_sel_t d_band_select; // band select setting - int d_rx_antenna; // antenna type rf/cal - int d_attenuation0; // attenuation setting - int d_attenuation1; // attenuation setting - bool d_10dB_atten; // 10dB attenuation on/of - - static bool - open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port, - int *ctrl_fd_ptr, struct in_addr *ctrl_port_inaddr, - int *data_fd_ptr, int *data_port_ptr); - - // dsprxno selects the Rx DSP pipe (0 or 1) to configure - static bool - send_rx_command(int ctrl_fd, int rxdspno, bool start, - struct in_addr addr, int data_port, int samples_per_pkt); - - // dsprxno selects the Rx DSP pipe (0 or 1) to stop - static bool - send_stop_rx_command(int ctrl_fd, int rxdspno); - - static int control_port() { return 790; } - int data_socket_fd() const { return d_data_fd; } - - bool open(const char *ip); - - void update_dboard_pins(void); - - public: - typedef boost::shared_ptr<quadradio> sptr; - - quadradio(const std::string &ip, size_t rx_bufsize = 0); - ~quadradio(); - - vrt::rx::sptr vrt_rx() const { return d_rx; } - - // FIXME add rxdspno as the first parameter - bool start_streaming(int samples_per_pkt = 0); - - // FIXME add rxdspno as the first parameter - bool stop_streaming(); - - /* convenience methods that ultimately write the dboard pins */ - bool set_center_freq(double target_freq); - bool set_band_select(vrt_band_sel_t band); - vrt_band_sel_t get_band_select(void){return d_band_select;} - //void set_10dB_atten(bool on); - bool set_attenuation0(int attenuation); - bool select_rx_antenna(const std::string &ant); - bool set_attenuation1(int attenuation); - - /* convenience methods that ultimately call set_hsadc_conf */ - void set_adc_gain(bool on); - void set_dc_offset_comp(bool on); - void set_digital_gain(float gain); - void set_test_signal(vrt_test_sig_t type); - - /* primitives */ - bool set_setting_reg(int regno, int value); - bool set_mem32(int addr, int value); // poke a 32-bit value - bool set_lo_freq(double freq); - bool set_cal_freq(double freq); - bool set_beamforming(int32_t gains[8]); - bool set_cal_enb(bool enb); - /* - * The first parameter for these is a bitmask which indicates which - * daughterboard or daughterboards to apply the operation to. - * 0x1 -> dboard 0 - * 0x2 -> dboard 1 - * 0x3 -> dboard 0 and 1... - */ - bool set_dboard_pins(int dboard_bitmask, int v); - bool set_hsadc_conf(int dboard_bitmask, int regno, int value); - bool set_lsdac(int dboard_bitmask, int which_dac, int value); - - }; - -}; - - -#endif /* INCLUDED_QUADRADIO_H */ diff --git a/vrt/include/vrt/types.h b/vrt/include/vrt/types.h new file mode 100644 index 000000000..edfa4ec37 --- /dev/null +++ b/vrt/include/vrt/types.h @@ -0,0 +1,138 @@ +/* -*- c++ -*- */ +/* + * Copyright 2009 Free Software Foundation, Inc. + * + * 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 3 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, see <http://www.gnu.org/licenses/>. + */ +#ifndef INCLUDED_VRT_TYPES_H +#define INCLUDED_VRT_TYPES_H + +#include <stdint.h> + +/* macros for dealing with fixed point numbers */ +#define _FXPT_C(_type, _x, _rp) ((_type)((_x)*(1ll << _rp))) +#define _FXPT_TO_INT(_x, _one) (((_x) + ((_one)/2))/(_one)) +#define _FXPT_TO_DOUBLE(_x, _one) ((double)(_x) * (1.0/(_one))) + +/*********************************************************************** + * The VRT Altitude Type (meters) + **********************************************************************/ +typedef int32_t vrt_altitude_t; +#define VRT_ALTITUDE_RP 5 +#define VRT_ALTITUDE_C(_x) _FXPT_C(vrt_altitude_t, _x, VRT_ALTITUDE_RP) + +static inline vrt_altitude_t +double_to_vrt_altitude(double num){ + return VRT_ALTITUDE_C(num); +} + +static inline int32_t +vrt_altitude_round_to_int(vrt_altitude_t fx){ + return _FXPT_TO_INT(fx, VRT_ALTITUDE_C(1)); +} + +static inline double +vrt_altitude_to_double(vrt_altitude_t fx){ + return _FXPT_TO_DOUBLE(fx, VRT_ALTITUDE_C(1)); +} + +/*********************************************************************** + * The VRT Geolocation Angle Type (degrees) + **********************************************************************/ +typedef int32_t vrt_geo_angle_t; +#define VRT_GEO_ANGLE_RP 22 +#define VRT_GEO_ANGLE_C(_x) _FXPT_C(vrt_geo_angle_t, _x, VRT_GEO_ANGLE_RP) + +static inline vrt_geo_angle_t +double_to_vrt_geo_angle(double num){ + return VRT_GEO_ANGLE_C(num); +} + +static inline int16_t +vrt_geo_angle_round_to_int(vrt_geo_angle_t fx){ + return _FXPT_TO_INT(fx, VRT_GEO_ANGLE_C(1)); +} + +static inline double +vrt_geo_angle_to_double(vrt_geo_angle_t fx){ + return _FXPT_TO_DOUBLE(fx, VRT_GEO_ANGLE_C(1)); +} + +/*********************************************************************** + * The VRT Frequency Type (Hz) + **********************************************************************/ +typedef int64_t vrt_freq_t; +#define VRT_FREQ_RP 20 +#define VRT_FREQ_C(_x) _FXPT_C(vrt_freq_t, _x, VRT_FREQ_RP) + +static inline vrt_freq_t +double_to_vrt_freq(double num){ + return VRT_FREQ_C(num); +} + +static inline int64_t +vrt_freq_round_to_int(vrt_freq_t fx){ + return _FXPT_TO_INT(fx, VRT_FREQ_C(1)); +} + +static inline double +vrt_freq_to_double(vrt_freq_t fx){ + return _FXPT_TO_DOUBLE(fx, VRT_FREQ_C(1)); +} + +/*********************************************************************** + * The VRT Gain Type (dB) + **********************************************************************/ +typedef int16_t vrt_gain_t; +#define VRT_GAIN_RP 7 +#define VRT_GAIN_C(_x) _FXPT_C(vrt_gain_t, _x, VRT_GAIN_RP) + +static inline vrt_gain_t +double_to_vrt_gain(double num){ + return VRT_GAIN_C(num); +} + +static inline int16_t +vrt_gain_round_to_int(vrt_gain_t fx){ + return _FXPT_TO_INT(fx, VRT_GAIN_C(1)); +} + +static inline double +vrt_gain_to_double(vrt_gain_t fx){ + return _FXPT_TO_DOUBLE(fx, VRT_GAIN_C(1)); +} + +/*********************************************************************** + * The VRT Temperature Type (Celcius) + **********************************************************************/ +typedef int16_t vrt_temp_t; +#define VRT_TEMP_RP 6 +#define VRT_TEMP_C(_x) _FXPT_C(vrt_temp_t, _x, VRT_TEMP_RP) + +static inline vrt_temp_t +double_to_vrt_temp(double num){ + return VRT_TEMP_C(num); +} + +static inline int16_t +vrt_temp_round_to_int(vrt_temp_t fx){ + return _FXPT_TO_INT(fx, VRT_TEMP_C(1)); +} + +static inline double +vrt_temp_to_double(vrt_temp_t fx){ + return _FXPT_TO_DOUBLE(fx, VRT_TEMP_C(1)); +} + +#endif /* INCLUDED_VRT_TYPES_H */ |