This commit is contained in:
Krzysiek Egzmont
2024-01-14 00:23:14 +01:00
parent 8941576887
commit ea3b5b23a9

View File

@@ -586,16 +586,34 @@ static void CheckRadioInterrupts(void)
if (SCANNER_IsScanning()) if (SCANNER_IsScanning())
return; return;
while (BK4819_ReadRegister(BK4819_REG_0C) & 1u) while (BK4819_ReadRegister(BK4819_REG_0C) & 1u) { // BK chip interrupt request
{ // BK chip interrupt request // clear interrupts
uint16_t interrupt_status_bits;
// reset the interrupt ?
BK4819_WriteRegister(BK4819_REG_02, 0); BK4819_WriteRegister(BK4819_REG_02, 0);
// fetch interrupt status bits
// fetch the interrupt status bits union {
interrupt_status_bits = BK4819_ReadRegister(BK4819_REG_02); struct {
uint16_t __UNUSED : 1;
uint16_t fskRxSync : 1;
uint16_t sqlLost : 1;
uint16_t sqlFound : 1;
uint16_t voxLost : 1;
uint16_t voxFound : 1;
uint16_t ctcssLost : 1;
uint16_t ctcssFound : 1;
uint16_t cdcssLost : 1;
uint16_t cdcssFound : 1;
uint16_t cssTailFound : 1;
uint16_t dtmf5ToneFound : 1;
uint16_t fskFifoAlmostFull : 1;
uint16_t fskRxFinied : 1;
uint16_t fskFifoAlmostEmpty : 1;
uint16_t fskTxFinied : 1;
};
uint16_t __raw;
} interrupts;
interrupts.__raw = BK4819_ReadRegister(BK4819_REG_02);
// 0 = no phase shift // 0 = no phase shift
// 1 = 120deg phase shift // 1 = 120deg phase shift
@@ -605,18 +623,13 @@ static void CheckRadioInterrupts(void)
// if (ctcss_shift > 0) // if (ctcss_shift > 0)
// g_CTCSS_Lost = true; // g_CTCSS_Lost = true;
if (interrupt_status_bits & BK4819_REG_02_DTMF_5TONE_FOUND) if (interrupts.dtmf5ToneFound) {
{ // save the RX'ed DTMF character const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); // save the RX'ed DTMF character
const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code()); if (c != 0xff) {
if (c != 0xff) if (gCurrentFunction != FUNCTION_TRANSMIT) {
{ if (gSetting_live_DTMF_decoder) {
if (gCurrentFunction != FUNCTION_TRANSMIT)
{
if (gSetting_live_DTMF_decoder)
{
size_t len = strlen(gDTMF_RX_live); size_t len = strlen(gDTMF_RX_live);
if (len >= (sizeof(gDTMF_RX_live) - 1)) if (len >= sizeof(gDTMF_RX_live) - 1) { // make room
{ // make room
memmove(&gDTMF_RX_live[0], &gDTMF_RX_live[1], sizeof(gDTMF_RX_live) - 1); memmove(&gDTMF_RX_live[0], &gDTMF_RX_live[1], sizeof(gDTMF_RX_live) - 1);
len--; len--;
} }
@@ -627,10 +640,8 @@ static void CheckRadioInterrupts(void)
} }
#ifdef ENABLE_DTMF_CALLING #ifdef ENABLE_DTMF_CALLING
if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) if (gRxVfo->DTMF_DECODING_ENABLE || gSetting_KILLED) {
{ if (gDTMF_RX_index >= sizeof(gDTMF_RX) - 1) { // make room
if (gDTMF_RX_index >= (sizeof(gDTMF_RX) - 1))
{ // make room
memmove(&gDTMF_RX[0], &gDTMF_RX[1], sizeof(gDTMF_RX) - 1); memmove(&gDTMF_RX[0], &gDTMF_RX[1], sizeof(gDTMF_RX) - 1);
gDTMF_RX_index--; gDTMF_RX_index--;
} }
@@ -647,40 +658,35 @@ static void CheckRadioInterrupts(void)
} }
} }
if (interrupt_status_bits & BK4819_REG_02_CxCSS_TAIL) if (interrupts.cssTailFound)
g_CxCSS_TAIL_Found = true; g_CxCSS_TAIL_Found = true;
if (interrupt_status_bits & BK4819_REG_02_CDCSS_LOST) if (interrupts.cdcssLost) {
{
g_CDCSS_Lost = true; g_CDCSS_Lost = true;
gCDCSSCodeType = BK4819_GetCDCSSCodeType(); gCDCSSCodeType = BK4819_GetCDCSSCodeType();
} }
if (interrupt_status_bits & BK4819_REG_02_CDCSS_FOUND) if (interrupts.cdcssFound)
g_CDCSS_Lost = false; g_CDCSS_Lost = false;
if (interrupt_status_bits & BK4819_REG_02_CTCSS_LOST) if (interrupts.ctcssLost)
g_CTCSS_Lost = true; g_CTCSS_Lost = true;
if (interrupt_status_bits & BK4819_REG_02_CTCSS_FOUND) if (interrupts.ctcssFound)
g_CTCSS_Lost = false; g_CTCSS_Lost = false;
#ifdef ENABLE_VOX #ifdef ENABLE_VOX
if (interrupt_status_bits & BK4819_REG_02_VOX_LOST) if (interrupts.voxLost) {
{
g_VOX_Lost = true; g_VOX_Lost = true;
gVoxPauseCountdown = 10; gVoxPauseCountdown = 10;
if (gEeprom.VOX_SWITCH) if (gEeprom.VOX_SWITCH) {
{ if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode) {
if (gCurrentFunction == FUNCTION_POWER_SAVE && !gRxIdleMode)
{
gPowerSave_10ms = power_save2_10ms; gPowerSave_10ms = power_save2_10ms;
gPowerSaveCountdownExpired = 0; gPowerSaveCountdownExpired = 0;
} }
if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) if (gEeprom.DUAL_WATCH != DUAL_WATCH_OFF && (gScheduleDualWatch || gDualWatchCountdown_10ms < dual_watch_count_after_vox_10ms)) {
{
gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms; gDualWatchCountdown_10ms = dual_watch_count_after_vox_10ms;
gScheduleDualWatch = false; gScheduleDualWatch = false;
@@ -691,27 +697,24 @@ static void CheckRadioInterrupts(void)
} }
} }
if (interrupt_status_bits & BK4819_REG_02_VOX_FOUND) if (interrupts.voxFound) {
{
g_VOX_Lost = false; g_VOX_Lost = false;
gVoxPauseCountdown = 0; gVoxPauseCountdown = 0;
} }
#endif #endif
if (interrupt_status_bits & BK4819_REG_02_SQUELCH_LOST) if (interrupts.sqlLost) {
{
g_SquelchLost = true; g_SquelchLost = true;
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, true); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, true);
} }
if (interrupt_status_bits & BK4819_REG_02_SQUELCH_FOUND) if (interrupts.sqlFound) {
{
g_SquelchLost = false; g_SquelchLost = false;
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2_GREEN, false);
} }
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
if (interrupt_status_bits & BK4819_REG_02_FSK_FIFO_ALMOST_FULL && if (interrupts.fskFifoAlmostFull &&
gScreenToDisplay == DISPLAY_AIRCOPY && gScreenToDisplay == DISPLAY_AIRCOPY &&
gAircopyState == AIRCOPY_TRANSFER && gAircopyState == AIRCOPY_TRANSFER &&
gAirCopyIsSendMode == 0) gAirCopyIsSendMode == 0)