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

View File

@ -57,6 +57,7 @@ typedef struct
char source_address[10]; /**< M17 call source address */
char destination_address[10]; /**< M17 call routing address */
bool invertRxPhase; /**< M17 RX phase inversion */
}
rtxStatus_t;

View File

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

View File

@ -435,6 +435,7 @@ bool M17Demodulator::update()
for(size_t i = 0; i < baseband.len; i++)
{
float elem = static_cast< float >(baseband.data[i]);
if(invPhase) elem = 0.0f - elem;
baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem));
}
@ -574,3 +575,8 @@ bool M17Demodulator::update()
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;
// 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
switch(status->opStatus)
{
@ -135,6 +141,7 @@ void OpMode_M17::rxState(rtxStatus_t *const status)
{
decoder.reset();
demodulator.startBasebandSampling();
demodulator.invertPhase(status->invertRxPhase);
audio_enableAmp();
codec_startDecode(SINK_SPK);

View File

@ -58,6 +58,7 @@ void rtx_init(pthread_mutex_t *m)
rtxStatus.rxTone = 0;
rtxStatus.txToneEn = 0;
rtxStatus.txTone = 0;
rtxStatus.invertRxPhase = false;
currMode = &noMode;
/*