Added configurable phase inversion to M17 demodulator. Forced enabling of phase inversion for MD3x0 VHF radios.
This commit is contained in:
parent
bfa3494777
commit
4d4ebae2f3
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ typedef struct
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -435,6 +435,7 @@ 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]);
|
||||||
|
if(invPhase) elem = 0.0f - elem;
|
||||||
baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem));
|
baseband.data[i] = static_cast< int16_t >(M17::rrc_24k(elem));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -574,3 +575,8 @@ bool M17Demodulator::update()
|
||||||
|
|
||||||
return newFrame;
|
return newFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void M17Demodulator::invertPhase(const bool status)
|
||||||
|
{
|
||||||
|
invPhase = status;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ void rtx_init(pthread_mutex_t *m)
|
||||||
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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue