This commit is contained in:
Krzysiek Egzmont 2024-01-29 22:42:38 +01:00
parent dc1808b1fe
commit aa92e93c56
10 changed files with 55 additions and 82 deletions

View File

@ -241,14 +241,12 @@ static void HandleReceive(void)
uint8_t Mode = END_OF_RX_MODE_SKIP; uint8_t Mode = END_OF_RX_MODE_SKIP;
if (gFlagTailNoteEliminationComplete) if (gFlagTailToneEliminationComplete) {
{
Mode = END_OF_RX_MODE_END; Mode = END_OF_RX_MODE_END;
goto Skip; goto Skip;
} }
if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel)) if (gScanStateDir != SCAN_OFF && IS_FREQ_CHANNEL(gNextMrChannel)) { // we are scanning in the frequency mode
{ // we are scanning in the frequency mode
if (g_SquelchLost) if (g_SquelchLost)
return; return;
@ -256,15 +254,13 @@ static void HandleReceive(void)
goto Skip; goto Skip;
} }
switch (gCurrentCodeType) switch (gCurrentCodeType) {
{
default: default:
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) if (gFoundCTCSS && gFoundCTCSSCountdown_10ms == 0) {
{
gFoundCTCSS = false; gFoundCTCSS = false;
gFoundCDCSS = false; gFoundCDCSS = false;
Mode = END_OF_RX_MODE_END; Mode = END_OF_RX_MODE_END;
@ -274,8 +270,7 @@ static void HandleReceive(void)
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0) if (gFoundCDCSS && gFoundCDCSSCountdown_10ms == 0) {
{
gFoundCTCSS = false; gFoundCTCSS = false;
gFoundCDCSS = false; gFoundCDCSS = false;
Mode = END_OF_RX_MODE_END; Mode = END_OF_RX_MODE_END;
@ -284,21 +279,16 @@ static void HandleReceive(void)
break; break;
} }
if (g_SquelchLost) if (g_SquelchLost) {
{ if (!gEndOfRxDetectedMaybe
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (!gEndOfRxDetectedMaybe && !IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) && !IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)
#else #endif
if (!gEndOfRxDetectedMaybe) ) {
#endif switch (gCurrentCodeType) {
{
switch (gCurrentCodeType)
{
case CODE_TYPE_OFF: case CODE_TYPE_OFF:
if (gEeprom.SQUELCH_LEVEL) if (gEeprom.SQUELCH_LEVEL) {
{ if (g_CxCSS_TAIL_Found) {
if (g_CxCSS_TAIL_Found)
{
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
} }
@ -306,19 +296,15 @@ static void HandleReceive(void)
break; break;
case CODE_TYPE_CONTINUOUS_TONE: case CODE_TYPE_CONTINUOUS_TONE:
if (g_CTCSS_Lost) if (g_CTCSS_Lost) {
{
gFoundCTCSS = false; gFoundCTCSS = false;
} }
else else if (!gFoundCTCSS) {
if (!gFoundCTCSS)
{
gFoundCTCSS = true; gFoundCTCSS = true;
gFoundCTCSSCountdown_10ms = 100; // 1 sec gFoundCTCSSCountdown_10ms = 100; // 1 sec
} }
if (g_CxCSS_TAIL_Found) if (g_CxCSS_TAIL_Found) {
{
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
g_CxCSS_TAIL_Found = false; g_CxCSS_TAIL_Found = false;
} }
@ -326,19 +312,15 @@ static void HandleReceive(void)
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE) if (g_CDCSS_Lost && gCDCSSCodeType == CDCSS_POSITIVE_CODE) {
{
gFoundCDCSS = false; gFoundCDCSS = false;
} }
else else if (!gFoundCDCSS) {
if (!gFoundCDCSS)
{
gFoundCDCSS = true; gFoundCDCSS = true;
gFoundCDCSSCountdown_10ms = 100; // 1 sec gFoundCDCSSCountdown_10ms = 100; // 1 sec
} }
if (g_CxCSS_TAIL_Found) if (g_CxCSS_TAIL_Found) {
{
if (BK4819_GetCTCType() == 1) if (BK4819_GetCTCType() == 1)
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
@ -356,32 +338,28 @@ static void HandleReceive(void)
Mode == END_OF_RX_MODE_SKIP && Mode == END_OF_RX_MODE_SKIP &&
gNextTimeslice40ms && gNextTimeslice40ms &&
gEeprom.TAIL_TONE_ELIMINATION && gEeprom.TAIL_TONE_ELIMINATION &&
(gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) && (gCurrentCodeType == CODE_TYPE_DIGITAL || gCurrentCodeType == CODE_TYPE_REVERSE_DIGITAL) &&
BK4819_GetCTCType() == 1) BK4819_GetCTCType() == 1)
Mode = END_OF_RX_MODE_TTE; Mode = END_OF_RX_MODE_TTE;
else else
gNextTimeslice40ms = false; gNextTimeslice40ms = false;
Skip: Skip:
switch (Mode) switch (Mode) {
{
case END_OF_RX_MODE_SKIP: case END_OF_RX_MODE_SKIP:
break; break;
case END_OF_RX_MODE_END: case END_OF_RX_MODE_END:
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE)) if (IS_NOAA_CHANNEL(gRxVfo->CHANNEL_SAVE))
gNOAACountdown_10ms = 300; // 3 sec gNOAACountdown_10ms = 300; // 3 sec
#endif #endif
gUpdateDisplay = true; gUpdateDisplay = true;
if (gScanStateDir != SCAN_OFF) if (gScanStateDir != SCAN_OFF) {
{ switch (gEeprom.SCAN_RESUME_MODE) {
switch (gEeprom.SCAN_RESUME_MODE)
{
case SCAN_RESUME_TO: case SCAN_RESUME_TO:
break; break;
@ -399,12 +377,11 @@ Skip:
break; break;
case END_OF_RX_MODE_TTE: case END_OF_RX_MODE_TTE:
if (gEeprom.TAIL_TONE_ELIMINATION) if (gEeprom.TAIL_TONE_ELIMINATION) {
{
AUDIO_AudioPathOff(); AUDIO_AudioPathOff();
gTailNoteEliminationCountdown_10ms = 20; gTailToneEliminationCountdown_10ms = 20;
gFlagTailNoteEliminationComplete = false; gFlagTailToneEliminationComplete = false;
gEndOfRxDetectedMaybe = true; gEndOfRxDetectedMaybe = true;
gEnableSpeaker = false; gEnableSpeaker = false;
} }
@ -1196,7 +1173,7 @@ void APP_TimeSlice10ms(void)
if (gAlarmState == ALARM_STATE_TXALARM) { if (gAlarmState == ALARM_STATE_TXALARM) {
gAlarmState = ALARM_STATE_SITE_ALARM; gAlarmState = ALARM_STATE_SITE_ALARM;
RADIO_EnableCxCSS(); RADIO_SendCssTail();
BK4819_SetupPowerAmplifier(0, 0); BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false); BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_PA_ENABLE, false);
BK4819_Enable_AfDac_DiscMode_TxDsp(); BK4819_Enable_AfDac_DiscMode_TxDsp();

View File

@ -80,11 +80,9 @@ void DTMF_clear_RX(void)
void DTMF_SendEndOfTransmission(void) void DTMF_SendEndOfTransmission(void)
{ {
if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO) { if (gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_APOLLO)
BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE); BK4819_PlaySingleTone(2475, 250, 28, gEeprom.DTMF_SIDE_TONE);
} else if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
&& gDTMF_CallState == DTMF_CALL_STATE_NONE && gDTMF_CallState == DTMF_CALL_STATE_NONE
#endif #endif

View File

@ -1395,18 +1395,16 @@ void BK4819_GenTail(uint8_t Tail)
} }
} }
void BK4819_EnableCDCSS(void) void BK4819_PlayCDCSSTail(void)
{ {
BK4819_GenTail(0); // CTC134 BK4819_GenTail(0); // CTC134
BK4819_WriteRegister(BK4819_REG_51, 0x804A); BK4819_WriteRegister(BK4819_REG_51, 0x804A); // 1 0 0 0 0 0 0 0 0 1001010
} }
void BK4819_EnableCTCSS(void) void BK4819_PlayCTCSSTail(void)
{ {
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT #ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
//BK4819_GenTail(1); // 120° phase shift
BK4819_GenTail(2); // 180° phase shift BK4819_GenTail(2); // 180° phase shift
//BK4819_GenTail(3); // 240° phase shift
#else #else
BK4819_GenTail(4); // 55Hz tone freq BK4819_GenTail(4); // 55Hz tone freq
#endif #endif
@ -1448,7 +1446,7 @@ void BK4819_EnableCTCSS(void)
// 0 = min // 0 = min
// 127 = max // 127 = max
BK4819_WriteRegister(BK4819_REG_51, 0x904A); // 1 0 0 1 0 0 0 0 0 1001010 BK4819_WriteRegister(BK4819_REG_51, 0x904A); // 1 0 0 1 0 0 0 0 0 1001010
} }
uint16_t BK4819_GetRSSI(void) uint16_t BK4819_GetRSSI(void)

View File

@ -132,8 +132,8 @@ void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t F
void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency); void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency);
void BK4819_GenTail(uint8_t Tail); void BK4819_GenTail(uint8_t Tail);
void BK4819_EnableCDCSS(void); void BK4819_PlayCDCSSTail(void);
void BK4819_EnableCTCSS(void); void BK4819_PlayCTCSSTail(void);
uint16_t BK4819_GetRSSI(void); uint16_t BK4819_GetRSSI(void);
int8_t BK4819_GetRxGain_dB(void); int8_t BK4819_GetRxGain_dB(void);

View File

@ -57,8 +57,8 @@ void FUNCTION_Init(void)
g_SquelchLost = false; g_SquelchLost = false;
gFlagTailNoteEliminationComplete = false; gFlagTailToneEliminationComplete = false;
gTailNoteEliminationCountdown_10ms = 0; gTailToneEliminationCountdown_10ms = 0;
gFoundCTCSS = false; gFoundCTCSS = false;
gFoundCDCSS = false; gFoundCDCSS = false;
gFoundCTCSSCountdown_10ms = 0; gFoundCTCSSCountdown_10ms = 0;

4
misc.c
View File

@ -132,7 +132,7 @@ volatile bool gNextTimeslice_500ms;
volatile uint16_t gTxTimerCountdown_500ms; volatile uint16_t gTxTimerCountdown_500ms;
volatile bool gTxTimeoutReached; volatile bool gTxTimeoutReached;
volatile uint16_t gTailNoteEliminationCountdown_10ms; volatile uint16_t gTailToneEliminationCountdown_10ms;
volatile uint8_t gVFOStateResumeCountdown_500ms; volatile uint8_t gVFOStateResumeCountdown_500ms;
@ -237,7 +237,7 @@ volatile bool gNextTimeslice40ms;
volatile uint16_t gNOAACountdown_10ms = 0; volatile uint16_t gNOAACountdown_10ms = 0;
volatile bool gScheduleNOAA = true; volatile bool gScheduleNOAA = true;
#endif #endif
volatile bool gFlagTailNoteEliminationComplete; volatile bool gFlagTailToneEliminationComplete;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
volatile bool gScheduleFM; volatile bool gScheduleFM;
#endif #endif

4
misc.h
View File

@ -205,7 +205,7 @@ extern volatile bool gNextTimeslice_500ms;
extern volatile uint16_t gTxTimerCountdown_500ms; extern volatile uint16_t gTxTimerCountdown_500ms;
extern volatile bool gTxTimeoutReached; extern volatile bool gTxTimeoutReached;
extern volatile uint16_t gTailNoteEliminationCountdown_10ms; extern volatile uint16_t gTailToneEliminationCountdown_10ms;
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
extern volatile uint16_t gNOAA_Countdown_10ms; extern volatile uint16_t gNOAA_Countdown_10ms;
@ -315,7 +315,7 @@ extern volatile bool gNextTimeslice40ms;
extern volatile uint16_t gNOAACountdown_10ms; extern volatile uint16_t gNOAACountdown_10ms;
extern volatile bool gScheduleNOAA; extern volatile bool gScheduleNOAA;
#endif #endif
extern volatile bool gFlagTailNoteEliminationComplete; extern volatile bool gFlagTailToneEliminationComplete;
extern volatile uint8_t gVFOStateResumeCountdown_500ms; extern volatile uint8_t gVFOStateResumeCountdown_500ms;
#ifdef ENABLE_FMRADIO #ifdef ENABLE_FMRADIO
extern volatile bool gScheduleFM; extern volatile bool gScheduleFM;

14
radio.c
View File

@ -983,9 +983,9 @@ void RADIO_PrepareTX(void)
gTxTimerCountdown_500ms = 0; // no timeout gTxTimerCountdown_500ms = 0; // no timeout
#if defined(ENABLE_ALARM) || defined(ENABLE_TX1750) #if defined(ENABLE_ALARM) || defined(ENABLE_TX1750)
if (gAlarmState == ALARM_STATE_OFF) if (gAlarmState == ALARM_STATE_OFF)
#endif #endif
{ {
if (gEeprom.TX_TIMEOUT_TIMER == 0) if (gEeprom.TX_TIMEOUT_TIMER == 0)
gTxTimerCountdown_500ms = 60; // 30 sec gTxTimerCountdown_500ms = 60; // 30 sec
@ -1004,15 +1004,15 @@ void RADIO_PrepareTX(void)
#endif #endif
} }
void RADIO_EnableCxCSS(void) void RADIO_SendCssTail(void)
{ {
switch (gCurrentVfo->pTX->CodeType) { switch (gCurrentVfo->pTX->CodeType) {
case CODE_TYPE_DIGITAL: case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL: case CODE_TYPE_REVERSE_DIGITAL:
BK4819_EnableCDCSS(); BK4819_PlayCDCSSTail();
break; break;
default: default:
BK4819_EnableCTCSS(); BK4819_PlayCTCSSTail();
break; break;
} }
@ -1025,7 +1025,7 @@ void RADIO_SendEndOfTransmission(void)
DTMF_SendEndOfTransmission(); DTMF_SendEndOfTransmission();
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
RADIO_EnableCxCSS(); RADIO_SendCssTail();
RADIO_SetupRegisters(false); RADIO_SetupRegisters(false);
} }
@ -1035,6 +1035,6 @@ void RADIO_PrepareCssTX(void)
SYSTEM_DelayMs(200); SYSTEM_DelayMs(200);
RADIO_EnableCxCSS(); RADIO_SendCssTail();
RADIO_SetupRegisters(true); RADIO_SetupRegisters(true);
} }

View File

@ -164,7 +164,7 @@ void RADIO_SetupAGC(bool listeningAM, bool disable);
void RADIO_SetModulation(ModulationMode_t modulation); void RADIO_SetModulation(ModulationMode_t modulation);
void RADIO_SetVfoState(VfoState_t State); void RADIO_SetVfoState(VfoState_t State);
void RADIO_PrepareTX(void); void RADIO_PrepareTX(void);
void RADIO_EnableCxCSS(void); void RADIO_SendCssTail(void);
void RADIO_PrepareCssTX(void); void RADIO_PrepareCssTX(void);
void RADIO_SendEndOfTransmission(void); void RADIO_SendEndOfTransmission(void);

View File

@ -92,7 +92,7 @@ void SystickHandler(void)
if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT) if (gCurrentFunction != FUNCTION_MONITOR && gCurrentFunction != FUNCTION_TRANSMIT)
DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen); DECREMENT_AND_TRIGGER(gScanPauseDelayIn_10ms, gScheduleScanListen);
DECREMENT_AND_TRIGGER(gTailNoteEliminationCountdown_10ms, gFlagTailNoteEliminationComplete); DECREMENT_AND_TRIGGER(gTailToneEliminationCountdown_10ms, gFlagTailToneEliminationComplete);
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice); DECREMENT_AND_TRIGGER(gCountdownToPlayNextVoice_10ms, gFlagPlayQueuedVoice);