diff options
author | Josh Blum | 2009-09-25 13:56:43 -0700 |
---|---|---|
committer | Josh Blum | 2009-09-25 13:56:43 -0700 |
commit | fd23d8e0b0f457b2b8b0db19bb74e6bac21189bb (patch) | |
tree | 3ff936592f470dedc95432cface62193b46cb5bb /vrt/include | |
parent | 6e71986985a157000cb41717cbce5b83e713e177 (diff) | |
download | gnuradio-fd23d8e0b0f457b2b8b0db19bb74e6bac21189bb.tar.gz gnuradio-fd23d8e0b0f457b2b8b0db19bb74e6bac21189bb.tar.bz2 gnuradio-fd23d8e0b0f457b2b8b0db19bb74e6bac21189bb.zip |
copied over vrt context and type headers, updated bits.h as well
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/if_context.h | 230 | ||||
-rw-r--r-- | vrt/include/vrt/types.h | 138 |
4 files changed, 404 insertions, 14 deletions
diff --git a/vrt/include/vrt/Makefile.am b/vrt/include/vrt/Makefile.am index b710547d9..2780d79b0 100644 --- a/vrt/include/vrt/Makefile.am +++ b/vrt/include/vrt/Makefile.am @@ -26,5 +26,7 @@ vrtinclude_HEADERS = \ copiers.h \ expanded_header.h \ quadradio.h \ + if_context.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/if_context.h b/vrt/include/vrt/if_context.h new file mode 100644 index 000000000..e51a7df6e --- /dev/null +++ b/vrt/include/vrt/if_context.h @@ -0,0 +1,230 @@ +/* -*- 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_IF_CONTEXT_H +#define INCLUDED_VRT_IF_CONTEXT_H + +#include <stdint.h> + +// Stream ID's for packet streams (low 8-bits) + +#define QR_SID_BEAMFORMER_IF_DATA 0x00 // paired +#define QR_SID_BEAMFORMER_IF_CNTX 0x00 // paired +#define QR_SID_DBOARD_0_IF_CNTX 0x01 // src assoc +#define QR_SID_DBOARD_1_IF_CNTX 0x02 // src assoc +#define QR_SID_DBOARD_2_IF_CNTX 0x03 // src assoc +#define QR_SID_DBOARD_3_IF_CNTX 0x04 // src assoc +#define QR_SID_GPS_IF_CNTX 0x05 // system assoc +#define QR_SID_SYS_INFO_EXT_CNTX 0x06 // system assoc + +// No class id, with 3 words of time. +// Used for all IF-Context packets +typedef struct if_context_hdr_tag { + uint32_t header; // first word of all packets + uint32_t stream_id; // mandatory in context packets + uint32_t integer_secs; // integer seconds timestamp + uint64_t fractional_secs; // fractional seconds timestamp + uint32_t context_indicator; // which context fields follow +} __attribute__((packed)) if_context_hdr_t; + + +// With class id, with 3 words of time. +// Used only with Extension Context packets +typedef struct if_context_hdr_with_classid_tag { + uint32_t header; // first word of all packets + uint32_t stream_id; // mandatory in context packets + uint64_t class_id; // class identifier + uint32_t integer_secs; // integer seconds timestamp + uint64_t fractional_secs; // fractional seconds timestamp + uint32_t context_indicator; // which context fields follow +} __attribute__((packed)) if_context_hdr_with_classid_t; + + +// ------------------------------------------------------------------------ +// Context Indicator field bits (Table 7.1.5.1-1) + +#define CI_CHANGE_INDICATOR (1 << 31) +#define CI_REF_POINT_ID (1 << 30) +#define CI_BANDWIDTH (1 << 29) +#define CI_IF_REF_FREQ (1 << 28) +#define CI_RF_REF_FREQ (1 << 27) +#define CI_RF_REF_FREQ_OFFSET (1 << 26) +#define CI_IF_BAND_OFFSET (1 << 25) +#define CI_REF_LEVEL (1 << 24) +#define CI_GAIN (1 << 23) +#define CI_OVER_RANGE_COUNT (1 << 22) +#define CI_SAMPLE_RATE (1 << 21) +#define CI_TIMESTAMP_ADJ (1 << 20) +#define CI_TIMESTAMP_CAL_TIME (1 << 19) +#define CI_TEMPERATURE (1 << 18) +#define CI_DEVICE_ID (1 << 17) +#define CI_STATE_AND_EVENT_IND (1 << 16) +#define CI_PAYLOAD_FMT (1 << 15) +#define CI_FORMATTED_GPS (1 << 14) +#define CI_FORMATTED_INS (1 << 13) +#define CI_ECEF_EPHEMERIS (1 << 12) +#define CI_REL_EPHEMERIS (1 << 11) +#define CI_EPHEMERIS_REF_ID (1 << 10) +#define CI_ASCII_GPS (1 << 9) +#define CI_CNTX_ASSOC_LISTS (1 << 8) +#define CI_RESERVED_7 (1 << 7) +#define CI_RESERVED_6 (1 << 6) +#define CI_RESERVED_5 (1 << 5) +#define CI_RESERVED_4 (1 << 4) +#define CI_RESERVED_3 (1 << 3) +#define CI_RESERVED_2 (1 << 2) +#define CI_RESERVED_1 (1 << 1) +#define CI_RESERVED_0 (1 << 0) + + +// ------------------------------------------------------------------------ +// Types that may be in the Context Section + + +// 7.1.5.10 Gain -- two Q10.6 dB fields + +static inline uint32_t +vrt_make_gain_field(int16_t stage1, int16_t stage2) +{ + return (((uint32_t) stage2) << 16) | (stage1 & 0xffff); +} + +static inline int16_t +vrt_gain_stage1(uint32_t field) +{ + return (int16_t)(field & 0xffff); +} + +static inline int16_t +vrt_gain_stage2(uint32_t field) +{ + return (int16_t)((field >> 16) & 0xffff); +} + +// See VITA-49.0 section 7.1.5.19 + +#define VRT_GPS_UNKNOWN_VALUE 0x7fffffff // for SOG, heading, track, and mag var + +typedef struct vrt_formatted_gps_tag { + uint32_t tsi_tsf_manuf_oui; + uint32_t integer_secs; // timestamp of position fix + uint64_t fractional_secs; // timestamp of position fix + uint32_t latitude; // degrees Q10.22 + uint32_t longitude; // degrees Q10.22 + uint32_t altitude; // meters Q27.5 + uint32_t speed_over_ground; + uint32_t heading_angle; + uint32_t track_angle; + uint32_t magnetic_variation; +} vrt_formatted_gps_t; + + +// Data Packet Payload Format Field 7.1.5.18 + +typedef struct vrt_payload_format_tag { + uint32_t word0; + uint32_t word1; +} vrt_payload_format_t; + +#define DF0_PACKED (1 << 31) +#define DF0_REAL_CMPLX_TYPE_MASK (0x3 << 29) +#define DF0_REAL_CMPLX_TYPE_REAL (0 << 29) +#define DF0_REAL_CMPLX_TYPE_CMPLX_CART (1 << 29) +#define DF0_REAL_CMPLX_TYPE_CMPLX_POLAR (2 << 29) +#define DF0_REAL_CMPLX_TYPE_RESERVED (3 << 29) +#define DF0_ITEM_FMT_MASK (0x1f << 24) +#define DF0_ITEM_FMT_SIGNED_FIXED_POINT (0x00 << 24) +#define DF0_ITEM_FMT_UNSIGNED_FIXED_POINT (0x10 << 24) +// lots more we're not using +#define DF0_SAMPLE_COMPONENT_REPEATING (1 << 23) +#define DF0_EVENT_TAG_SIZE_SHIFT 20 +#define DF0_EVENT_TAG_SIZE_MASK (0x7 << 20) +#define DF0_CHANNEL_TAG_SIZE_SHIFT 16 +#define DF0_CHANNEL_TAG_SIZE_MASK (0xf << 16) +#define DF0_RESERVED_SHIFT 12 +#define DF0_RESERVED_MASK (0xf << 12) +#define DF0_ITEM_PACKING_FIELD_SIZE_SHIFT 6 +#define DF0_ITEM_PACKING_FIELD_SIZE_MASK (0x3f << 6) +#define DF0_DATA_ITEM_SIZE_SHIFT 0 +#define DF0_DATA_ITEM_SIZE_MASK (0x3f << 0) + +#define DF1_REPEAT_COUNT_SHIFT 16 +#define DF1_REPEAT_COUNT_MASK (0xffff << 16) +#define DF1_VECTOR_SIZE_SHIFT 0 +#define DF1_VECTOR_SIZE_MASK (0xffff << 0) + + +// Composite values + +// 16-bit I & Q, no events, no channel tags +#define DF0_16_BIT_IQ \ + (0 \ + | DF0_REAL_CMPLX_TYPE_CMPLX_CART \ + | DF0_ITEM_FMT_SIGNED_FIXED_POINT \ + | (15 << DF0_ITEM_PACKING_FIELD_SIZE_SHIFT) \ + | (15 << DF0_DATA_ITEM_SIZE_SHIFT)) + +// Vector of length 1 +#define DF1_VECTOR_1 (0 << DF1_VECTOR_SIZE_SHIFT) + +// Vector of length 4 +#define DF1_VECTOR_4 (3 << DF1_VECTOR_SIZE_SHIFT) + + +// ------------------------------------------------------------------------ +// Our context packets + +typedef struct beamformer_if_cntx_tag { + if_context_hdr_t cntx_hdr; + uint64_t rf_ref_freq; // Q44.20 Hz + uint64_t sample_rate; // Q44.20 Hz + vrt_payload_format_t format; + // FIXME context association lists +} __attribute__((packed)) beamformer_if_cntx_t; + +typedef struct gps_if_cntx_tag { + if_context_hdr_t cntx_hdr; + vrt_formatted_gps_t formatted_gps; +} __attribute__((packed)) gps_if_cntx_t; + +typedef struct gain_if_cntx_tag { + if_context_hdr_t cntx_hdr; + uint32_t gain; +} __attribute__((packed)) gain_if_cntx_t; + + +// FIXME the rest... + +// ------------------------------------------------------------------------ +// All of them concatenated + +#define NCONTEXT_PKTS 6 // number of context pkts aggregated here + +typedef struct all_context_tag { + beamformer_if_cntx_t beamformer; + gain_if_cntx_t db[4]; + + // FIXME add Extension Context for board types, revs, serial numbers, temps + + gps_if_cntx_t gps; // must be last +} __attribute__((packed)) all_context_t; + +#define SIZEOF_ALL_CONTEXT (sizeof(all_context_t)) +#define SIZEOF_ALL_CONTEXT_BUT_GPS (SIZEOF_ALL_CONTEXT - sizeof(gps_if_cntx_t)) + + +#endif /* INCLUDED_IF_CONTEXT_H */ diff --git a/vrt/include/vrt/types.h b/vrt/include/vrt/types.h new file mode 100644 index 000000000..2081702c5 --- /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_altitude_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 */ |