aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSylvain Munaut <tnt@246tNt.com>2016-03-07 15:22:07 +0100
committerSylvain Munaut <tnt@246tNt.com>2016-09-12 15:51:17 -0600
commit22022252083f8833ef8d46d062edc877957a67a0 (patch)
treefd42c515ca4c1abd5dff4f5669c7a37995add993
parent35ed5379ca29c083e0868cd7adb4404a9c1a0934 (diff)
sdr/pi4cxpsk: Add support for pi/2-CBPSK
The rotation is not always pi/4 now. Ideally everything should get renamed but that's a big diff and will be done later. Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
-rw-r--r--include/osmocom/gmr1/sdr/pi4cxpsk.h12
-rw-r--r--src/sdr/pi4cxpsk.c35
2 files changed, 31 insertions, 16 deletions
diff --git a/include/osmocom/gmr1/sdr/pi4cxpsk.h b/include/osmocom/gmr1/sdr/pi4cxpsk.h
index 61f09bf..57178c9 100644
--- a/include/osmocom/gmr1/sdr/pi4cxpsk.h
+++ b/include/osmocom/gmr1/sdr/pi4cxpsk.h
@@ -1,4 +1,4 @@
-/* GMR-1 SDR - pi4-CBPSK and pi4-CQPSK modulation support */
+/* GMR-1 SDR - pi2-CBPSK, pi4-CBPSK and pi4-CQPSK modulation support */
/* See GMR-1 05.004 (ETSI TS 101 376-5-4 V1.2.1) - Section 5.1 & 5.2 */
/* (C) 2011-2016 by Sylvain Munaut <tnt@246tNt.com>
@@ -21,13 +21,13 @@
#ifndef __OSMO_GMR1_SDR_PI4CXPSK_H__
#define __OSMO_GMR1_SDR_PI4CXPSK_H__
-/*! \defgroup pi4cxpsk pi4-CBPSK and pi4-CQPSK modulation
+/*! \defgroup pi4cxpsk pi2-CBPSK, pi4-CBPSK and pi4-CQPSK modulation
* \ingroup sdr
* @{
*/
/*! \file sdr/pi4cxpsk.h
- * \brief Osmocom GMR-1 pi4-CBPSK and pi4-CQPSK modulation support header
+ * \brief Osmocom GMR-1 pi2-CBPSK, pi4-CBPSK and pi4-CQPSK modulation support header
*/
#include <stdint.h>
@@ -50,14 +50,16 @@ struct gmr1_pi4cxpsk_symbol {
/*! \brief pi4-CxPSK modulation description */
struct gmr1_pi4cxpsk_modulation {
- int nbits; /*!< \brief ebits/sym */
+ float rotation; /*!< \brief rotation per symbol */
+ int nbits; /*!< \brief ebits/sym */
struct gmr1_pi4cxpsk_symbol *syms; /*!< \brief Symbols (sym order) */
struct gmr1_pi4cxpsk_symbol *bits; /*!< \brief Symbols (bit order) */
};
-extern struct gmr1_pi4cxpsk_modulation gmr1_pi4cqpsk;
+extern struct gmr1_pi4cxpsk_modulation gmr1_pi2cbpsk;
extern struct gmr1_pi4cxpsk_modulation gmr1_pi4cbpsk;
+extern struct gmr1_pi4cxpsk_modulation gmr1_pi4cqpsk;
/*! \brief pi4-CxPSK Synchronization sequence segment description */
diff --git a/src/sdr/pi4cxpsk.c b/src/sdr/pi4cxpsk.c
index 243a305..12710c1 100644
--- a/src/sdr/pi4cxpsk.c
+++ b/src/sdr/pi4cxpsk.c
@@ -1,4 +1,4 @@
-/* GMR-1 SDR - pi4-CBPSK and pi4-CQPSK modulation support */
+/* GMR-1 SDR - pi2-CBPSK, pi4-CBPSK & pi4-CQPSK modulation support */
/* See GMR-1 05.004 (ETSI TS 101 376-5-4 V1.2.1) - Section 5.1 & 5.2 */
/* (C) 2011-2016 by Sylvain Munaut <tnt@246tNt.com>
@@ -23,7 +23,7 @@
*/
/*! \file sdr/pi4cxpsk.c
- * \brief Osmocom GMR-1 pi4-CBPSK and pi4-CQPSK modulation support implementation
+ * \brief Osmocom GMR-1 pi2-CBPSK, pi4-CBPSK and pi4-CQPSK modulation support implementation
*/
#include <complex.h>
@@ -66,17 +66,26 @@
* continuous rotation)
*/
-/*! \brief pi4-CBPSK symbols descriptions */
-static struct gmr1_pi4cxpsk_symbol gmr1_pi4cbpsk_syms_bits[] = {
+/*! \brief pi{2,4}-CBPSK symbols descriptions */
+static struct gmr1_pi4cxpsk_symbol gmr1_piNcbpsk_syms_bits[] = {
{ 0, {0}, 0*M_PIf/2, 1+0*I },
{ 1, {1}, 2*M_PIf/2, -1+0*I },
};
+/*! \brief pi2-CBPSK modulation description */
+struct gmr1_pi4cxpsk_modulation gmr1_pi2cbpsk = {
+ .rotation = M_PIf/2,
+ .nbits = 1,
+ .syms = gmr1_piNcbpsk_syms_bits,
+ .bits = gmr1_piNcbpsk_syms_bits,
+};
+
/*! \brief pi4-CBPSK modulation description */
struct gmr1_pi4cxpsk_modulation gmr1_pi4cbpsk = {
+ .rotation = M_PIf/4,
.nbits = 1,
- .syms = gmr1_pi4cbpsk_syms_bits,
- .bits = gmr1_pi4cbpsk_syms_bits,
+ .syms = gmr1_piNcbpsk_syms_bits,
+ .bits = gmr1_piNcbpsk_syms_bits,
};
@@ -98,6 +107,7 @@ static struct gmr1_pi4cxpsk_symbol gmr1_pi4cqpsk_bits[] = {
/*! \brief pi4-CQPSK modulation description */
struct gmr1_pi4cxpsk_modulation gmr1_pi4cqpsk = {
+ .rotation = M_PIf/4,
.nbits = 2,
.syms = gmr1_pi4cqpsk_syms,
.bits = gmr1_pi4cqpsk_bits,
@@ -525,7 +535,7 @@ gmr1_pi4cxpsk_demod(struct gmr1_pi4cxpsk_burst *burst_type,
goto err;
/* Normalize the burst and counter rotate by pi/4 */
- burst = osmo_cxvec_sig_normalize(burst_in, 1, (freq_shift - (M_PIf/4)) / sps, NULL);
+ burst = osmo_cxvec_sig_normalize(burst_in, 1, (freq_shift - burst_type->mod->rotation) / sps, NULL);
if (!burst) {
rv = -ENOMEM;
goto err;
@@ -601,7 +611,7 @@ err:
* \param[out] toa_p Pointer to TOA return variable
* \returns -errno for errors, 0 for success
*
- * The various burst types must be compatible in length.
+ * The various burst types must be compatible in length and modulation !
*/
int
gmr1_pi4cxpsk_detect(struct gmr1_pi4cxpsk_burst **burst_types, float e_toa,
@@ -614,8 +624,8 @@ gmr1_pi4cxpsk_detect(struct gmr1_pi4cxpsk_burst **burst_types, float e_toa,
float p_toa=0.0f, p_pwr=0.0f;
int rv = 0;
- /* Normalize the burst and counter rotate by pi/4 */
- burst = osmo_cxvec_sig_normalize(burst_in, 1, (freq_shift - (M_PIf/4)) / sps, NULL);
+ /* Normalize the burst and counter rotate */
+ burst = osmo_cxvec_sig_normalize(burst_in, 1, (freq_shift - burst_types[0]->mod->rotation) / sps, NULL);
if (!burst) {
rv = -ENOMEM;
goto err;
@@ -675,6 +685,9 @@ err:
* \param[in] sps Oversampling used in the input complex signal
* \param[in] freq_shift Frequency shift to pre-apply to burst_in (rad/sym)
* \returns <0 for error. 2 for BPSK, 4 for QPSK.
+ *
+ * Since x^4 only make sense for pi/4 variant, the pi/4 counter rotation is
+ * always applied.
*/
int
gmr1_pi4cxpsk_mod_order(struct osmo_cxvec *burst_in, int sps, float freq_shift)
@@ -776,7 +789,7 @@ gmr1_pi4cxpsk_mod(struct gmr1_pi4cxpsk_burst *burst_type,
}
/* Apply the final pi/4 rotation */
- osmo_cxvec_rotate(burst_out, M_PIf / 4.0f, burst_out);
+ osmo_cxvec_rotate(burst_out, burst_type->mod->rotation, burst_out);
rv = 0;