Added configurable phase inversion to M17 demodulator. Forced enabling of phase inversion for MD3x0 VHF radios.

This commit is contained in:
Silvano Seva 2022-05-30 19:03:29 +02:00
parent bfa3494777
commit 4d4ebae2f3
6 changed files with 39 additions and 15 deletions

View File

@ -109,6 +109,13 @@ public:
*/ */
bool isLocked(); bool isLocked();
/**
* Invert baseband signal phase before decoding.
*
* @param status: if set to true signal phase is inverted.
*/
void invertPhase(const bool status);
private: private:
/** /**
@ -150,6 +157,7 @@ private:
bool newFrame; ///< A new frame has been fully decoded. bool newFrame; ///< A new frame has been fully decoded.
int16_t basebandBridge[M17_BRIDGE_SIZE] = { 0 }; ///< Bridge buffer int16_t basebandBridge[M17_BRIDGE_SIZE] = { 0 }; ///< Bridge buffer
int16_t phase; ///< Phase of the signal w.r.t. sampling int16_t phase; ///< Phase of the signal w.r.t. sampling
bool invPhase; ///< Invert signal phase
/* /*
* State variables * State variables

View File

@ -55,8 +55,9 @@ typedef struct
uint8_t rxCan : 4, /**< M17 Channel Access Number for RX squelch */ uint8_t rxCan : 4, /**< M17 Channel Access Number for RX squelch */
txCan : 4; /**< M17 Channel Access Number for TX squelch */ txCan : 4; /**< M17 Channel Access Number for TX squelch */
char source_address[10]; /**< M17 call source address */ char source_address[10]; /**< M17 call source address */
char destination_address[10]; /**< M17 call routing address */ char destination_address[10]; /**< M17 call routing address */
bool invertRxPhase; /**< M17 RX phase inversion */
} }
rtxStatus_t; rtxStatus_t;

View File

@ -103,12 +103,13 @@ void *ui_task(void *arg)
rtx_cfg.rxTone = ctcss_tone[state.channel.fm.rxTone]; rtx_cfg.rxTone = ctcss_tone[state.channel.fm.rxTone];
rtx_cfg.txToneEn = state.channel.fm.txToneEn; rtx_cfg.txToneEn = state.channel.fm.txToneEn;
rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone]; rtx_cfg.txTone = ctcss_tone[state.channel.fm.txTone];
pthread_mutex_unlock(&rtx_mutex);
// Copy new M17 source and destination addresses // Copy new M17 source and destination addresses
strncpy(rtx_cfg.source_address, state.settings.callsign, 10); strncpy(rtx_cfg.source_address, state.settings.callsign, 10);
strncpy(rtx_cfg.destination_address, state.m17_data.dst_addr, 10); strncpy(rtx_cfg.destination_address, state.m17_data.dst_addr, 10);
pthread_mutex_unlock(&rtx_mutex);
rtx_configure(&rtx_cfg); rtx_configure(&rtx_cfg);
sync_rtx = false; sync_rtx = false;
} }

View File

@ -435,7 +435,8 @@ bool M17Demodulator::update()
for(size_t i = 0; i < baseband.len; i++) for(size_t i = 0; i < baseband.len; i++)
{ {
float elem = static_cast< float >(baseband.data[i]); float elem = static_cast< float >(baseband.data[i]);
baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem)); if(invPhase) elem = 0.0f - elem;
baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem));
} }
// Process the buffer // Process the buffer
@ -574,3 +575,8 @@ bool M17Demodulator::update()
return newFrame; return newFrame;
} }
void M17Demodulator::invertPhase(const bool status)
{
invPhase = status;
}

View File

@ -66,6 +66,12 @@ void OpMode_M17::update(rtxStatus_t *const status, const bool newCfg)
{ {
(void) newCfg; (void) newCfg;
// Force inversion of RX phase for MD3x0 VHF radios
#ifdef PLATFORM_MD3x0
const hwInfo_t* hwinfo = platform_getHwInfo();
status->invertRxPhase |= hwinfo->vhf_band;
#endif
// Main FSM logic // Main FSM logic
switch(status->opStatus) switch(status->opStatus)
{ {
@ -135,6 +141,7 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
{ {
decoder.reset(); decoder.reset();
demodulator.startBasebandSampling(); demodulator.startBasebandSampling();
demodulator.invertPhase(status->invertRxPhase);
audio_enableAmp(); audio_enableAmp();
codec_startDecode(SINK_SPK); codec_startDecode(SINK_SPK);

View File

@ -46,18 +46,19 @@ void rtx_init(pthread_mutex_t *m)
/* /*
* Default initialisation for rtx status * Default initialisation for rtx status
*/ */
rtxStatus.opMode = OPMODE_NONE; rtxStatus.opMode = OPMODE_NONE;
rtxStatus.bandwidth = BW_25; rtxStatus.bandwidth = BW_25;
rtxStatus.txDisable = 0; rtxStatus.txDisable = 0;
rtxStatus.opStatus = OFF; rtxStatus.opStatus = OFF;
rtxStatus.rxFrequency = 430000000; rtxStatus.rxFrequency = 430000000;
rtxStatus.txFrequency = 430000000; rtxStatus.txFrequency = 430000000;
rtxStatus.txPower = 0.0f; rtxStatus.txPower = 0.0f;
rtxStatus.sqlLevel = 1; rtxStatus.sqlLevel = 1;
rtxStatus.rxToneEn = 0; rtxStatus.rxToneEn = 0;
rtxStatus.rxTone = 0; rtxStatus.rxTone = 0;
rtxStatus.txToneEn = 0; rtxStatus.txToneEn = 0;
rtxStatus.txTone = 0; rtxStatus.txTone = 0;
rtxStatus.invertRxPhase = false;
currMode = &noMode; currMode = &noMode;
/* /*