diff --git a/app/app.c b/app/app.c index e398769..4422c9f 100644 --- a/app/app.c +++ b/app/app.c @@ -1562,7 +1562,7 @@ void APP_process_flash_light_10ms(void) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_FLASHLIGHT); #ifdef ENABLE_FLASH_LIGHT_SOS_TONE if (!g_squelch_open && !g_monitor_enabled && !GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER)) - BK4819_StartTone1(880, 50, g_current_function == FUNCTION_TRANSMIT); + BK4819_StartTone1(880, 50, g_current_function == FUNCTION_TRANSMIT, true); #endif } } diff --git a/audio.c b/audio.c index 9e01dd5..008dc79 100644 --- a/audio.c +++ b/audio.c @@ -173,8 +173,7 @@ void AUDIO_PlayBeep(beep_type_t Beep) break; } -// BK4819_PlayTone(ToneFrequency, true); - BK4819_StartTone1(ToneFrequency, 96, false); + BK4819_StartTone1(ToneFrequency, 96, false, false); SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); diff --git a/driver/bk4819.c b/driver/bk4819.c index e69979c..0a8b389 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -814,7 +814,7 @@ void BK4819_EnableDTMF(void) (15u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15 } -void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx) +void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx, const bool tx_unmute) { GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); SYSTEM_DelayMs(2); @@ -825,7 +825,10 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const BK4819_EnterTxMute(); - BK4819_write_reg(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); + if (level > 0) + BK4819_write_reg(0x70, BK4819_REG_70_ENABLE_TONE1 | ((level & 0x7f) << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)); + else + BK4819_write_reg(0x70, 0); BK4819_write_reg(0x30, 0); @@ -862,10 +865,12 @@ void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const BK4819_write_reg(0x71, scale_freq(frequency)); - BK4819_ExitTxMute(); + if (tx_unmute) + BK4819_ExitTxMute(); SYSTEM_DelayMs(2); - if (!tx) + + if (!tx && level > 0) GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); } @@ -918,7 +923,7 @@ void BK4819_StopTones(const bool tx) void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level) { const uint16_t prev_af = BK4819_read_reg(0x47); - BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT); + BK4819_StartTone1(tone_Hz, level, g_current_function == FUNCTION_TRANSMIT, true); SYSTEM_DelayMs(delay - 2); BK4819_StopTones(g_current_function == FUNCTION_TRANSMIT); BK4819_write_reg(0x47, prev_af); @@ -936,9 +941,9 @@ void BK4819_PlayRoger(void) #endif const uint16_t prev_af = BK4819_read_reg(0x47); - BK4819_StartTone1(tone1_Hz, 96, true); + BK4819_StartTone1(tone1_Hz, 96, true, true); SYSTEM_DelayMs(80 - 2); - BK4819_StartTone1(tone2_Hz, 96, true); + BK4819_StartTone1(tone2_Hz, 96, true, true); SYSTEM_DelayMs(80); BK4819_StopTones(true); BK4819_write_reg(0x47, prev_af); @@ -2128,7 +2133,7 @@ void BK4819_reset_fsk(void) } } - void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id) + void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id, const bool long_preamble) { uint16_t fsk_reg59; uint8_t packet[42]; @@ -2320,10 +2325,11 @@ void BK4819_reset_fsk(void) (0u << 10) | // 0/1 1 = invert data when RX (0u << 9) | // 0/1 1 = invert data when TX (0u << 8) | // 0/1 ??? - (3u << 4) | // 0 ~ 15 preamble length .. bit toggling + (0u << 4) | // 0 ~ 15 preamble length .. bit toggling (1u << 3) | // 0/1 sync length (0u << 0); // 0 ~ 7 ??? - + fsk_reg59 |= long_preamble ? 15u << 4 : 3u << 4; + // Set packet length (not including pre-amble and sync bytes that we can't seem to disable) BK4819_write_reg(0x5D, ((size - 1) << 8)); diff --git a/driver/bk4819.h b/driver/bk4819.h index b09aa37..a8e2b15 100644 --- a/driver/bk4819.h +++ b/driver/bk4819.h @@ -106,7 +106,7 @@ void BK4819_SetCompander(const unsigned int mode); void BK4819_DisableVox(void); void BK4819_DisableDTMF(void); void BK4819_EnableDTMF(void); -void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx); +void BK4819_StartTone1(const uint16_t frequency, const unsigned int level, const bool tx, const bool tx_unmute); void BK4819_StopTones(const bool tx); void BK4819_PlayTone(const unsigned int tone_Hz, const unsigned int delay, const unsigned int level); void BK4819_EnterTxMute(void); @@ -165,7 +165,7 @@ void BK4819_PlayRoger(void); #ifdef ENABLE_MDC1200 void BK4819_enable_mdc1200_rx(const bool enable); - void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id); + void BK4819_send_MDC1200(const uint8_t op, const uint8_t arg, const uint16_t id, const bool long_preamble); #endif void BK4819_Enable_AfDac_DiscMode_TxDsp(void); diff --git a/firmware.bin b/firmware.bin index d4e133d..f0f0880 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 188b714..f9fa9ec 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ diff --git a/functions.c b/functions.c index 0ec5dfb..af0d45b 100644 --- a/functions.c +++ b/functions.c @@ -220,7 +220,7 @@ void FUNCTION_Select(function_type_t Function) GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); SYSTEM_DelayMs(2); - BK4819_StartTone1(500, 28, g_current_function == FUNCTION_TRANSMIT); + BK4819_StartTone1(500, 28, g_current_function == FUNCTION_TRANSMIT, true); SYSTEM_DelayMs(2); GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER); @@ -267,15 +267,16 @@ void FUNCTION_Select(function_type_t Function) if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH) { #ifdef ENABLE_MDC1200_SIDE_BEEP - BK4819_StartTone1(880, 20, false); - SYSTEM_DelayMs(120); - BK4819_StopTones(true); +// BK4819_StartTone1(880, 20, true, false); +// SYSTEM_DelayMs(120); +// BK4819_StopTones(true); #endif + SYSTEM_DelayMs(30); - BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id); + BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.config.setting.mdc1200_id, true); #ifdef ENABLE_MDC1200_SIDE_BEEP - BK4819_StartTone1(880, 20, false); + BK4819_StartTone1(880, 20, true, false); SYSTEM_DelayMs(120); BK4819_StopTones(true); #endif @@ -287,19 +288,7 @@ void FUNCTION_Select(function_type_t Function) BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0); } } -/* - BK4819_write_reg(0x30, - (1u << 15) | // enable VCO calibration - (1u << 14) | // enable something or other - (0u << 10) | // diable RX link - (1u << 9) | // enable AF DAC - (1u << 8) | // enable DISC mode, what's DISC mode ? - (15u << 4) | // enable PLL/VCO - (1u << 3) | // enable PA gain - (1u << 2) | // enable MIC ADC - (1u << 1) | // enable TX DSP - (0u << 0)); // disable RX DSP -*/ + if (g_eeprom.config.setting.enable_scrambler) BK4819_set_scrambler(g_current_vfo->channel.scrambler); diff --git a/radio.c b/radio.c index 02ea570..04e7b3c 100644 --- a/radio.c +++ b/radio.c @@ -1212,16 +1212,10 @@ void RADIO_tx_eot(void) // if (g_eeprom.config.setting.roger_mode == ROGER_MODE_MDC) if (g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_EOT || g_current_vfo->channel.mdc1200_mode == MDC1200_MODE_BOTH) { - #ifdef ENABLE_MDC1200_SIDE_BEEP - //BK4819_StartTone1(880, 20, false); - //SYSTEM_DelayMs(120); - //BK4819_StopTones(true); - #endif - - BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id); + BK4819_send_MDC1200(MDC1200_OP_CODE_POST_ID, 0x00, g_eeprom.config.setting.mdc1200_id, false); #ifdef ENABLE_MDC1200_SIDE_BEEP - BK4819_StartTone1(880, 20, false); + BK4819_StartTone1(880, 30, true, false); SYSTEM_DelayMs(120); BK4819_StopTones(true); #endif