mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-27 22:01:26 +03:00
ctcss phase stuff + fast manual freq up/dn scanning update
This commit is contained in:
parent
2522b4184a
commit
010ee10516
4
Makefile
4
Makefile
@ -36,6 +36,7 @@ ENABLE_ALARM := 0
|
||||
ENABLE_TX1750 := 0
|
||||
# MDC1200 2.8 kB
|
||||
ENABLE_MDC1200 := 1
|
||||
ENABLE_MDC1200_SHOW_OP_ARG := 1
|
||||
ENABLE_PWRON_PASSWORD := 0
|
||||
ENABLE_RESET_AES_KEY := 1
|
||||
ENABLE_BIG_FREQ := 0
|
||||
@ -360,6 +361,9 @@ endif
|
||||
ifeq ($(ENABLE_MDC1200),1)
|
||||
CFLAGS += -DENABLE_MDC1200
|
||||
endif
|
||||
ifeq ($(ENABLE_MDC1200_SHOW_OP_ARG),1)
|
||||
CFLAGS += -DENABLE_MDC1200_SHOW_OP_ARG
|
||||
endif
|
||||
ifeq ($(ENABLE_PWRON_PASSWORD),1)
|
||||
CFLAGS += -DENABLE_PWRON_PASSWORD
|
||||
endif
|
||||
|
@ -57,6 +57,8 @@ ENABLE_VOX := 0 voice operated transmission
|
||||
ENABLE_REDUCE_LOW_MID_TX_POWER := 1 reduce the low and mid TX power levels (high remains unchanged)
|
||||
ENABLE_ALARM := 0 TX alarms
|
||||
ENABLE_1750HZ := 0 side key 1750Hz TX tone (older style repeater access)
|
||||
ENABLE_MDC1200 := 0 enable MDC1200 TX/RX + menu TX option
|
||||
ENABLE_MDC1200_SHOW_OP_ARG := 1 show RX opcode and argument values when MDC1200 is RX'ed
|
||||
ENABLE_PWRON_PASSWORD := 0 include power-on password code
|
||||
ENABLE_RESET_AES_KEY := 1 '1' = reset/clear the AES key stored in the eeprom (only if it's set)
|
||||
ENABLE_BIG_FREQ := 0 big font frequencies (like original QS firmware)
|
||||
|
279
app/app.c
279
app/app.c
@ -92,8 +92,7 @@ static void APP_update_rssi(const int vfo)
|
||||
|
||||
g_current_rssi[vfo] = rssi;
|
||||
|
||||
// if (g_squelch_open || g_monitor_enabled)
|
||||
UI_update_rssi(rssi, vfo);
|
||||
UI_update_rssi(rssi, vfo);
|
||||
}
|
||||
|
||||
static void APP_check_for_new_receive(void)
|
||||
@ -109,7 +108,7 @@ static void APP_check_for_new_receive(void)
|
||||
if (g_css_scan_mode != CSS_SCAN_MODE_OFF && g_rx_reception_mode == RX_MODE_NONE)
|
||||
{ // CTCSS/DTS scanning
|
||||
|
||||
g_scan_pause_tick_10ms = scan_pause_code_10ms;
|
||||
g_scan_pause_tick_10ms = scan_pause_code_10ms;
|
||||
g_scan_pause_time_mode = false;
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
}
|
||||
@ -121,7 +120,7 @@ static void APP_check_for_new_receive(void)
|
||||
if (g_is_noaa_mode)
|
||||
{
|
||||
g_noaa_tick_10ms = noaa_tick_3_10ms;
|
||||
g_schedule_noaa = false;
|
||||
g_schedule_noaa = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -150,7 +149,7 @@ static void APP_check_for_new_receive(void)
|
||||
g_rx_reception_mode = RX_MODE_DETECTED;
|
||||
|
||||
done:
|
||||
// if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
if (g_current_function != FUNCTION_NEW_RECEIVE)
|
||||
{
|
||||
FUNCTION_Select(FUNCTION_NEW_RECEIVE);
|
||||
|
||||
@ -162,11 +161,10 @@ done:
|
||||
//BK4819_WriteRegister(0x59, (1u << 12) | fsk_reg59);
|
||||
}
|
||||
#endif
|
||||
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
|
||||
g_update_rssi = true;
|
||||
}
|
||||
APP_update_rssi(g_eeprom.rx_vfo);
|
||||
g_update_rssi = true;
|
||||
// }
|
||||
}
|
||||
|
||||
static void APP_process_new_receive(void)
|
||||
@ -194,14 +192,14 @@ static void APP_process_new_receive(void)
|
||||
if (IS_NOAA_CHANNEL(g_rx_vfo->channel_save) && g_noaa_tick_10ms > 0)
|
||||
{
|
||||
g_noaa_tick_10ms = 0;
|
||||
flag = true;
|
||||
flag = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (g_ctcss_lost && g_current_code_type == CODE_TYPE_CONTINUOUS_TONE)
|
||||
{
|
||||
flag = true;
|
||||
g_found_ctcss = false;
|
||||
flag = true;
|
||||
}
|
||||
|
||||
if (g_cdcss_lost && g_cdcss_code_type == CDCSS_POSITIVE_CODE && (g_current_code_type == CODE_TYPE_DIGITAL || g_current_code_type == CODE_TYPE_REVERSE_DIGITAL))
|
||||
@ -229,7 +227,7 @@ static void APP_process_new_receive(void)
|
||||
if (g_rx_reception_mode == RX_MODE_DETECTED)
|
||||
{
|
||||
g_dual_watch_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
g_rx_reception_mode = RX_MODE_LISTENING;
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
@ -269,7 +267,7 @@ static void APP_process_rx(void)
|
||||
case SCAN_RESUME_TIME: // stay only for a limited time
|
||||
break;
|
||||
case SCAN_RESUME_CARRIER: // stay untill the carrier goes away
|
||||
g_scan_pause_tick_10ms = g_eeprom.scan_hold_time_500ms * 50;
|
||||
g_scan_pause_tick_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
|
||||
@ -321,11 +319,11 @@ static void APP_process_rx(void)
|
||||
switch (g_current_code_type)
|
||||
{
|
||||
case CODE_TYPE_NONE:
|
||||
if (g_eeprom.squelch_level)
|
||||
if (g_eeprom.squelch_level > 0)
|
||||
{
|
||||
if (g_cxcss_tail_found)
|
||||
{
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
g_cxcss_tail_found = false;
|
||||
}
|
||||
}
|
||||
@ -339,13 +337,13 @@ static void APP_process_rx(void)
|
||||
else
|
||||
if (!g_found_ctcss)
|
||||
{
|
||||
g_found_ctcss = true;
|
||||
g_found_ctcss = true;
|
||||
g_found_ctcss_tick_10ms = 100; // 1 sec
|
||||
}
|
||||
|
||||
if (g_cxcss_tail_found)
|
||||
{
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
Mode = END_OF_RX_MODE_TTE;
|
||||
g_cxcss_tail_found = false;
|
||||
}
|
||||
break;
|
||||
@ -359,7 +357,7 @@ static void APP_process_rx(void)
|
||||
else
|
||||
if (!g_found_cdcss)
|
||||
{
|
||||
g_found_cdcss = true;
|
||||
g_found_cdcss = true;
|
||||
g_found_cdcss_tick_10ms = 100; // 1 sec
|
||||
}
|
||||
|
||||
@ -412,10 +410,9 @@ Skip:
|
||||
break;
|
||||
|
||||
case END_OF_RX_MODE_TTE:
|
||||
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
{
|
||||
if (!g_squelch_open && !g_monitor_enabled)
|
||||
if (!g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
|
||||
g_tail_tone_elimination_tick_10ms = 20; // 200ms
|
||||
@ -470,6 +467,11 @@ bool APP_start_listening(void)
|
||||
if (g_scan_state_dir != SCAN_STATE_DIR_OFF)
|
||||
{ // we're RF scanning
|
||||
|
||||
g_rx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_scan_next_channel))
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
switch (g_eeprom.scan_resume_mode)
|
||||
{
|
||||
case SCAN_RESUME_TIME:
|
||||
@ -629,6 +631,9 @@ void APP_stop_scan(void)
|
||||
|
||||
g_rx_vfo->freq_config_rx.frequency = g_scan_restore_frequency;
|
||||
|
||||
// find the first channel that contains this frequency
|
||||
g_rx_vfo->freq_in_channel = BOARD_find_channel(g_rx_vfo->freq_config_rx.frequency);
|
||||
|
||||
RADIO_ApplyOffset(g_rx_vfo, false);
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
RADIO_setup_registers(true);
|
||||
@ -670,6 +675,8 @@ static void APP_next_freq(void)
|
||||
|
||||
g_rx_vfo->freq_config_rx.frequency = frequency;
|
||||
|
||||
g_rx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("APP_next_freq %u %u\r\n", frequency, new_band);
|
||||
#endif
|
||||
@ -864,81 +871,111 @@ void APP_process_radio_interrupts(void)
|
||||
if (g_current_display_screen == DISPLAY_SEARCH)
|
||||
return;
|
||||
|
||||
while (BK4819_ReadRegister(0x0C) & (1u << 0))
|
||||
{ // BK chip interrupt request
|
||||
while (1)
|
||||
{ // BK4819 chip interrupt request
|
||||
|
||||
uint16_t interrupt_bits;
|
||||
uint16_t int_bits;
|
||||
|
||||
const uint16_t reg_c = BK4819_ReadRegister(0x0C);
|
||||
if ((reg_c & 1u) == 0)
|
||||
break;
|
||||
|
||||
BK4819_WriteRegister(0x02, 0);
|
||||
interrupt_bits = BK4819_ReadRegister(0x02);
|
||||
int_bits = BK4819_ReadRegister(0x02);
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("reg_c int_bits %04X\r\n", reg_c, int_bits);
|
||||
#endif
|
||||
|
||||
if (int_bits & BK4819_REG_02_DTMF_5TONE_FOUND)
|
||||
{ // save the RX'ed DTMF character
|
||||
const char c = DTMF_GetCharacter(BK4819_GetDTMF_5TONE_Code());
|
||||
if (c != 0xff)
|
||||
if (c != 0xff && g_current_function != FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (g_current_function != FUNCTION_TRANSMIT)
|
||||
if (g_setting_live_dtmf_decoder)
|
||||
{
|
||||
if (g_setting_live_dtmf_decoder)
|
||||
{
|
||||
size_t len = strlen(g_dtmf_rx_live);
|
||||
if (len >= (sizeof(g_dtmf_rx_live) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1);
|
||||
len--;
|
||||
}
|
||||
g_dtmf_rx_live[len++] = c;
|
||||
g_dtmf_rx_live[len] = 0;
|
||||
g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it
|
||||
g_update_display = true;
|
||||
size_t len = strlen(g_dtmf_rx_live);
|
||||
if (len >= (sizeof(g_dtmf_rx_live) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx_live[0], &g_dtmf_rx_live[1], sizeof(g_dtmf_rx_live) - 1);
|
||||
len--;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
{
|
||||
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
|
||||
g_dtmf_rx_index--;
|
||||
}
|
||||
g_dtmf_rx[g_dtmf_rx_index++] = c;
|
||||
g_dtmf_rx[g_dtmf_rx_index] = 0;
|
||||
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
|
||||
g_dtmf_rx_pending = true;
|
||||
|
||||
DTMF_HandleRequest();
|
||||
g_dtmf_rx_live[len++] = c;
|
||||
g_dtmf_rx_live[len] = 0;
|
||||
g_dtmf_rx_live_timeout = dtmf_rx_live_timeout_500ms; // time till we delete it
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (g_rx_vfo->dtmf_decoding_enable || g_setting_radio_disabled)
|
||||
#else
|
||||
if (g_rx_vfo->dtmf_decoding_enable)
|
||||
#endif
|
||||
{
|
||||
if (g_dtmf_rx_index >= (sizeof(g_dtmf_rx) - 1))
|
||||
{ // make room
|
||||
memmove(&g_dtmf_rx[0], &g_dtmf_rx[1], sizeof(g_dtmf_rx) - 1);
|
||||
g_dtmf_rx_index--;
|
||||
}
|
||||
g_dtmf_rx[g_dtmf_rx_index++] = c;
|
||||
g_dtmf_rx[g_dtmf_rx_index] = 0;
|
||||
g_dtmf_rx_timeout = dtmf_rx_timeout_500ms; // time till we delete it
|
||||
g_dtmf_rx_pending = true;
|
||||
|
||||
DTMF_HandleRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CxCSS_TAIL)
|
||||
g_cxcss_tail_found = true;
|
||||
if (int_bits & BK4819_REG_02_CxCSS_TAIL)
|
||||
{
|
||||
g_cxcss_tail_found = true;
|
||||
g_ctcss_tail_phase_shift_rx = (reg_c >> 12) & 3u;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CDCSS_LOST)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("cxcss tail %u\r\n", g_ctcss_tail_phase_shift_rx);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CDCSS_LOST)
|
||||
{
|
||||
g_cdcss_lost = true;
|
||||
g_cdcss_code_type = BK4819_get_CDCSS_code_type();
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_printf("cdcss lost %u\r\n", g_cdcss_code_type);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CDCSS_FOUND)
|
||||
if (int_bits & BK4819_REG_02_CDCSS_FOUND)
|
||||
{
|
||||
g_cdcss_lost = false;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CTCSS_LOST)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("cdcss found\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CTCSS_LOST)
|
||||
{
|
||||
g_ctcss_lost = true;
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_CTCSS_FOUND)
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("cdcss lost\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (int_bits & BK4819_REG_02_CTCSS_FOUND)
|
||||
{
|
||||
g_ctcss_lost = false;
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
MDC1200_process_rx(interrupt_bits);
|
||||
#endif
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
UART_SendText("ctcss found\r\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
if (interrupt_bits & BK4819_REG_02_VOX_LOST)
|
||||
if (int_bits & BK4819_REG_02_VOX_LOST)
|
||||
{
|
||||
g_vox_lost = true;
|
||||
g_vox_pause_tick_10ms = 10;
|
||||
@ -960,14 +997,14 @@ void APP_process_radio_interrupts(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_VOX_FOUND)
|
||||
if (int_bits & BK4819_REG_02_VOX_FOUND)
|
||||
{
|
||||
g_vox_lost = false;
|
||||
g_vox_pause_tick_10ms = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_SQUELCH_CLOSED)
|
||||
if (int_bits & BK4819_REG_02_SQUELCH_CLOSED)
|
||||
{
|
||||
g_squelch_open = false;
|
||||
|
||||
@ -986,7 +1023,7 @@ void APP_process_radio_interrupts(void)
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
if (interrupt_bits & BK4819_REG_02_SQUELCH_OPENED)
|
||||
if (int_bits & BK4819_REG_02_SQUELCH_OPENED)
|
||||
{
|
||||
g_squelch_open = true;
|
||||
|
||||
@ -1002,6 +1039,10 @@ void APP_process_radio_interrupts(void)
|
||||
|
||||
g_update_display = true;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_MDC1200
|
||||
MDC1200_process_rx(int_bits);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -1016,13 +1057,13 @@ void APP_end_tx(void)
|
||||
//if (g_eeprom.tail_note_elimination && g_eeprom.repeater_tail_tone_elimination > 0)
|
||||
if (g_eeprom.tail_note_elimination)
|
||||
{ // send the CTCSS/DCS tail tone - allows the receivers to mute the usual FM squelch tail/crash
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
}
|
||||
#if 1
|
||||
else
|
||||
{ // TX a short blank carrier after disabling the CTCSS/CDCSS
|
||||
// this gives the receivers time to mute their RX audio before we drop carrier
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
SYSTEM_DelayMs(200);
|
||||
}
|
||||
#endif
|
||||
@ -1031,10 +1072,7 @@ void APP_end_tx(void)
|
||||
RADIO_setup_registers(false);
|
||||
|
||||
if (g_monitor_enabled)
|
||||
APP_start_listening();
|
||||
|
||||
if (g_squelch_open || g_monitor_enabled)
|
||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
@ -1089,16 +1127,14 @@ void APP_end_tx(void)
|
||||
APP_end_tx();
|
||||
|
||||
if (g_eeprom.repeater_tail_tone_elimination == 0)
|
||||
{
|
||||
//if (g_current_function != FUNCTION_FOREGROUND)
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
}
|
||||
FUNCTION_Select(FUNCTION_FOREGROUND);
|
||||
else
|
||||
g_rtte_count_down = g_eeprom.repeater_tail_tone_elimination * 10;
|
||||
}
|
||||
|
||||
g_update_status = true;
|
||||
g_update_display = true;
|
||||
|
||||
g_flag_end_tx = false;
|
||||
}
|
||||
return;
|
||||
@ -1124,7 +1160,7 @@ void APP_end_tx(void)
|
||||
// called every 10ms
|
||||
void APP_check_keys(void)
|
||||
{
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT) && (g_serial_config_tick_500ms == 0) && g_setting_tx_enable;
|
||||
const bool ptt_pressed = !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT);
|
||||
|
||||
key_code_t key;
|
||||
|
||||
@ -1138,43 +1174,48 @@ void APP_check_keys(void)
|
||||
|
||||
if (ptt_pressed)
|
||||
{ // PTT pressed
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_setting_radio_disabled)
|
||||
#endif
|
||||
|
||||
if (!g_ptt_is_pressed && g_serial_config_tick_500ms == 0 && g_setting_tx_enable)
|
||||
{
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
#else
|
||||
if (!g_ptt_is_pressed)
|
||||
#endif
|
||||
#ifdef ENABLE_KILL_REVIVE
|
||||
if (!g_setting_radio_disabled)
|
||||
#endif
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
{ // start TX'ing
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = true;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_process_key(KEY_PTT, true, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
#ifdef ENABLE_AIRCOPY
|
||||
if (!g_ptt_is_pressed && g_current_display_screen != DISPLAY_AIRCOPY)
|
||||
#else
|
||||
if (!g_ptt_is_pressed)
|
||||
#endif
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms debounce
|
||||
{ // start TX'ing
|
||||
|
||||
g_boot_tick_10ms = 0; // cancel the boot-up screen
|
||||
g_ptt_is_pressed = ptt_pressed;
|
||||
g_ptt_was_released = false;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
APP_process_key(KEY_PTT, true, false);
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf(" ptt key %3u %u %u\r\n", KEY_PTT, g_ptt_is_pressed, g_ptt_was_released);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
else
|
||||
g_ptt_debounce = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // PTT released
|
||||
if (g_ptt_is_pressed)
|
||||
|
||||
if (g_ptt_is_pressed && g_current_function == FUNCTION_TRANSMIT)
|
||||
{
|
||||
if (++g_ptt_debounce >= 3) // 30ms
|
||||
if (++g_ptt_debounce >= 3 || g_serial_config_tick_500ms > 0 || !g_setting_tx_enable) // 30ms debounce
|
||||
{ // stop TX'ing
|
||||
|
||||
g_ptt_is_pressed = false;
|
||||
// g_ptt_is_pressed = false;
|
||||
g_ptt_was_released = true;
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
@ -1186,7 +1227,12 @@ void APP_check_keys(void)
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_ptt_debounce = 0;
|
||||
|
||||
if (g_ptt_is_pressed && !ptt_pressed)
|
||||
g_ptt_is_pressed = false;
|
||||
}
|
||||
}
|
||||
|
||||
// *****************
|
||||
@ -1293,17 +1339,19 @@ void APP_check_keys(void)
|
||||
#else
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
#endif
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
if (key == KEY_UP || key == KEY_DOWN)
|
||||
{ // only the up and down keys are repeatable
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + key_repeat_10ms))
|
||||
|
||||
// go much faster if the user is moving up/down freq/channel
|
||||
const uint8_t repeat_10ms = (g_manual_scanning && g_monitor_enabled && g_current_display_screen == DISPLAY_MAIN) ? 1 : key_repeat_10ms;
|
||||
|
||||
if (++g_key_debounce_repeat >= (key_long_press_10ms + repeat_10ms))
|
||||
{ // key repeat
|
||||
g_key_debounce_repeat -= key_repeat_10ms;
|
||||
|
||||
g_key_debounce_repeat = key_long_press_10ms;
|
||||
|
||||
#if defined(ENABLE_UART) && defined(ENABLE_UART_DEBUG)
|
||||
// UART_printf("rept key %3u %3u, %3u %3u, %u\r\n", key, g_key_prev, g_key_debounce_press, g_key_debounce_repeat, g_key_held);
|
||||
@ -1317,9 +1365,6 @@ void APP_check_keys(void)
|
||||
#else
|
||||
APP_process_key(g_key_prev, true, g_key_held);
|
||||
#endif
|
||||
|
||||
//g_update_status = true;
|
||||
//g_update_display = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1373,7 +1418,7 @@ void APP_cancel_user_input_modes(void)
|
||||
if (g_eeprom.alarm_mode == ALARM_MODE_TONE)
|
||||
{
|
||||
RADIO_tx_eot();
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
@ -1652,7 +1697,7 @@ void APP_process_transmit(void)
|
||||
{
|
||||
g_alarm_state = ALARM_STATE_ALARM;
|
||||
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
BK4819_SetupPowerAmplifier(0, 0);
|
||||
BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_PA_ENABLE, false); // PA off
|
||||
BK4819_Enable_AfDac_DiscMode_TxDsp();
|
||||
|
40
app/main.c
40
app/main.c
@ -43,6 +43,8 @@
|
||||
#include "ui/menu.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
bool g_manual_scanning;
|
||||
|
||||
bool scanning_paused(void)
|
||||
{
|
||||
if ((g_scan_state_dir != SCAN_STATE_DIR_OFF || g_eeprom.dual_watch != DUAL_WATCH_OFF) &&
|
||||
@ -862,15 +864,15 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
if (key_pressed && !key_held)
|
||||
{ // key just pressed
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_beep_to_play = BEEP_1KHZ_60MS_OPTIONAL;
|
||||
g_manual_scanning = false;
|
||||
}
|
||||
|
||||
if (!key_pressed)
|
||||
{
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF &&
|
||||
(Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
|
||||
{ // key released
|
||||
{ // key released
|
||||
|
||||
if (g_scan_state_dir == SCAN_STATE_DIR_OFF && (Channel <= USER_CHANNEL_LAST || IS_FREQ_CHANNEL(Channel)))
|
||||
{
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (key_held && !monitor_was_enabled)
|
||||
{ // re-enable the squelch
|
||||
@ -894,6 +896,8 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
// UART_printf("save chan %u\r\n", g_tx_vfo->channel_save);
|
||||
#endif
|
||||
}
|
||||
|
||||
g_manual_scanning = false;
|
||||
}
|
||||
|
||||
if (key_held || !key_pressed)
|
||||
@ -985,6 +989,7 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_manual_scanning = true;
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
@ -1002,18 +1007,6 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
|
||||
g_tx_vfo->freq_in_channel = 0xff;
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (!key_held && key_pressed)
|
||||
monitor_was_enabled = g_monitor_enabled;
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
Next = RADIO_FindNextChannel(Channel + Direction, Direction, false, 0);
|
||||
if (Next == 0xFF)
|
||||
return;
|
||||
@ -1021,6 +1014,19 @@ void MAIN_Key_UP_DOWN(bool key_pressed, bool key_held, scan_state_dir_t Directio
|
||||
if (Channel == Next)
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_SQ_OPEN_WITH_UP_DN_BUTTS
|
||||
if (!key_held && key_pressed)
|
||||
monitor_was_enabled = g_monitor_enabled;
|
||||
|
||||
if (key_held && key_pressed && !monitor_was_enabled)
|
||||
{ // open the squelch if the user holds the key down
|
||||
g_manual_scanning = true;
|
||||
g_monitor_enabled = true;
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||
// APP_start_listening();
|
||||
}
|
||||
#endif
|
||||
|
||||
g_eeprom.user_channel[g_eeprom.tx_vfo] = Next;
|
||||
g_eeprom.screen_channel[g_eeprom.tx_vfo] = Next;
|
||||
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "driver/keyboard.h"
|
||||
|
||||
extern bool g_manual_scanning;
|
||||
|
||||
void MAIN_process_key(key_code_t Key, bool bKeyPressed, bool bKeyHeld);
|
||||
|
||||
#endif
|
||||
|
12
app/menu.c
12
app/menu.c
@ -177,13 +177,13 @@ int MENU_GetLimits(uint8_t Cursor, int32_t *pMin, int32_t *pMax)
|
||||
case MENU_TX_CDCSS:
|
||||
*pMin = 0;
|
||||
*pMax = 208;
|
||||
//*pMax = (ARRAY_SIZE(DCS_OPTIONS) * 2);
|
||||
//*pMax = (ARRAY_SIZE(DCS_CODE_LIST) * 2);
|
||||
break;
|
||||
|
||||
case MENU_RX_CTCSS:
|
||||
case MENU_TX_CTCSS:
|
||||
*pMin = 0;
|
||||
*pMax = ARRAY_SIZE(CTCSS_OPTIONS) - 1;
|
||||
*pMax = ARRAY_SIZE(CTCSS_TONE_LIST) - 1;
|
||||
break;
|
||||
|
||||
case MENU_BANDWIDTH:
|
||||
@ -477,7 +477,7 @@ void MENU_AcceptSetting(void)
|
||||
pConfig->code = Code;
|
||||
pConfig->code_type = CODE_TYPE_NONE;
|
||||
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -485,7 +485,7 @@ void MENU_AcceptSetting(void)
|
||||
Code = g_sub_menu_selection - 1;
|
||||
pConfig->code = Code;
|
||||
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]);
|
||||
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[Code]);
|
||||
}
|
||||
|
||||
g_request_save_channel = 1;
|
||||
@ -910,10 +910,10 @@ void MENU_SelectNextCode(void)
|
||||
|
||||
if (g_menu_cursor == MENU_RX_CDCSS)
|
||||
UpperLimit = 208;
|
||||
//UpperLimit = ARRAY_SIZE(DCS_OPTIONS);
|
||||
//UpperLimit = ARRAY_SIZE(DCS_CODE_LIST);
|
||||
else
|
||||
if (g_menu_cursor == MENU_RX_CTCSS)
|
||||
UpperLimit = ARRAY_SIZE(CTCSS_OPTIONS) - 1;
|
||||
UpperLimit = ARRAY_SIZE(CTCSS_TONE_LIST) - 1;
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -450,7 +450,7 @@ void SEARCH_process(void)
|
||||
//
|
||||
// RF carrier found, move on to CTCSS/CDCSS search
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
|
||||
g_search_css_result_type = CODE_TYPE_NONE;
|
||||
g_search_css_result_code = 0xff;
|
||||
@ -576,7 +576,7 @@ void SEARCH_process(void)
|
||||
if (g_search_css_state == SEARCH_CSS_STATE_OFF || g_search_css_state == SEARCH_CSS_STATE_SCANNING)
|
||||
{ // re-start scan
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
g_search_tick_10ms = search_10ms;
|
||||
}
|
||||
|
||||
@ -630,7 +630,7 @@ void SEARCH_Start(void)
|
||||
|
||||
BK4819_set_rf_filter_path(g_search_frequency);
|
||||
|
||||
BK4819_SetScanFrequency(g_search_frequency);
|
||||
BK4819_set_scan_frequency(g_search_frequency);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
18
dcs.c
18
dcs.c
@ -21,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
// CTCSS Hz * 10
|
||||
const uint16_t CTCSS_OPTIONS[50] = {
|
||||
const uint16_t CTCSS_TONE_LIST[50] = {
|
||||
670, 693, 719, 744, 770, 797, 825, 854, 885, 915,
|
||||
948, 974, 1000, 1035, 1072, 1109, 1148, 1188, 1230, 1273,
|
||||
1318, 1365, 1413, 1462, 1514, 1567, 1598, 1622, 1655, 1679,
|
||||
@ -29,7 +29,7 @@ const uint16_t CTCSS_OPTIONS[50] = {
|
||||
2035, 2065, 2107, 2181, 2257, 2291, 2336, 2418, 2503, 2541
|
||||
};
|
||||
|
||||
const uint16_t DCS_OPTIONS[104] = {
|
||||
const uint16_t DCS_CODE_LIST[104] = {
|
||||
0x0013, 0x0015, 0x0016, 0x0019, 0x001A, 0x001E, 0x0023, 0x0027,
|
||||
0x0029, 0x002B, 0x002C, 0x0035, 0x0039, 0x003A, 0x003B, 0x003C,
|
||||
0x004C, 0x004D, 0x004E, 0x0052, 0x0055, 0x0059, 0x005A, 0x005C,
|
||||
@ -60,7 +60,7 @@ static uint32_t DCS_CalculateGolay(uint32_t CodeWord)
|
||||
|
||||
uint32_t DCS_GetGolayCodeWord(dcs_code_type_t code_type, uint8_t Option)
|
||||
{
|
||||
uint32_t code = DCS_CalculateGolay(DCS_OPTIONS[Option] + 0x800U);
|
||||
uint32_t code = DCS_CalculateGolay(DCS_CODE_LIST[Option] + 0x800U);
|
||||
if (code_type == CODE_TYPE_REVERSE_DIGITAL)
|
||||
code ^= 0x7FFFFF;
|
||||
return code;
|
||||
@ -76,8 +76,8 @@ uint8_t DCS_GetCdcssCode(uint32_t Code)
|
||||
if (((Code >> 9) & 0x7U) == 4)
|
||||
{
|
||||
unsigned int j;
|
||||
for (j = 0; j < ARRAY_SIZE(DCS_OPTIONS); j++)
|
||||
if (DCS_OPTIONS[j] == (Code & 0x1FF))
|
||||
for (j = 0; j < ARRAY_SIZE(DCS_CODE_LIST); j++)
|
||||
if (DCS_CODE_LIST[j] == (Code & 0x1FF))
|
||||
if (DCS_GetGolayCodeWord(2, j) == Code)
|
||||
return j;
|
||||
}
|
||||
@ -95,13 +95,13 @@ uint8_t DCS_GetCtcssCode(int Code)
|
||||
{
|
||||
unsigned int i;
|
||||
uint8_t Result = 0xFF;
|
||||
int Smallest = ARRAY_SIZE(CTCSS_OPTIONS);
|
||||
int Smallest = ARRAY_SIZE(CTCSS_TONE_LIST);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(CTCSS_OPTIONS); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(CTCSS_TONE_LIST); i++)
|
||||
{
|
||||
int Delta = Code - CTCSS_OPTIONS[i];
|
||||
int Delta = Code - CTCSS_TONE_LIST[i];
|
||||
if (Delta < 0)
|
||||
Delta = -(Code - CTCSS_OPTIONS[i]);
|
||||
Delta = -(Code - CTCSS_TONE_LIST[i]);
|
||||
if (Smallest > Delta)
|
||||
{
|
||||
Smallest = Delta;
|
||||
|
4
dcs.h
4
dcs.h
@ -34,8 +34,8 @@ enum {
|
||||
CDCSS_NEGATIVE_CODE = 2U,
|
||||
};
|
||||
|
||||
extern const uint16_t CTCSS_OPTIONS[50];
|
||||
extern const uint16_t DCS_OPTIONS[104];
|
||||
extern const uint16_t CTCSS_TONE_LIST[50];
|
||||
extern const uint16_t DCS_CODE_LIST[104];
|
||||
|
||||
uint32_t DCS_GetGolayCodeWord(dcs_code_type_t code_type, uint8_t Option);
|
||||
uint8_t DCS_GetCdcssCode(uint32_t Code);
|
||||
|
559
driver/bk4819.c
559
driver/bk4819.c
@ -51,8 +51,9 @@ void BK4819_Init(void)
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SCL);
|
||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_BK4819_SDA);
|
||||
|
||||
BK4819_WriteRegister(0x00, 0x8000);
|
||||
BK4819_WriteRegister(0x00, 0x0000);
|
||||
// reset the chip
|
||||
BK4819_WriteRegister(0x00, (1u << 15));
|
||||
BK4819_WriteRegister(0x00, 0);
|
||||
|
||||
BK4819_WriteRegister(0x37, 0x1D0F);
|
||||
BK4819_WriteRegister(0x36, 0x0022);
|
||||
@ -92,7 +93,7 @@ void BK4819_Init(void)
|
||||
(58u << 4) | // AF Rx Gain-2
|
||||
( 8u << 0)); // AF DAC Gain (after Gain-1 and Gain-2)
|
||||
|
||||
BK4819_sub_audible();
|
||||
BK4819_config_sub_audible();
|
||||
|
||||
#if 1
|
||||
const uint8_t dtmf_coeffs[] = {111, 107, 103, 98, 80, 71, 58, 44, 65, 55, 37, 23, 228, 203, 181, 159};
|
||||
@ -395,172 +396,6 @@ void BK4819_set_GPIO_pin(bk4819_gpio_pin_t Pin, bool bSet)
|
||||
BK4819_WriteRegister(0x33, gBK4819_GpioOutState);
|
||||
}
|
||||
|
||||
void BK4819_SetCDCSSCodeWord(uint32_t CodeWord)
|
||||
{
|
||||
// REG_51
|
||||
//
|
||||
// <15> 0
|
||||
// 1 = Enable TxCTCSS/CDCSS
|
||||
// 0 = Disable
|
||||
//
|
||||
// <14> 0
|
||||
// 1 = GPIO0Input for CDCSS
|
||||
// 0 = Normal Mode (for BK4819 v3)
|
||||
//
|
||||
// <13> 0
|
||||
// 1 = Transmit negative CDCSS code
|
||||
// 0 = Transmit positive CDCSS code
|
||||
//
|
||||
// <12> 0 CTCSS/CDCSS mode selection
|
||||
// 1 = CTCSS
|
||||
// 0 = CDCSS
|
||||
//
|
||||
// <11> 0 CDCSS 24/23bit selection
|
||||
// 1 = 24bit
|
||||
// 0 = 23bit
|
||||
//
|
||||
// <10> 0 1050HzDetectionMode
|
||||
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
|
||||
//
|
||||
// <9> 0 Auto CDCSS Bw Mode
|
||||
// 1 = Disable
|
||||
// 0 = Enable
|
||||
//
|
||||
// <8> 0 Auto CTCSS Bw Mode
|
||||
// 0 = Enable
|
||||
// 1 = Disable
|
||||
//
|
||||
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
|
||||
// 0 = min
|
||||
// 127 = max
|
||||
|
||||
// Enable CDCSS
|
||||
// Transmit positive CDCSS code
|
||||
// CDCSS Mode
|
||||
// CDCSS 23bit
|
||||
// Enable Auto CDCSS Bw Mode
|
||||
// Enable Auto CTCSS Bw Mode
|
||||
// CTCSS/CDCSS Tx Gain1 Tuning = 51
|
||||
//
|
||||
BK4819_WriteRegister(0x51,
|
||||
BK4819_REG_51_ENABLE_CxCSS |
|
||||
BK4819_REG_51_GPIO6_PIN2_NORMAL |
|
||||
BK4819_REG_51_TX_CDCSS_POSITIVE |
|
||||
BK4819_REG_51_MODE_CDCSS |
|
||||
BK4819_REG_51_CDCSS_23_BIT |
|
||||
BK4819_REG_51_1050HZ_NO_DETECTION |
|
||||
BK4819_REG_51_AUTO_CDCSS_BW_ENABLE |
|
||||
BK4819_REG_51_AUTO_CTCSS_BW_ENABLE |
|
||||
(51u << BK4819_REG_51_SHIFT_CxCSS_TX_GAIN1));
|
||||
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// When <13> = 0 for CTC1
|
||||
// <12:0> = CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 1 for CTC2 (Tail 55Hz Rx detection)
|
||||
// <12:0> = CTC2 (should below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 2 for CDCSS 134.4Hz
|
||||
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
BK4819_WriteRegister(0x07, BK4819_REG_07_MODE_CTC1 | 2775u);
|
||||
|
||||
// REG_08 <15:0> <15> = 1 for CDCSS high 12bit
|
||||
// <15> = 0 for CDCSS low 12bit
|
||||
// <11:0> = CDCSShigh/low 12bit code
|
||||
//
|
||||
BK4819_WriteRegister(0x08, (0u << 15) | ((CodeWord >> 0) & 0x0FFF)); // LS 12-bits
|
||||
BK4819_WriteRegister(0x08, (1u << 15) | ((CodeWord >> 12) & 0x0FFF)); // MS 12-bits
|
||||
}
|
||||
|
||||
void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
|
||||
{
|
||||
// REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable
|
||||
// REG_51 <14> 0 1 = GPIO0Input for CDCSS 0 = Normal Mode.(for BK4819v3)
|
||||
// REG_51 <13> 0 1 = Transmit negative CDCSS code 0 = Transmit positive CDCSScode
|
||||
// REG_51 <12> 0 CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
// REG_51 <11> 0 CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
// REG_51 <10> 0 1050HzDetectionMode 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
|
||||
// REG_51 <9> 0 Auto CDCSS Bw Mode 1 = Disable 0 = Enable.
|
||||
// REG_51 <8> 0 Auto CTCSS Bw Mode 0 = Enable 1 = Disable
|
||||
// REG_51 <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning 0 = min 127 = max
|
||||
|
||||
uint16_t Config;
|
||||
if (FreqControlWord == 2625)
|
||||
{ // Enables 1050Hz detection mode
|
||||
// Enable TxCTCSS
|
||||
// CTCSS Mode
|
||||
// 1050/4 Detect Enable
|
||||
// Enable Auto CDCSS Bw Mode
|
||||
// Enable Auto CTCSS Bw Mode
|
||||
// CTCSS/CDCSS Tx Gain1 Tuning = 74
|
||||
//
|
||||
Config = 0x944A; // 1 0 0 1 0 1 0 0 0 1001010
|
||||
}
|
||||
else
|
||||
{ // Enable TxCTCSS
|
||||
// CTCSS Mode
|
||||
// Enable Auto CDCSS Bw Mode
|
||||
// Enable Auto CTCSS Bw Mode
|
||||
// CTCSS/CDCSS Tx Gain1 Tuning = 74
|
||||
//
|
||||
Config = 0x904A; // 1 0 0 1 0 0 0 0 0 1001010
|
||||
}
|
||||
BK4819_WriteRegister(0x51, Config);
|
||||
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// When <13> = 0 for CTC1
|
||||
// <12:0> = CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 1 for CTC2 (Tail RX detection)
|
||||
// <12:0> = CTC2 (should below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 2 for CDCSS 134.4Hz
|
||||
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
BK4819_WriteRegister(0x07, BK4819_REG_07_MODE_CTC1 | (((FreqControlWord * 206488u) + 50000u) / 100000u)); // with rounding
|
||||
}
|
||||
|
||||
// freq_10Hz is CTCSS Hz * 10
|
||||
void BK4819_SetTailDetection(const uint32_t freq_10Hz)
|
||||
{
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// When <13> = 0 for CTC1
|
||||
// <12:0> = CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 1 for CTC2 (Tail RX detection)
|
||||
// <12:0> = CTC2 (should below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// When <13> = 2 for CDCSS 134.4Hz
|
||||
// <12:0> = CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
BK4819_WriteRegister(0x07, BK4819_REG_07_MODE_CTC2 | ((253910 + (freq_10Hz / 2)) / freq_10Hz)); // with rounding
|
||||
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
#endif
|
||||
}
|
||||
|
||||
void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
|
||||
{
|
||||
//VOX Algorithm
|
||||
@ -1251,19 +1086,8 @@ void BK4819_PrepareTransmit(void)
|
||||
{
|
||||
// BK4819_ExitBypass();
|
||||
BK4819_ExitTxMute();
|
||||
BK4819_sub_audible();
|
||||
}
|
||||
|
||||
void BK4819_sub_audible(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x37, 0x1D0F); // 0001110100001111
|
||||
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_GenTail(2); // 180 deg
|
||||
#else
|
||||
// BK4819_GenTail(4);
|
||||
BK4819_WriteRegister(0x52, (0u << 15) | (0u << 13) | (0u << 12) | (10u << 6) | (15u << 0)); // 0x028F); // 0 00 0 001010 001111
|
||||
#endif
|
||||
BK4819_config_sub_audible();
|
||||
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
BK4819_WriteRegister(0x30,
|
||||
@ -1280,48 +1104,6 @@ void BK4819_sub_audible(void)
|
||||
0);
|
||||
}
|
||||
|
||||
void BK4819_ExitSubAu(void)
|
||||
{
|
||||
// REG_51
|
||||
//
|
||||
// <15> 0
|
||||
// 1 = Enable TxCTCSS/CDCSS
|
||||
// 0 = Disable
|
||||
//
|
||||
// <14> 0
|
||||
// 1 = GPIO0Input for CDCSS
|
||||
// 0 = Normal Mode (for BK4819 v3)
|
||||
//
|
||||
// <13> 0
|
||||
// 1 = Transmit negative CDCSS code
|
||||
// 0 = Transmit positive CDCSS code
|
||||
//
|
||||
// <12> 0 CTCSS/CDCSS mode selection
|
||||
// 1 = CTCSS
|
||||
// 0 = CDCSS
|
||||
//
|
||||
// <11> 0 CDCSS 24/23bit selection
|
||||
// 1 = 24bit
|
||||
// 0 = 23bit
|
||||
//
|
||||
// <10> 0 1050HzDetectionMode
|
||||
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
|
||||
//
|
||||
// <9> 0 Auto CDCSS Bw Mode
|
||||
// 1 = Disable
|
||||
// 0 = Enable
|
||||
//
|
||||
// <8> 0 Auto CTCSS Bw Mode
|
||||
// 0 = Enable
|
||||
// 1 = Disable
|
||||
//
|
||||
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
|
||||
// 0 = min
|
||||
// 127 = max
|
||||
//
|
||||
BK4819_WriteRegister(0x51, 0);
|
||||
}
|
||||
|
||||
void BK4819_Conditional_RX_TurnOn(void)
|
||||
{
|
||||
if (g_rx_idle_mode)
|
||||
@ -1499,44 +1281,96 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency)
|
||||
BK4819_ExitTxMute();
|
||||
}
|
||||
|
||||
void BK4819_GenTail(const unsigned int tail)
|
||||
void BK4819_disable_sub_audible(void)
|
||||
{
|
||||
BK4819_WriteRegister(0x51, 0);
|
||||
}
|
||||
|
||||
void BK4819_config_sub_audible(void)
|
||||
{
|
||||
// #ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
// BK4819_gen_tail(2); // 180 deg
|
||||
// #else
|
||||
// BK4819_gen_tail(4);
|
||||
BK4819_WriteRegister(0x52, (0u << 15) | (0u << 13) | (0u << 12) | (10u << 6) | (15u << 0)); // 0x028F); // 0 00 0 001010 001111
|
||||
// #endif
|
||||
}
|
||||
|
||||
// freq_10Hz is CTCSS Hz * 10
|
||||
void BK4819_set_tail_detection(const uint32_t freq_10Hz)
|
||||
{
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// <15) ???
|
||||
//
|
||||
// <14:13> 0 = CTC-1, 1 = CTC-2 (tail detection), 2 = CDCSS 134.4Hz
|
||||
//
|
||||
// if <14:13> == 0
|
||||
// <12:0> CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// if <14:13> == 1
|
||||
// <12:0> CTC2 (should below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// if <14:13> == 2
|
||||
// <12:0> CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_WriteRegister(0x07, (0u << 13) | (((freq_10Hz * 206488u) + 50000u) / 100000u));
|
||||
#else
|
||||
BK4819_WriteRegister(0x07, (1u << 13) | ((253910 + (freq_10Hz / 2)) / freq_10Hz)); // with rounding
|
||||
#endif
|
||||
}
|
||||
|
||||
void BK4819_gen_tail(const unsigned int tail)
|
||||
{
|
||||
// REG_52
|
||||
//
|
||||
// <15> 0 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode
|
||||
// 0 = Normal
|
||||
// 1 = Enable
|
||||
// <15> degree shift CTCSS or 134.4Hz tail CDCSS
|
||||
// 0 = normal
|
||||
// 1 = enable
|
||||
//
|
||||
// <14:13> 0 CTCSS tail mode selection (only valid when REG_52 <15> = 1)
|
||||
// 00 = for 134.4Hz CTCSS Tail when CDCSS mode
|
||||
// 01 = CTCSS0 120° phase shift
|
||||
// 10 = CTCSS0 180° phase shift
|
||||
// 11 = CTCSS0 240° phase shift
|
||||
// <14:13> CTCSS tail mode selection (only valid when <15> == 1)
|
||||
// 0 = for 134.4Hz CTCSS Tail when CDCSS mode
|
||||
// 1 = CTCSS0 120° phase shift
|
||||
// 2 = CTCSS0 180° phase shift
|
||||
// 3 = CTCSS0 240° phase shift
|
||||
//
|
||||
// <12> 0 CTCSS Detection Threshold Mode
|
||||
// <12> CTCSS Detection Threshold Mode
|
||||
// 1 = ~0.1%
|
||||
// 0 = 0.1 Hz
|
||||
// 0 = 0.1Hz
|
||||
//
|
||||
// <11:6> 10 CTCSS found detect threshold 0 ~ 63
|
||||
//
|
||||
// <5:0> 15 CTCSS lost detect threshold 0 ~ 63
|
||||
// <5:0> 15 CTCSS lost detect threshold 0 ~ 63
|
||||
|
||||
uint16_t tail_phase_shift = 1;
|
||||
uint16_t ctcss_tail_mode_selection = 0;
|
||||
uint16_t ctcss_detect_threshold_mode = 0;
|
||||
// uint16_t ctcss_found_threshold = 10;
|
||||
// uint16_t ctcss_lost_threshold = 15;
|
||||
uint16_t ctcss_found_threshold = 20;
|
||||
uint16_t ctcss_lost_threshold = 30;
|
||||
|
||||
#if 0
|
||||
// original QS setting
|
||||
uint16_t ctcss_found_threshold = 10;
|
||||
uint16_t ctcss_lost_threshold = 15;
|
||||
#else
|
||||
// increase it to help reduce false detections when doing CTCSS/CDCSS searching
|
||||
uint16_t ctcss_found_threshold = 15;
|
||||
uint16_t ctcss_lost_threshold = 23;
|
||||
#endif
|
||||
|
||||
switch (tail)
|
||||
{
|
||||
case 0: // 134.4Hz CTCSS Tail
|
||||
// ctcss_tail_mode_selection = 0;
|
||||
break;
|
||||
case 1: // 120° phase shift
|
||||
ctcss_tail_mode_selection = 1;
|
||||
break;
|
||||
case 2: // 180° phase shift
|
||||
case 2: // 180° phase shift 1 10 0 001010 001111
|
||||
ctcss_tail_mode_selection = 2;
|
||||
break;
|
||||
case 3: // 240° phase shift
|
||||
@ -1558,60 +1392,148 @@ void BK4819_GenTail(const unsigned int tail)
|
||||
(ctcss_lost_threshold << 0));
|
||||
}
|
||||
|
||||
void BK4819_EnableCDCSS(void)
|
||||
void BK4819_set_CDCSS_code(const uint32_t control_word)
|
||||
{
|
||||
BK4819_GenTail(0); // CTC134
|
||||
BK4819_WriteRegister(0x51, 0x804A);
|
||||
BK4819_WriteRegister(0x51,
|
||||
( 1u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
( 0u << 14) | // GPIO input for CDCSS 0 = normal (for BK4819v3)
|
||||
( 0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
( 0u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
( 0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
( 0u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
( 1u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
( 1u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 7) | // ???
|
||||
(51u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// <15) ???
|
||||
//
|
||||
// <14:13> 0 = CTC-1, 1 = CTC-2 (tail detection), 2 = CDCSS 134.4Hz
|
||||
//
|
||||
// <14:13> == 0
|
||||
// <12:0> CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// <14:13> == 1
|
||||
// <12:0> CTC2 (should below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// <14:13> == 2
|
||||
// <12:0> CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
BK4819_WriteRegister(0x07, (0u << 13) | 2775u);
|
||||
|
||||
// REG_08 <15:0> <15> = 1 for CDCSS high 12bit
|
||||
// <15> = 0 for CDCSS low 12bit
|
||||
// <11:0> = CDCSShigh/low 12bit code
|
||||
//
|
||||
BK4819_WriteRegister(0x08, (0u << 15) | ((control_word >> 0) & 0x0FFF)); // LS 12-bits
|
||||
BK4819_WriteRegister(0x08, (1u << 15) | ((control_word >> 12) & 0x0FFF)); // MS 12-bits
|
||||
}
|
||||
|
||||
void BK4819_EnableCTCSS(void)
|
||||
void BK4819_set_CTCSS_freq(const uint32_t control_word)
|
||||
{
|
||||
if (control_word == 0)
|
||||
{ // NOAA 1050Hz tone stuff
|
||||
BK4819_WriteRegister(0x51,
|
||||
( 1u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
( 0u << 14) | // GPIO input for CDCSS 0 = normal (for BK4819v3)
|
||||
( 0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
( 1u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
( 0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
( 1u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
( 0u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 7) | // ???
|
||||
(74u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
}
|
||||
else
|
||||
{ // normal CTCSS
|
||||
BK4819_WriteRegister(0x51,
|
||||
( 1u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
( 0u << 14) | // GPIO input for CDCSS 0 = normal (for BK4819v3)
|
||||
( 0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
( 1u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
( 0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
( 0u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
( 0u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 7) | // ???
|
||||
(74u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
}
|
||||
|
||||
// REG_07 <15:0>
|
||||
//
|
||||
// <15) 0
|
||||
//
|
||||
// <14:13> 0 = CTC-1, 1 = CTC-2 (tail detection), 2 = CDCSS 134.4Hz
|
||||
//
|
||||
// if <14:13> == 0
|
||||
// <12:0> CTC1 frequency control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// if <14:13> == 1
|
||||
// <12:0> CTC2 (should be below 100Hz) frequency control word =
|
||||
// 25391 / freq(Hz) for XTAL 13M/26M or
|
||||
// 25000 / freq(Hz) for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
// if <14:13> == 2
|
||||
// <12:0> CDCSS baud rate frequency (134.4Hz) control word =
|
||||
// freq(Hz) * 20.64888 for XTAL 13M/26M or
|
||||
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
|
||||
//
|
||||
#ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_WriteRegister(0x07, (0u << 13) | (((control_word * 206488u) + 50000u) / 100000u));
|
||||
#else
|
||||
BK4819_WriteRegister(0x07, (1u << 13) | ((253910 + (control_word / 2)) / control_word));
|
||||
#endif
|
||||
}
|
||||
|
||||
void BK4819_enable_CDCSS_tail(void)
|
||||
{
|
||||
BK4819_gen_tail(0); // CTC134
|
||||
|
||||
BK4819_WriteRegister(0x51, // 0x804A); // 1 0 0 0 0 0 0 0 0 1001010
|
||||
( 1u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
( 0u << 14) | // GPIO0 input for CDCSS 0 = normal (for BK4819v3)
|
||||
( 0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
( 0u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
( 0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
( 0u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
( 0u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 7) | // ???
|
||||
(74u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
}
|
||||
|
||||
void BK4819_enable_CTCSS_tail(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
|
||||
//BK4819_gen_tail(1); // 120° phase shift
|
||||
BK4819_gen_tail(2); // 180° phase shift
|
||||
//BK4819_gen_tail(3); // 240° phase shift
|
||||
#else
|
||||
BK4819_GenTail(4); // 55Hz tone freq
|
||||
BK4819_gen_tail(4); // 55Hz tone freq
|
||||
#endif
|
||||
|
||||
// REG_51
|
||||
//
|
||||
// <15> 0
|
||||
// 1 = Enable TxCTCSS/CDCSS
|
||||
// 0 = Disable
|
||||
//
|
||||
// <14> 0
|
||||
// 1 = GPIO0Input for CDCSS
|
||||
// 0 = Normal Mode (for BK4819 v3)
|
||||
//
|
||||
// <13> 0
|
||||
// 1 = Transmit negative CDCSS code
|
||||
// 0 = Transmit positive CDCSS code
|
||||
//
|
||||
// <12> 0 CTCSS/CDCSS mode selection
|
||||
// 1 = CTCSS
|
||||
// 0 = CDCSS
|
||||
//
|
||||
// <11> 0 CDCSS 24/23bit selection
|
||||
// 1 = 24bit
|
||||
// 0 = 23bit
|
||||
//
|
||||
// <10> 0 1050HzDetectionMode
|
||||
// 1 = 1050/4 Detect Enable, CTC1 should be set to 1050/4 Hz
|
||||
//
|
||||
// <9> 0 Auto CDCSS Bw Mode
|
||||
// 1 = Disable
|
||||
// 0 = Enable
|
||||
//
|
||||
// <8> 0 Auto CTCSS Bw Mode
|
||||
// 0 = Enable
|
||||
// 1 = Disable
|
||||
//
|
||||
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
|
||||
// 0 = min
|
||||
// 127 = max
|
||||
|
||||
BK4819_WriteRegister(0x51, 0x904A); // 1 0 0 1 0 0 0 0 0 1001010
|
||||
BK4819_WriteRegister(0x51, // 0x804A); // 1 0 0 0 0 0 0 0 0 1001010
|
||||
( 1u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
( 0u << 14) | // GPIO0 input for CDCSS 0 = normal (for BK4819v3)
|
||||
( 0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
( 1u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
( 0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
( 0u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
( 0u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
( 0u << 7) | // ???
|
||||
(74u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
}
|
||||
|
||||
uint16_t BK4819_GetRSSI(void)
|
||||
@ -1763,56 +1685,21 @@ void BK4819_EnableFrequencyScan(void)
|
||||
( 1u << 0)); // 1 frequency scan enable
|
||||
}
|
||||
|
||||
void BK4819_SetScanFrequency(uint32_t Frequency)
|
||||
void BK4819_set_scan_frequency(uint32_t Frequency)
|
||||
{
|
||||
BK4819_set_rf_frequency(Frequency, false);
|
||||
|
||||
// REG_51
|
||||
//
|
||||
// <15> 0
|
||||
// 1 = Enable TxCTCSS/CDCSS
|
||||
// 0 = Disable
|
||||
//
|
||||
// <14> 0
|
||||
// 1 = GPIO-0 input for CDCSS
|
||||
// 0 = Normal Mode (for BK4819 v3)
|
||||
//
|
||||
// <13> 0
|
||||
// 1 = Transmit negative CDCSS code
|
||||
// 0 = Transmit positive CDCSS code
|
||||
//
|
||||
// <12> 0 CTCSS/CDCSS mode selection
|
||||
// 1 = CTCSS
|
||||
// 0 = CDCSS
|
||||
//
|
||||
// <11> 0 CDCSS 24/23bit selection
|
||||
// 1 = 24bit
|
||||
// 0 = 23bit
|
||||
//
|
||||
// <10> 0 1050Hz detection mode
|
||||
// 1 = 1050/4 detect enable, CTC1 should be set to 1050/4 Hz
|
||||
//
|
||||
// <9> 0 Auto CDCSS Bw Mode
|
||||
// 1 = Disable
|
||||
// 0 = Enable
|
||||
//
|
||||
// <8> 0 Auto CTCSS Bw Mode
|
||||
// 0 = Enable
|
||||
// 1 = Disable
|
||||
//
|
||||
// <6:0> 0 CTCSS/CDCSS Tx Gain1 Tuning
|
||||
// 0 = min
|
||||
// 127 = max
|
||||
//
|
||||
BK4819_WriteRegister(0x51,
|
||||
BK4819_REG_51_DISABLE_CxCSS |
|
||||
BK4819_REG_51_GPIO6_PIN2_NORMAL |
|
||||
BK4819_REG_51_TX_CDCSS_POSITIVE |
|
||||
BK4819_REG_51_MODE_CDCSS |
|
||||
BK4819_REG_51_CDCSS_23_BIT |
|
||||
BK4819_REG_51_1050HZ_NO_DETECTION |
|
||||
BK4819_REG_51_AUTO_CDCSS_BW_DISABLE |
|
||||
BK4819_REG_51_AUTO_CTCSS_BW_DISABLE);
|
||||
(0u << 15) | // TX CTCSS/CDCSS 1 = enable 0 = disable
|
||||
(0u << 14) | // GPIO input for CDCSS 0 = normal (for BK4819v3)
|
||||
(0u << 13) | // TX CDCSS code 1 = negative 0 = positive
|
||||
(0u << 12) | // CTCSS/CDCSS mode selection 1 = CTCSS 0 = CDCSS
|
||||
(0u << 11) | // CDCSS 24/23bit selection 1 = 24bit 0 = 23bit
|
||||
(0u << 10) | // 1050Hz detection mode 1 = enable, CTC1 should be set to 1050/4 Hz
|
||||
(1u << 9) | // Auto CDCSS BW Mode 1 = disable 0 = enable
|
||||
(1u << 8) | // Auto CTCSS BW Mode 1 = disable 0 = enable
|
||||
(0u << 7) | // ???
|
||||
(0u << 0)); // CTCSS/CDCSS TX gain 1 0 ~ 127
|
||||
|
||||
BK4819_RX_TurnOn();
|
||||
}
|
||||
@ -1858,9 +1745,11 @@ void BK4819_reset_fsk(void)
|
||||
(1u << 3) | // 0 or 1 sync length selection
|
||||
(0u << 0); // 0 ~ 7 ???
|
||||
|
||||
BK4819_WriteRegister(0x3F, 0); // disable interrupts
|
||||
BK4819_WriteRegister(0x3F, 0); // disable interrupts
|
||||
|
||||
BK4819_WriteRegister(0x59, (1u << 15) | (1u << 14) | fsk_reg59); // clear FIFO's
|
||||
BK4819_WriteRegister(0x59, (0u << 15) | (0u << 14) | fsk_reg59);
|
||||
BK4819_WriteRegister(0x59, fsk_reg59);
|
||||
|
||||
BK4819_WriteRegister(0x30, 0);
|
||||
}
|
||||
|
||||
|
@ -72,9 +72,9 @@ void BK4819_EnableAGC(void);
|
||||
|
||||
void BK4819_set_GPIO_pin(bk4819_gpio_pin_t Pin, bool bSet);
|
||||
|
||||
void BK4819_SetCDCSSCodeWord(uint32_t CodeWord);
|
||||
void BK4819_SetCTCSSFrequency(uint32_t BaudRate);
|
||||
void BK4819_SetTailDetection(const uint32_t freq_10Hz);
|
||||
void BK4819_set_CDCSS_code(const uint32_t control_word);
|
||||
void BK4819_set_CTCSS_freq(const uint32_t control_word);
|
||||
void BK4819_set_tail_detection(const uint32_t freq_10Hz);
|
||||
void BK4819_EnableVox(uint16_t Vox1Threshold, uint16_t Vox0Threshold);
|
||||
|
||||
void BK4819_set_TX_deviation(const bool narrow);
|
||||
@ -120,8 +120,12 @@ void BK4819_TurnsOffTones_TurnsOnRX(void);
|
||||
void BK4819_reset_fsk(void);
|
||||
void BK4819_Idle(void);
|
||||
void BK4819_PrepareTransmit(void);
|
||||
void BK4819_sub_audible(void);
|
||||
void BK4819_ExitSubAu(void);
|
||||
|
||||
void BK4819_config_sub_audible(void);
|
||||
void BK4819_gen_tail(const unsigned int tail);
|
||||
void BK4819_enable_CDCSS_tail(void);
|
||||
void BK4819_enable_CTCSS_tail(void);
|
||||
void BK4819_disable_sub_audible(void);
|
||||
|
||||
void BK4819_Conditional_RX_TurnOn(void);
|
||||
|
||||
@ -134,10 +138,6 @@ void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t F
|
||||
|
||||
void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency);
|
||||
|
||||
void BK4819_GenTail(const unsigned int tail);
|
||||
void BK4819_EnableCDCSS(void);
|
||||
void BK4819_EnableCTCSS(void);
|
||||
|
||||
uint16_t BK4819_GetRSSI(void);
|
||||
uint8_t BK4819_GetGlitchIndicator(void);
|
||||
uint8_t BK4819_GetExNoiceIndicator(void);
|
||||
@ -148,7 +148,7 @@ bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency);
|
||||
BK4819_CSS_scan_result_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq);
|
||||
void BK4819_DisableFrequencyScan(void);
|
||||
void BK4819_EnableFrequencyScan(void);
|
||||
void BK4819_SetScanFrequency(uint32_t Frequency);
|
||||
void BK4819_set_scan_frequency(uint32_t Frequency);
|
||||
|
||||
void BK4819_StopScan(void);
|
||||
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
4
misc.c
4
misc.c
@ -201,10 +201,14 @@ bool g_flag_save_channel;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
bool g_flag_save_fm;
|
||||
#endif
|
||||
|
||||
bool g_cdcss_lost;
|
||||
uint8_t g_cdcss_code_type;
|
||||
bool g_ctcss_lost;
|
||||
bool g_cxcss_tail_found;
|
||||
uint8_t g_ctcss_tail_phase_shift_rx;
|
||||
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
bool g_vox_lost;
|
||||
bool g_vox_noise_detected;
|
||||
|
3
misc.h
3
misc.h
@ -294,10 +294,13 @@ extern bool g_flag_save_channel;
|
||||
#ifdef ENABLE_FMRADIO
|
||||
extern bool g_flag_save_fm;
|
||||
#endif
|
||||
|
||||
extern bool g_cdcss_lost;
|
||||
extern uint8_t g_cdcss_code_type;
|
||||
extern bool g_ctcss_lost;
|
||||
extern bool g_cxcss_tail_found;
|
||||
extern uint8_t g_ctcss_tail_phase_shift_rx;
|
||||
|
||||
#ifdef ENABLE_VOX
|
||||
extern bool g_vox_lost;
|
||||
extern bool g_vox_noise_detected;
|
||||
|
70
radio.c
70
radio.c
@ -280,11 +280,11 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
|
||||
p_vfo->freq_config_rx.code = 0;
|
||||
break;
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_OPTIONS)) ? m_channel.rx_ctcss_cdcss_code : 0;
|
||||
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_TONE_LIST)) ? m_channel.rx_ctcss_cdcss_code : 0;
|
||||
break;
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(DCS_OPTIONS)) ? m_channel.rx_ctcss_cdcss_code : 0;
|
||||
p_vfo->freq_config_rx.code = (m_channel.rx_ctcss_cdcss_code < ARRAY_SIZE(DCS_CODE_LIST)) ? m_channel.rx_ctcss_cdcss_code : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -297,11 +297,11 @@ void RADIO_configure_channel(const unsigned int VFO, const unsigned int configur
|
||||
p_vfo->freq_config_tx.code = 0;
|
||||
break;
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_OPTIONS)) ? m_channel.tx_ctcss_cdcss_code : 0;
|
||||
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(CTCSS_TONE_LIST)) ? m_channel.tx_ctcss_cdcss_code : 0;
|
||||
break;
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(DCS_OPTIONS)) ? m_channel.tx_ctcss_cdcss_code : 0;
|
||||
p_vfo->freq_config_tx.code = (m_channel.tx_ctcss_cdcss_code < ARRAY_SIZE(DCS_CODE_LIST)) ? m_channel.tx_ctcss_cdcss_code : 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -741,45 +741,49 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
if (g_rx_vfo->am_mode == 0)
|
||||
{ // FM
|
||||
uint8_t code_type = g_selected_code_type;
|
||||
uint8_t Code = g_selected_code;
|
||||
uint8_t code = g_selected_code;
|
||||
|
||||
if (g_css_scan_mode == CSS_SCAN_MODE_OFF)
|
||||
{
|
||||
code_type = g_rx_vfo->p_rx->code_type;
|
||||
Code = g_rx_vfo->p_rx->code;
|
||||
code = g_rx_vfo->p_rx->code;
|
||||
}
|
||||
|
||||
switch (code_type)
|
||||
{
|
||||
default:
|
||||
case CODE_TYPE_NONE:
|
||||
BK4819_SetCTCSSFrequency(670);
|
||||
|
||||
//#ifndef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_SetTailDetection(550); // QS's 55Hz tone method
|
||||
//#else
|
||||
// BK4819_SetTailDetection(670); // 67Hz
|
||||
//#endif
|
||||
BK4819_set_CTCSS_freq(670);
|
||||
BK4819_set_tail_detection(550); // QS's 55Hz tone method
|
||||
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]);
|
||||
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[code]);
|
||||
|
||||
//#ifndef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
BK4819_SetTailDetection(550); // QS's 55Hz tone method
|
||||
//#else
|
||||
// BK4819_SetTailDetection(CTCSS_OPTIONS[Code]);
|
||||
//#endif
|
||||
// #ifdef ENABLE_CTCSS_TAIL_PHASE_SHIFT
|
||||
// BK4819_set_tail_detection(CTCSS_TONE_LIST[code]); // doesn't work in RX mode
|
||||
// #else
|
||||
// BK4819_set_tail_detection(550); // QS's 55Hz tone method
|
||||
// #endif
|
||||
|
||||
interrupt_mask |=
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CTCSS_FOUND |
|
||||
BK4819_REG_3F_CTCSS_LOST;
|
||||
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
|
||||
break;
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(code_type, Code));
|
||||
interrupt_mask |= BK4819_REG_3F_CxCSS_TAIL | BK4819_REG_3F_CDCSS_FOUND | BK4819_REG_3F_CDCSS_LOST;
|
||||
BK4819_set_CDCSS_code(DCS_GetGolayCodeWord(code_type, code));
|
||||
|
||||
interrupt_mask |=
|
||||
BK4819_REG_3F_CxCSS_TAIL |
|
||||
BK4819_REG_3F_CDCSS_FOUND |
|
||||
BK4819_REG_3F_CDCSS_LOST;
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -792,7 +796,8 @@ void RADIO_setup_registers(bool switch_to_function_foreground)
|
||||
#ifdef ENABLE_NOAA
|
||||
else
|
||||
{
|
||||
BK4819_SetCTCSSFrequency(2625);
|
||||
BK4819_set_CTCSS_freq(0); // NOAA 1050Hz stuff
|
||||
|
||||
interrupt_mask |= BK4819_REG_3F_CTCSS_FOUND | BK4819_REG_3F_CTCSS_LOST;
|
||||
}
|
||||
#endif
|
||||
@ -934,7 +939,7 @@ void RADIO_enableTX(const bool fsk_tx)
|
||||
|
||||
if (fsk_tx)
|
||||
{
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -942,16 +947,18 @@ void RADIO_enableTX(const bool fsk_tx)
|
||||
{
|
||||
default:
|
||||
case CODE_TYPE_NONE:
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[g_current_vfo->p_tx->code]);
|
||||
BK4819_gen_tail(4);
|
||||
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[g_current_vfo->p_tx->code]);
|
||||
break;
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_SetCDCSSCodeWord(DCS_GetGolayCodeWord(g_current_vfo->p_tx->code_type, g_current_vfo->p_tx->code));
|
||||
BK4819_gen_tail(4);
|
||||
BK4819_set_CDCSS_code(DCS_GetGolayCodeWord(g_current_vfo->p_tx->code_type, g_current_vfo->p_tx->code));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1094,7 +1101,7 @@ void RADIO_PrepareTX(void)
|
||||
g_dtmf_reply_state = DTMF_REPLY_NONE;
|
||||
}
|
||||
|
||||
void RADIO_EnableCxCSS(void)
|
||||
void RADIO_enable_CxCSS_tail(void)
|
||||
{
|
||||
switch (g_current_vfo->p_tx->code_type)
|
||||
{
|
||||
@ -1103,13 +1110,13 @@ void RADIO_EnableCxCSS(void)
|
||||
break;
|
||||
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
BK4819_EnableCTCSS();
|
||||
BK4819_enable_CTCSS_tail();
|
||||
SYSTEM_DelayMs(200);
|
||||
break;
|
||||
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
BK4819_EnableCDCSS();
|
||||
BK4819_enable_CDCSS_tail();
|
||||
SYSTEM_DelayMs(200);
|
||||
break;
|
||||
}
|
||||
@ -1123,7 +1130,8 @@ void RADIO_PrepareCssTX(void)
|
||||
|
||||
SYSTEM_DelayMs(200);
|
||||
|
||||
RADIO_EnableCxCSS();
|
||||
RADIO_enable_CxCSS_tail();
|
||||
|
||||
RADIO_setup_registers(true);
|
||||
}
|
||||
|
||||
|
2
radio.h
2
radio.h
@ -157,7 +157,7 @@ void RADIO_enableTX(const bool fsk_tx);
|
||||
|
||||
void RADIO_set_vfo_state(vfo_state_t State);
|
||||
void RADIO_PrepareTX(void);
|
||||
void RADIO_EnableCxCSS(void);
|
||||
void RADIO_enable_CxCSS_tail(void);
|
||||
void RADIO_PrepareCssTX(void);
|
||||
void RADIO_tx_eot(void);
|
||||
|
||||
|
43
ui/main.c
43
ui/main.c
@ -789,22 +789,35 @@ void UI_DisplayMain(void)
|
||||
}
|
||||
#else
|
||||
{
|
||||
strcpy(str, " ");
|
||||
|
||||
if (IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]))
|
||||
const bool is_freq_chan = IS_FREQ_CHANNEL(g_eeprom.screen_channel[vfo_num]);
|
||||
const uint8_t freq_in_channel = g_eeprom.vfo_info[vfo_num].freq_in_channel;
|
||||
// const uint8_t freq_in_channel = BOARD_find_channel(frequency); // currently way to slow
|
||||
|
||||
// if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
{
|
||||
//g_eeprom.vfo_info[vfo_num].freq_in_channel = BOARD_find_channel(frequency);
|
||||
if (g_eeprom.vfo_info[vfo_num].freq_in_channel <= USER_CHANNEL_LAST)
|
||||
strcpy(str, " ");
|
||||
|
||||
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
|
||||
{ // the channel number that contains this VFO frequency
|
||||
str[0] = 'F';
|
||||
// strcpy(str, "F");
|
||||
sprintf(str, "%03u", freq_in_channel);
|
||||
}
|
||||
|
||||
if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
strcat(str, "C");
|
||||
|
||||
// UI_PrintStringSmall(str, LCD_WIDTH - (7 * 2), 0, line + 1);
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 4), 0, line + 1);
|
||||
}
|
||||
/* else
|
||||
{
|
||||
if (is_freq_chan && freq_in_channel <= USER_CHANNEL_LAST)
|
||||
{ // the channel number that contains this VFO frequency
|
||||
sprintf(str, "%03u", freq_in_channel);
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - (7 * 3), 0, line + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (g_eeprom.vfo_info[vfo_num].compand)
|
||||
str[1] = 'C';
|
||||
|
||||
UI_PrintStringSmall(str, LCD_WIDTH - 1 - (6 * 2), 0, line + 1);
|
||||
}
|
||||
*/ }
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -941,7 +954,11 @@ void UI_DisplayMain(void)
|
||||
if (mdc1200_rx_ready_tick_500ms > 0)
|
||||
{
|
||||
g_center_line = CENTER_LINE_MDC1200;
|
||||
sprintf(str, "MDC1200 %02X %02X %04X", mdc1200_op, mdc1200_arg, mdc1200_unit_id);
|
||||
#ifdef ENABLE_MDC1200_SHOW_OP_ARG
|
||||
sprintf(str, "MDC1200 %02X %02X %04X", mdc1200_op, mdc1200_arg, mdc1200_unit_id);
|
||||
#else
|
||||
sprintf(str, "MDC1200 ID %04X", mdc1200_unit_id);
|
||||
#endif
|
||||
#ifdef ENABLE_SMALL_BOLD
|
||||
UI_PrintStringSmallBold(str, 2, 0, 3);
|
||||
#else
|
||||
|
12
ui/menu.c
12
ui/menu.c
@ -610,9 +610,9 @@ void UI_DisplayMenu(void)
|
||||
strcat(str, "OFF");
|
||||
else
|
||||
if (g_sub_menu_selection < 105)
|
||||
sprintf(str + strlen(str), "D%03oN", DCS_OPTIONS[g_sub_menu_selection - 1]);
|
||||
sprintf(str + strlen(str), "D%03oN", DCS_CODE_LIST[g_sub_menu_selection - 1]);
|
||||
else
|
||||
sprintf(str + strlen(str), "D%03oI", DCS_OPTIONS[g_sub_menu_selection - 105]);
|
||||
sprintf(str + strlen(str), "D%03oI", DCS_CODE_LIST[g_sub_menu_selection - 105]);
|
||||
break;
|
||||
|
||||
case MENU_RX_CTCSS:
|
||||
@ -634,23 +634,23 @@ void UI_DisplayMenu(void)
|
||||
pConfig->code_type = CODE_TYPE_NONE;
|
||||
pConfig->code = Code;
|
||||
|
||||
BK4819_ExitSubAu();
|
||||
BK4819_disable_sub_audible();
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str + strlen(str), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10);
|
||||
sprintf(str + strlen(str), "%u.%uHz", CTCSS_TONE_LIST[g_sub_menu_selection - 1] / 10, CTCSS_TONE_LIST[g_sub_menu_selection - 1] % 10);
|
||||
|
||||
pConfig->code_type = CODE_TYPE_CONTINUOUS_TONE;
|
||||
Code = g_sub_menu_selection - 1;
|
||||
pConfig->code = Code;
|
||||
|
||||
BK4819_SetCTCSSFrequency(CTCSS_OPTIONS[Code]);
|
||||
BK4819_set_CTCSS_freq(CTCSS_TONE_LIST[Code]);
|
||||
}
|
||||
#else
|
||||
if (g_sub_menu_selection == 0)
|
||||
strcat(str, "OFF");
|
||||
else
|
||||
sprintf(str + strlen(str), "%u.%uHz", CTCSS_OPTIONS[g_sub_menu_selection - 1] / 10, CTCSS_OPTIONS[g_sub_menu_selection - 1] % 10);
|
||||
sprintf(str + strlen(str), "%u.%uHz", CTCSS_TONE_LIST[g_sub_menu_selection - 1] / 10, CTCSS_TONE_LIST[g_sub_menu_selection - 1] % 10);
|
||||
#endif
|
||||
|
||||
break;
|
||||
|
@ -96,11 +96,11 @@ void UI_DisplaySearch(void)
|
||||
case CODE_TYPE_NONE:
|
||||
break;
|
||||
case CODE_TYPE_CONTINUOUS_TONE:
|
||||
sprintf(String, "CTCSS %u.%uHz", CTCSS_OPTIONS[g_search_css_result_code] / 10, CTCSS_OPTIONS[g_search_css_result_code] % 10);
|
||||
sprintf(String, "CTCSS %u.%uHz", CTCSS_TONE_LIST[g_search_css_result_code] / 10, CTCSS_TONE_LIST[g_search_css_result_code] % 10);
|
||||
break;
|
||||
case CODE_TYPE_DIGITAL:
|
||||
case CODE_TYPE_REVERSE_DIGITAL:
|
||||
sprintf(String, "CDCSS D%03oN", DCS_OPTIONS[g_search_css_result_code]);
|
||||
sprintf(String, "CDCSS D%03oN", DCS_CODE_LIST[g_search_css_result_code]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user