0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-06-19 06:39:49 +03:00

Fix RF scan problem + removed enums

This commit is contained in:
OneOfEleven
2023-10-25 08:47:00 +01:00
parent 9f3fa510c2
commit 5b5259c17d
13 changed files with 398 additions and 464 deletions

View File

@ -186,21 +186,21 @@ void AIRCOPY_start_fsk_tx(const int request_block_num)
(0u << 0); // 0 ~ 7 ???
// set the packet size
BK4819_WriteRegister(BK4819_REG_5D, (((tx_size * 2) - 1) << 8));
BK4819_WriteRegister(0x5D, (((tx_size * 2) - 1) << 8));
// clear TX fifo
BK4819_WriteRegister(BK4819_REG_59, (1u << 15) | fsk_reg59);
BK4819_WriteRegister(BK4819_REG_59, fsk_reg59);
BK4819_WriteRegister(0x59, (1u << 15) | fsk_reg59);
BK4819_WriteRegister(0x59, fsk_reg59);
// load the packet
for (k = 0; k < tx_size; k++)
BK4819_WriteRegister(BK4819_REG_5F, g_fsk_buffer[k]);
BK4819_WriteRegister(0x5F, g_fsk_buffer[k]);
// enable tx interrupt(s)
BK4819_WriteRegister(BK4819_REG_3F, BK4819_REG_3F_FSK_TX_FINISHED);
BK4819_WriteRegister(0x3F, BK4819_REG_3F_FSK_TX_FINISHED);
// enable scramble, enable TX
BK4819_WriteRegister(BK4819_REG_59, (1u << 13) | (1u << 11) | fsk_reg59);
BK4819_WriteRegister(0x59, (1u << 13) | (1u << 11) | fsk_reg59);
}
void AIRCOPY_stop_fsk_tx(void)
@ -268,10 +268,10 @@ void AIRCOPY_process_fsk_tx_10ms(void)
if (--g_fsk_tx_timeout_10ms > 0)
{ // still TX'ing
if ((BK4819_ReadRegister(BK4819_REG_0C) & (1u << 0)) == 0)
if ((BK4819_ReadRegister(0x0C) & (1u << 0)) == 0)
return;
BK4819_WriteRegister(BK4819_REG_02, 0);
interrupt_bits = BK4819_ReadRegister(BK4819_REG_02);
BK4819_WriteRegister(0x02, 0);
interrupt_bits = BK4819_ReadRegister(0x02);
if ((interrupt_bits & BK4819_REG_02_FSK_TX_FINISHED) == 0)
return; // TX not yet finished
}
@ -343,7 +343,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
//
// <2:0> 0 ???
//
status = BK4819_ReadRegister(BK4819_REG_59);
status = BK4819_ReadRegister(0x59);
if (status & (1u << 11) || g_fsk_tx_timeout_10ms > 0)
return; // FSK TX is busy
@ -355,13 +355,13 @@ void AIRCOPY_process_fsk_rx_10ms(void)
BK4819_start_fsk_rx((g_aircopy_state == AIRCOPY_TX) ? AIRCOPY_REQ_PACKET_SIZE : AIRCOPY_DATA_PACKET_SIZE);
}
status = BK4819_ReadRegister(BK4819_REG_0C);
status = BK4819_ReadRegister(0x0C);
if ((status & (1u << 0)) == 0)
return; // no flagged interrupts
// read the interrupt flags
BK4819_WriteRegister(BK4819_REG_02, 0); // clear them
interrupt_bits = BK4819_ReadRegister(BK4819_REG_02);
BK4819_WriteRegister(0x02, 0); // clear them
interrupt_bits = BK4819_ReadRegister(0x02);
if (interrupt_bits & BK4819_REG_02_FSK_RX_SYNC)
BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2_GREEN, true); // LED on
@ -377,7 +377,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
// fetch RX'ed data
for (i = 0; i < 4; i++)
{
const uint16_t word = BK4819_ReadRegister(BK4819_REG_5F);
const uint16_t word = BK4819_ReadRegister(0x5F);
if (g_fsk_write_index < ARRAY_SIZE(g_fsk_buffer))
g_fsk_buffer[g_fsk_write_index++] = word;
}
@ -400,7 +400,7 @@ void AIRCOPY_process_fsk_rx_10ms(void)
//
// <3:0> ???
//
status = BK4819_ReadRegister(BK4819_REG_0B);
status = BK4819_ReadRegister(0x0B);
// check to see if it's a REQ/ACK packet
if (g_fsk_write_index == req_ack_size)
@ -591,10 +591,10 @@ send_req:
while (g_fsk_tx_timeout_10ms-- > 0)
{
SYSTEM_DelayMs(5);
if (BK4819_ReadRegister(BK4819_REG_0C) & (1u << 0))
if (BK4819_ReadRegister(0x0C) & (1u << 0))
{ // we have interrupt flags
BK4819_WriteRegister(BK4819_REG_02, 0);
const uint16_t interrupt_bits = BK4819_ReadRegister(BK4819_REG_02);
BK4819_WriteRegister(0x02, 0);
const uint16_t interrupt_bits = BK4819_ReadRegister(0x02);
if (interrupt_bits & BK4819_REG_02_FSK_TX_FINISHED)
g_fsk_tx_timeout_10ms = 0; // TX is complete
}

View File

@ -247,7 +247,21 @@ static void APP_process_rx(void)
if (g_scan_state_dir != SCAN_STATE_DIR_OFF) // && IS_FREQ_CHANNEL(g_scan_next_channel))
{
if (g_squelch_open)
{
switch (g_eeprom.scan_resume_mode)
{
case SCAN_RESUME_TIME: // stay only for a limited time
break;
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
break;
case SCAN_RESUME_STOP: // stop scan once we find any signal
APP_stop_scan();
break;
}
return;
}
Mode = END_OF_RX_MODE_END;
goto Skip;
@ -284,7 +298,7 @@ static void APP_process_rx(void)
if (g_squelch_open)
{
if (g_setting_backlight_on_tx_rx >= 2)
backlight_turn_on(backlight_tx_rx_time_500ms);
backlight_turn_on(backlight_tx_rx_time_500ms); // keep the backlight on while we're receiving
if (!g_end_of_rx_detected_maybe && IS_NOT_NOAA_CHANNEL(g_rx_vfo->channel_save))
{
@ -404,11 +418,11 @@ Skip:
{
case SCAN_RESUME_TIME: // stay only for a limited time
break;
case SCAN_RESUME_CARRIER: // stay till the carrier goes away
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
break;
case SCAN_RESUME_SEARCH:
case SCAN_RESUME_STOP: // stop scan once we find any signal
APP_stop_scan();
break;
}
@ -498,7 +512,7 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
g_scan_pause_10ms = g_eeprom.scan_hold_time_500ms * 50;
g_scan_pause_time_mode = false;
break;
case SCAN_RESUME_SEARCH:
case SCAN_RESUME_STOP:
g_scan_pause_10ms = 0;
g_scan_pause_time_mode = false;
break;
@ -549,14 +563,14 @@ bool APP_start_listening(function_type_t Function, const bool reset_am_fix)
AM_fix_10ms(chan);
}
else
BK4819_WriteRegister(BK4819_REG_13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
BK4819_WriteRegister(0x13, (lna_short << 8) | (lna << 5) | (mixer << 3) | (pga << 0));
}
#else
(void)reset_am_fix;
#endif
// AF gain - original QS values
BK4819_WriteRegister(BK4819_REG_48,
BK4819_WriteRegister(0x48,
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
( 0u << 10) | // AF Rx Gain-1
(g_eeprom.volume_gain << 4) | // AF Rx Gain-2
@ -892,11 +906,11 @@ void APP_process_radio_interrupts(void)
if (g_screen_to_display == DISPLAY_SEARCH)
return;
while (BK4819_ReadRegister(BK4819_REG_0C) & (1u << 0))
while (BK4819_ReadRegister(0x0C) & (1u << 0))
{ // BK chip interrupt request
BK4819_WriteRegister(BK4819_REG_02, 0);
const uint16_t interrupt_bits = BK4819_ReadRegister(BK4819_REG_02);
BK4819_WriteRegister(0x02, 0);
const uint16_t interrupt_bits = BK4819_ReadRegister(0x02);
if (interrupt_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
{ // save the RX'ed DTMF character

View File

@ -384,9 +384,9 @@ static void cmd_0527(void)
memset(&reply, 0, sizeof(reply));
reply.Header.ID = 0x0528;
reply.Header.Size = sizeof(reply.Data);
reply.Data.RSSI = BK4819_ReadRegister(BK4819_REG_67) & 0x01FF;
reply.Data.ExNoiseIndicator = BK4819_ReadRegister(BK4819_REG_65) & 0x007F;
reply.Data.GlitchIndicator = BK4819_ReadRegister(BK4819_REG_63);
reply.Data.RSSI = BK4819_ReadRegister(0x67) & 0x01FF;
reply.Data.ExNoiseIndicator = BK4819_ReadRegister(0x65) & 0x007F;
reply.Data.GlitchIndicator = BK4819_ReadRegister(0x63);
SendReply(&reply, sizeof(reply));
}