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

View File

@ -80,11 +80,9 @@ void DTMF_clear_RX(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);
}
if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
else if ((gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_TX_DOWN || gCurrentVfo->DTMF_PTT_ID_TX_MODE == PTT_ID_BOTH)
#ifdef ENABLE_DTMF_CALLING
&& gDTMF_CallState == DTMF_CALL_STATE_NONE
#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_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
//BK4819_GenTail(1); // 120° phase shift
BK4819_GenTail(2); // 180° phase shift
//BK4819_GenTail(3); // 240° phase shift
#else
BK4819_GenTail(4); // 55Hz tone freq
#endif

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_GenTail(uint8_t Tail);
void BK4819_EnableCDCSS(void);
void BK4819_EnableCTCSS(void);
void BK4819_PlayCDCSSTail(void);
void BK4819_PlayCTCSSTail(void);
uint16_t BK4819_GetRSSI(void);
int8_t BK4819_GetRxGain_dB(void);

View File

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

4
misc.c
View File

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

4
misc.h
View File

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

10
radio.c
View File

@ -1004,15 +1004,15 @@ void RADIO_PrepareTX(void)
#endif
}
void RADIO_EnableCxCSS(void)
void RADIO_SendCssTail(void)
{
switch (gCurrentVfo->pTX->CodeType) {
case CODE_TYPE_DIGITAL:
case CODE_TYPE_REVERSE_DIGITAL:
BK4819_EnableCDCSS();
BK4819_PlayCDCSSTail();
break;
default:
BK4819_EnableCTCSS();
BK4819_PlayCTCSSTail();
break;
}
@ -1025,7 +1025,7 @@ void RADIO_SendEndOfTransmission(void)
DTMF_SendEndOfTransmission();
// send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
RADIO_EnableCxCSS();
RADIO_SendCssTail();
RADIO_SetupRegisters(false);
}
@ -1035,6 +1035,6 @@ void RADIO_PrepareCssTX(void)
SYSTEM_DelayMs(200);
RADIO_EnableCxCSS();
RADIO_SendCssTail();
RADIO_SetupRegisters(true);
}

View File

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

View File

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