diff --git a/README.md b/README.md index dbdf86f..861c51d 100644 --- a/README.md +++ b/README.md @@ -61,13 +61,13 @@ ENABLE_COPY_CHAN_TO_VFO := 1 copy current channel into the other VFO # New/modified function keys -* Long-press 'M' = Copy selected channel into same VFO, then switch VFO to frequency mode +* Long-press 'M' .. Copy selected channel into same VFO, then switch VFO to frequency mode * -* Long-press '7' = Toggle selected channel scanlist setting .. if VOX is disable in Makefile - or -* Long-press '5' = Toggle selected channel scanlist setting .. if NOAA is disable in Makefile +* Long-press '7' .. Toggle selected channel scanlist setting .. if VOX is disabled in Makefile +* or +* Long-press '5' .. Toggle selected channel scanlist setting .. if NOAA is disabled in Makefile * -* Long-press '*' = Start scanning, then toggle scanlist scan 1, 2 or ALL channels (if in channel scan mode) +* Long-press '*' .. Start scanning, then toggles scanlist scan 1, 2 or ALL channel scanning # Some changes made from the Quansheng firmware diff --git a/app/app.c b/app/app.c index 975f557..025544d 100644 --- a/app/app.c +++ b/app/app.c @@ -152,7 +152,7 @@ static void APP_CheckForIncoming(void) gUpdateStatus = true; } else - { + { // RF scanning if (gRxReceptionMode != RX_MODE_NONE) { if (gCurrentFunction != FUNCTION_INCOMING) @@ -163,7 +163,6 @@ static void APP_CheckForIncoming(void) updateRSSI(gEeprom.RX_VFO); gUpdateRSSI = true; } - return; } @@ -1068,7 +1067,8 @@ void APP_Update(void) #else if (gScreenToDisplay != DISPLAY_SCANNER && gScanState != SCAN_OFF && gScheduleScanListen && !gPttIsPressed) #endif - { + { // scanning + if (IS_FREQ_CHANNEL(gNextMrChannel)) { if (gCurrentFunction == FUNCTION_INCOMING) diff --git a/app/main.c b/app/main.c index bf2baea..fe08b78 100644 --- a/app/main.c +++ b/app/main.c @@ -549,16 +549,24 @@ static void MAIN_Key_MENU(const bool bKeyPressed, const bool bKeyHeld) #ifdef ENABLE_COPY_CHAN_TO_VFO - if (gEeprom.VFO_OPEN && - gScanState == SCAN_OFF && - gCssScanMode == CSS_SCAN_MODE_OFF) - { // copy channel to VFO + if (gEeprom.VFO_OPEN && gCssScanMode == CSS_SCAN_MODE_OFF) + { + if (gScanState != SCAN_OFF) + { + if (gCurrentFunction != FUNCTION_INCOMING || + gRxReceptionMode == RX_MODE_NONE || + ScanPauseDelayIn_10ms == 0) + { // scan is running (not paused) + return; + } + } + const unsigned int vfo = get_rx_VFO(); if (IS_MR_CHANNEL(gEeprom.ScreenChannel[vfo])) - { // swap to the VFO - + { // copy channel to VFO, then swap to the VFO + const unsigned int channel = FREQ_CHANNEL_FIRST + gEeprom.VfoInfo[vfo].Band; gEeprom.ScreenChannel[vfo] = channel; diff --git a/driver/bk4819.c b/driver/bk4819.c index 695d11f..aa96c20 100644 --- a/driver/bk4819.c +++ b/driver/bk4819.c @@ -58,23 +58,23 @@ void BK4819_Init(void) BK4819_WriteRegister(BK4819_REG_7D, 0xE940); - // RX AF level + // REG_48 .. RX AF level // - // REG_48 <15:12> 11 ??? 0 to 15 + // <15:12> 11 ??? 0 to 15 // - // REG_48 <11:10> 0 AF Rx Gain-1 - // 0 = 0dB - // 1 = -6dB - // 2 = -12dB - // 3 = -18dB + // <11:10> 0 AF Rx Gain-1 + // 0 = 0dB + // 1 = -6dB + // 2 = -12dB + // 3 = -18dB // - // REG_48 <9:4> 60 AF Rx Gain-2 -26dB ~ 5.5dB 0.5dB/step - // 63 = max - // 0 = mute + // <9:4> 60 AF Rx Gain-2 -26dB ~ 5.5dB 0.5dB/step + // 63 = max + // 0 = mute // - // REG_48 <3:0> 15 AF DAC Gain (after Gain-1 and Gain-2) approx 2dB/step - // 15 = max - // 0 = min + // <3:0> 15 AF DAC Gain (after Gain-1 and Gain-2) approx 2dB/step + // 15 = max + // 0 = min // BK4819_WriteRegister(BK4819_REG_48, // 0xB3A8); // 1011 00 111010 1000 (11u << 12) | // ??? 0..15 @@ -236,44 +236,43 @@ void BK4819_SetAGC(uint8_t Value) { if (Value == 0) { - // REG_10 <15:0> 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) + // REG_10 // - // <9:8> = LNA Gain Short - // 3 = 0dB - // 2 = -24dB // was -11 - // 1 = -30dB // was -16 - // 0 = -33dB // was -19 + // 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) // - // <7:5> = LNA Gain - // 7 = 0dB - // 6 = -2dB - // 5 = -4dB - // 4 = -6dB - // 3 = -9dB - // 2 = -14dB - // 1 = -19dB - // 0 = -24dB + // <15:10> ??? // - // <4:3> = MIXER Gain - // 3 = 0dB - // 2 = -3dB - // 1 = -6dB - // 0 = -8dB + // <9:8> LNA Gain Short + // 3 = 0dB <<< + // 2 = -24dB // was -11 + // 1 = -30dB // was -16 + // 0 = -33dB // was -19 // - // <2:0> = PGA Gain - // 7 = 0dB - // 6 = -3dB - // 5 = -6dB - // 4 = -9dB - // 3 = -15dB - // 2 = -21dB - // 1 = -27dB - // 0 = -33dB + // <7:5> LNA Gain + // 7 = 0dB + // 6 = -2dB + // 5 = -4dB + // 4 = -6dB + // 3 = -9dB + // 2 = -14dB <<< + // 1 = -19dB + // 0 = -24dB // - // LNA_SHORT .. 0dB - // LNA ........ 14dB - // MIXER ...... 0dB - // PGA ........ -3dB + // <4:3> MIXER Gain + // 3 = 0dB <<< + // 2 = -3dB + // 1 = -6dB + // 0 = -8dB + // + // <2:0> PGA Gain + // 7 = 0dB + // 6 = -3dB <<< + // 5 = -6dB + // 4 = -9dB + // 3 = -15dB + // 2 = -21dB + // 1 = -27dB + // 0 = -33dB // BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); // 000000 11 101 11 110 @@ -287,44 +286,47 @@ void BK4819_SetAGC(uint8_t Value) } else if (Value == 1) - { // what does this do ????????? + { // what does this do ??? unsigned int i; // REG_10 - // <15:0> 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) - // - // <9:8> = LNA Gain Short - // 3 = 0dB << original - // 2 = -24dB // was -11 - // 1 = -30dB // was -16 - // 0 = -33dB // was -19 - // - // <7:5> = LNA Gain - // 7 = 0dB - // 6 = -2dB - // 5 = -4dB - // 4 = -6dB - // 3 = -9dB - // 2 = -14dB << original - // 1 = -19dB - // 0 = -24dB - // - // <4:3> = MIXER Gain - // 3 = 0dB << original - // 2 = -3dB - // 1 = -6dB - // 0 = -8dB - // - // <2:0> = PGA Gain - // 7 = 0dB - // 6 = -3dB << original - // 5 = -6dB - // 4 = -9dB - // 3 = -15dB - // 2 = -21dB - // 1 = -27dB - // 0 = -33dB + // + // 0x0038 Rx AGC Gain Table[0]. (Index Max->Min is 3,2,1,0,-1) + // + // (15:10> ??? + // + // <9:8> LNA Gain Short + // 3 = 0dB << original + // 2 = -24dB // was -11 + // 1 = -30dB // was -16 + // 0 = -33dB // was -19 + // + // <7:5> LNA Gain + // 7 = 0dB + // 6 = -2dB + // 5 = -4dB + // 4 = -6dB + // 3 = -9dB + // 2 = -14dB << original + // 1 = -19dB + // 0 = -24dB + // + // <4:3> MIXER Gain + // 3 = 0dB << original + // 2 = -3dB + // 1 = -6dB + // 0 = -8dB + // + // <2:0> PGA Gain + // 7 = 0dB + // 6 = -3dB << original + // 5 = -6dB + // 4 = -9dB + // 3 = -15dB + // 2 = -21dB + // 1 = -27dB + // 0 = -33dB // BK4819_WriteRegister(BK4819_REG_13, (3u << 8) | (2u << 5) | (3u << 3) | (6u << 0)); @@ -357,15 +359,42 @@ void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet) void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) { - // 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 + // 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 @@ -376,15 +405,15 @@ void BK4819_SetCDCSSCodeWord(uint32_t CodeWord) // CTCSS/CDCSS Tx Gain1 Tuning = 51 // BK4819_WriteRegister(BK4819_REG_51, - 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)); + 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> // @@ -515,131 +544,142 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold) void BK4819_SetFilterBandwidth(const BK4819_FilterBandwidth_t Bandwidth, const bool weak_no_different) { - // REG_43 <14:12> 4 RF filter bandwidth - // 0 = 1.7 kHz - // 1 = 2.0 kHz - // 2 = 2.5 kHz - // 3 = 3.0 kHz - // 4 = 3.75 kHz - // 5 = 4.0 kHz - // 6 = 4.25 kHz - // 7 = 4.5 kHz - // if REG_43 <5> == 1 RF filter bandwidth * 2 + // REG_43 + // <15> 0 ??? // - // REG_43 <11:9> 0 RF filter bandwidth when signal is weak - // 0 = 1.7 kHz - // 1 = 2.0 kHz - // 2 = 2.5 kHz - // 3 = 3.0 kHz - // 4 = 3.75 kHz - // 5 = 4.0 kHz - // 6 = 4.25 kHz - // 7 = 4.5 kHz - // if REG_43 <5> == 1 RF filter bandwidth * 2 + // <14:12> 4 RF filter bandwidth + // 0 = 1.7 kHz + // 1 = 2.0 kHz + // 2 = 2.5 kHz + // 3 = 3.0 kHz + // 4 = 3.75 kHz + // 5 = 4.0 kHz + // 6 = 4.25 kHz + // 7 = 4.5 kHz + // if <5> == 1, RF filter bandwidth * 2 // - // REG_43 <8:6> 1 AFTxLPF2 filter Band Width - // 1 = 2.5 kHz (for 12.5k channel space) - // 2 = 2.75 kHz - // 0 = 3.0 kHz (for 25k channel space) - // 3 = 3.5 kHz - // 4 = 4.5 kHz - // 5 = 4.25 kHz - // 6 = 4.0 kHz - // 7 = 3.75 kHz + // <11:9> 0 RF filter bandwidth when signal is weak + // 0 = 1.7 kHz + // 1 = 2.0 kHz + // 2 = 2.5 kHz + // 3 = 3.0 kHz + // 4 = 3.75 kHz + // 5 = 4.0 kHz + // 6 = 4.25 kHz + // 7 = 4.5 kHz + // if <5> == 1, RF filter bandwidth * 2 // - // REG_43 <5:4> 0 BW Mode Selection - // 1 = 6.25k - // 0 = 12.5k - // 2 = 25k/20k + // <8:6> 1 AFTxLPF2 filter Band Width + // 1 = 2.5 kHz (for 12.5k channel space) + // 2 = 2.75 kHz + // 0 = 3.0 kHz (for 25k channel space) + // 3 = 3.5 kHz + // 4 = 4.5 kHz + // 5 = 4.25 kHz + // 6 = 4.0 kHz + // 7 = 3.75 kHz // - // REG_43 <2> 0 Gain after FM Demodulation - // 0 = 0dB - // 1 = 6dB + // <5:4> 0 BW Mode Selection + // 0 = 12.5k + // 1 = 6.25k + // 2 = 25k/20k + // + // <3> 1 ??? + // + // <2> 0 Gain after FM Demodulation + // 0 = 0dB + // 1 = 6dB + // + // <1:0> 0 ??? - if (Bandwidth == BK4819_FILTER_BW_WIDE) - { // 25kHz - if (weak_no_different) - { // make the RX bandwidth the same with weak signals (sounds better) + uint16_t val; - BK4819_WriteRegister(BK4819_REG_43, - (0u << 15) | // 0 - (3u << 12) | // 3 RF filter bandwidth - (3u << 9) | // *0 RF filter bandwidth when signal is weak - (6u << 6) | // *0 AFTxLPF2 filter Band Width - (2u << 4) | // 2 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } - else - { // with weak RX signals the RX bandwidth is reduced - BK4819_WriteRegister(BK4819_REG_43, // 0x3028); // 0 011 000 000 10 1 0 00 - (0u << 15) | // 0 - (3u << 12) | // 3 RF filter bandwidth - (0u << 9) | // *0 RF filter bandwidth when signal is weak - (6u << 6) | // *0 AFTxLPF2 filter Band Width - (2u << 4) | // 2 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } - } - else - if (Bandwidth == BK4819_FILTER_BW_NARROW) - { // 12.5kHz - if (weak_no_different) - { - BK4819_WriteRegister(BK4819_REG_43, // 0x4048); // 0 100 000 001 00 1 0 00 - (0u << 15) | // 0 - (3u << 12) | // 4 RF filter bandwidth - (3u << 9) | // *0 RF filter bandwidth when signal is weak - (0u << 6) | // *1 AFTxLPF2 filter Band Width - (0u << 4) | // 0 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } - else - { - BK4819_WriteRegister(BK4819_REG_43, // 0x4048); // 0 100 000 001 00 1 0 00 - (0u << 15) | // 0 - (3u << 12) | // 4 RF filter bandwidth - (0u << 9) | // *0 RF filter bandwidth when signal is weak - (0u << 6) | // *1 AFTxLPF2 filter Band Width - (0u << 4) | // 0 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } - } - else - if (Bandwidth == BK4819_FILTER_BW_NARROWER) - { // 6.25kHz - if (weak_no_different) - { - BK4819_WriteRegister(BK4819_REG_43, - (0u << 15) | // 0 - (2u << 12) | // 4 RF filter bandwidth - (2u << 9) | // 0 RF filter bandwidth when signal is weak - (1u << 6) | // 1 AFTxLPF2 filter Band Width - (1u << 4) | // 1 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } - else - { - BK4819_WriteRegister(BK4819_REG_43, - (0u << 15) | // 0 - (2u << 12) | // 4 RF filter bandwidth - (0u << 9) | // 0 RF filter bandwidth when signal is weak - (1u << 6) | // 1 AFTxLPF2 filter Band Width - (1u << 4) | // 1 BW Mode Selection - (1u << 3) | // 1 - (0u << 2) | // 0 Gain after FM Demodulation - (0u << 0)); // 0 - } + switch (Bandwidth) + { + default: + case BK4819_FILTER_BW_WIDE: // 25kHz + if (weak_no_different) + { // make the RX bandwidth the same with weak signals + val = + (0u << 15) | // 0 + (5u << 12) | // *3 RF filter bandwidth + (5u << 9) | // *0 RF filter bandwidth when signal is weak + (6u << 6) | // *0 AFTxLPF2 filter Band Width + (2u << 4) | // 2 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 0 Gain after FM Demodulation + (0u << 0); // 0 + } + else + { // with weak RX signals the RX bandwidth is reduced + val = // 0x3028); // 0 011 000 000 10 1 0 00 + (0u << 15) | // 0 + (5u << 12) | // *3 RF filter bandwidth + (2u << 9) | // *0 RF filter bandwidth when signal is weak + (6u << 6) | // *0 AFTxLPF2 filter Band Width + (2u << 4) | // 2 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 0 Gain after FM Demodulation + (0u << 0); // 0 + } + break; + + case BK4819_FILTER_BW_NARROW: // 12.5kHz + if (weak_no_different) + { + val = + (0u << 15) | // 0 + (5u << 12) | // *4 RF filter bandwidth + (5u << 9) | // *0 RF filter bandwidth when signal is weak + (0u << 6) | // *1 AFTxLPF2 filter Band Width + (0u << 4) | // 0 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 0 Gain after FM Demodulation + (0u << 0); // 0 + } + else + { + val = // 0x4048); // 0 100 000 001 00 1 0 00 + (0u << 15) | // 0 + (5u << 12) | // *4 RF filter bandwidth + (2u << 9) | // *0 RF filter bandwidth when signal is weak + (0u << 6) | // *1 AFTxLPF2 filter Band Width + (0u << 4) | // 0 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 0 Gain after FM Demodulation + (0u << 0); // 0 + } + break; + + case BK4819_FILTER_BW_NARROWER: // 6.25kHz + if (weak_no_different) + { + val = + (0u << 15) | // 0 + (3u << 12) | // 3 RF filter bandwidth + (3u << 9) | // *0 RF filter bandwidth when signal is weak + (1u << 6) | // 1 AFTxLPF2 filter Band Width + (1u << 4) | // 1 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 0 Gain after FM Demodulation + (0u << 0); // 0 + } + else + { + val = + (0u << 15) | // 0 + (3u << 12) | // 3 RF filter bandwidth + (0u << 9) | // 0 RF filter bandwidth when signal is weak + (1u << 6) | // 1 AFTxLPF2 filter Band Width + (1u << 4) | // 1 BW Mode Selection + (1u << 3) | // 1 + (0u << 2) | // 1 Gain after FM Demodulation + (0u << 0); // 0 + } + break; } + + BK4819_WriteRegister(BK4819_REG_43, val); } void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency) @@ -680,19 +720,21 @@ void BK4819_SetupSquelch( uint8_t SquelchCloseGlitchThresh, uint8_t SquelchOpenGlitchThresh) { - // REG_70 <15> 0 Enable TONE1 - // 1 = Enable - // 0 = Disable + // REG_70 // - // REG_70 <14:8> 0 TONE1 tuning gain - // 0 ~ 127 + // <15> 0 Enable TONE1 + // 1 = Enable + // 0 = Disable // - // REG_70 <7> 0 Enable TONE2 - // 1 = Enable - // 0 = Disable + // <14:8> 0 TONE1 tuning gain + // 0 ~ 127 // - // REG_70 <6:0> 0 TONE2/FSK tuning gain - // 0 ~ 127 + // <7> 0 Enable TONE2 + // 1 = Enable + // 0 = Disable + // + // <6:0> 0 TONE2/FSK tuning gain + // 0 ~ 127 // BK4819_WriteRegister(BK4819_REG_70, 0); @@ -702,43 +744,51 @@ void BK4819_SetupSquelch( // BK4819_WriteRegister(BK4819_REG_4D, 0xA000 | SquelchCloseGlitchThresh); - // REG_4E <15:14> 1 ??? + // REG_4E // - // REG_4E <13:11> 5 Squelch = 1 Delay Setting - // 0 ~ 7 + // <15:14> 1 ??? // - // REG_4E <10: 9> 7 Squelch = 0 Delay Setting - // 0 ~ 3 + // <13:11> 5 Squelch = 1 Delay Setting + // 0 ~ 7 // - // REG_4E < 8> 0 ??? + // <10:9> 7 Squelch = 0 Delay Setting + // 0 ~ 3 // - // REG_4E < 7: 0> 8 Glitch threshold for Squelch = 1 - // 0 ~ 255 + // <8> 0 ??? + // + // <7:0> 8 Glitch threshold for Squelch = 1 + // 0 ~ 255 // BK4819_WriteRegister(BK4819_REG_4E, // 01 101 11 1 00000000 #ifndef ENABLE_FASTER_CHANNEL_SCAN // original - (1u << 14) // 1 ??? - | (5u << 11) // 5 squelch = 1 delay .. 0 ~ 7 - | (3u << 9) // 3 squelch = 0 delay .. 0 ~ 3 - | SquelchOpenGlitchThresh); // 0 ~ 255 + (1u << 14) | // 1 ??? + (5u << 11) | // 5 squelch = 1 delay .. 0 ~ 7 + (3u << 9) | // 3 squelch = 0 delay .. 0 ~ 3 + SquelchOpenGlitchThresh); // 0 ~ 255 #else // faster (but twitchier) - (1u << 14) // 1 ??? - | SquelchOpenGlitchThresh); // 0 ~ 255 + (1u << 14) | // 1 ??? + SquelchOpenGlitchThresh); // 0 ~ 255 #endif - - // REG_4F <14:8> 47 Ex-noise threshold for Squelch = 0 - // 0 ~ 127 + + // REG_4F // - // REG_4F < 7> ??? + // <14:8> 47 Ex-noise threshold for Squelch = 0 + // 0 ~ 127 + // + // <7> ??? + // + // <6:0> 46 Ex-noise threshold for Squelch = 1 + // 0 ~ 127 // - // REG_4F < 6:0> 46 Ex-noise threshold for Squelch = 1 - // 0 ~ 127 BK4819_WriteRegister(BK4819_REG_4F, ((uint16_t)SquelchCloseNoiseThresh << 8) | SquelchOpenNoiseThresh); - // REG_78 <15:8> 72 RSSI threshold for Squelch = 1 0.5dB/step - // REG_78 < 7:0> 70 RSSI threshold for Squelch = 0 0.5dB/step + // REG_78 + // + // <15:8> 72 RSSI threshold for Squelch = 1 0.5dB/step + // + // <7:0> 70 RSSI threshold for Squelch = 0 0.5dB/step // BK4819_WriteRegister(BK4819_REG_78, ((uint16_t)SquelchOpenRSSIThresh << 8) | SquelchCloseRSSIThresh); @@ -751,6 +801,7 @@ void BK4819_SetAF(BK4819_AF_Type_t AF) { // AF Output Inverse Mode = Inverse // Undocumented bits 0x2040 + // BK4819_WriteRegister(BK4819_REG_47, 0x6040 | (AF << 8)); } @@ -769,6 +820,7 @@ void BK4819_RX_TurnOn(void) // Enable DSP // Enable XTAL // Enable Band Gap + // BK4819_WriteRegister(BK4819_REG_37, 0x1F0F); // 0001111100001111 // Turn off everything @@ -782,6 +834,7 @@ void BK4819_RX_TurnOn(void) // Disable MIC ADC // Disable TX DSP // Enable RX DSP + // BK4819_WriteRegister(BK4819_REG_30, 0b1011111111110001); // 1 0 1111 1 1 1111 0 0 0 1 } @@ -821,7 +874,7 @@ void BK4819_EnableScramble(uint8_t Type) bool BK4819_CompanderEnabled(void) { - return (BK4819_ReadRegister(BK4819_REG_31) & (1u < 3)) ? true : false; + return (BK4819_ReadRegister(BK4819_REG_31) & (1u << 3)) ? true : false; } void BK4819_SetCompander(const unsigned int mode) @@ -832,54 +885,54 @@ void BK4819_SetCompander(const unsigned int mode) // mode 3 .. TX and RX const uint16_t r31 = BK4819_ReadRegister(BK4819_REG_31); - + if (mode == 0) { // disable BK4819_WriteRegister(BK4819_REG_31, r31 & ~(1u << 3)); return; } - // set the compressor ratio + // REG_29 // - // REG_29 <15:14> 10 Compress (AF Tx) Ratio - // 00 = Disable - // 01 = 1.333:1 - // 10 = 2:1 - // 11 = 4:1 + // <15:14> 10 Compress (AF Tx) Ratio + // 00 = Disable + // 01 = 1.333:1 + // 10 = 2:1 + // 11 = 4:1 // - // REG_29 <13:7> 86 Compress (AF Tx) 0 dB point (dB) + // <13:7> 86 Compress (AF Tx) 0 dB point (dB) // - // REG_29 <6:0> 64 Compress (AF Tx) noise point (dB) + // <6:0> 64 Compress (AF Tx) noise point (dB) // const uint16_t compress_ratio = (mode == 1 || mode >= 3) ? 2 : 0; // 2:1 const uint16_t compress_0dB = 86; const uint16_t compress_noise_dB = 64; // AB40 10 1010110 1000000 - BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u < 14)) | (compress_ratio < 14)); - (compress_ratio << 14) - | (compress_0dB << 7) - | (compress_noise_dB << 0)); - - // set the expander ratio + BK4819_WriteRegister(BK4819_REG_29, // (BK4819_ReadRegister(BK4819_REG_29) & ~(3u << 14)) | (compress_ratio << 14)); + (compress_ratio << 14) | + (compress_0dB << 7) | + (compress_noise_dB << 0)); + + // REG_28 // - // REG_28 <15:14> 01 Expander (AF Rx) Ratio - // 00 = Disable - // 01 = 1:2 - // 10 = 1:3 - // 11 = 1:4 + // <15:14> 01 Expander (AF Rx) Ratio + // 00 = Disable + // 01 = 1:2 + // 10 = 1:3 + // 11 = 1:4 // - // REG_28 <13:7> 86 Expander (AF Rx) 0 dB point (dB) + // <13:7> 86 Expander (AF Rx) 0 dB point (dB) // - // REG_28 <6:0> 56 Expander (AF Rx) noise point (dB) + // <6:0> 56 Expander (AF Rx) noise point (dB) // const uint16_t expand_ratio = (mode >= 2) ? 1 : 0; // 1:2 const uint16_t expand_0dB = 86; const uint16_t expand_noise_dB = 56; // 6B38 01 1010110 0111000 - BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u < 14)) | (expand_ratio < 14)); - (expand_ratio << 14) - | (expand_0dB << 7) - | (expand_noise_dB << 0)); + BK4819_WriteRegister(BK4819_REG_28, // (BK4819_ReadRegister(BK4819_REG_28) & ~(3u << 14)) | (expand_ratio << 14)); + (expand_ratio << 14) | + (expand_0dB << 7) | + (expand_noise_dB << 0)); // enable BK4819_WriteRegister(BK4819_REG_31, r31 | (1u << 3)); @@ -898,29 +951,36 @@ void BK4819_DisableDTMF(void) void BK4819_EnableDTMF(void) { - // no idea what this register does + // no idea what this does BK4819_WriteRegister(BK4819_REG_21, 0x06D8); // 0000 0110 1101 1000 - // REG_24 <15> 1 ??? - // REG_24 <14:7> 24 Threshold - // REG_24 <6> 1 ??? - // REG_24 <5> 0 DTMF/SelCall enable - // 1 = Enable - // 0 = Disable - // REG_24 <4> 1 DTMF or SelCall detection mode - // 1 = for DTMF - // 0 = for SelCall - // REG_24 <3:0> 14 Max symbol number for SelCall detection - -// const uint16_t threshold = 24; // doesn't decode non-QS radios + // REG_24 + // + // <15> 1 ??? + // + // <14:7> 24 Threshold + // + // <6> 1 ??? + // + // <5> 0 DTMF/SelCall enable + // 1 = Enable + // 0 = Disable + // + // <4> 1 DTMF or SelCall detection mode + // 1 = for DTMF + // 0 = for SelCall + // + // <3:0> 14 Max symbol number for SelCall detection + // +// const uint16_t threshold = 24; // default, but doesn't decode non-QS radios const uint16_t threshold = 160; // but 128 ~ 247 does - BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110 - (1u << BK4819_REG_24_SHIFT_UNKNOWN_15) - | (threshold << BK4819_REG_24_SHIFT_THRESHOLD) // 0 ~ 255 - | (1u << BK4819_REG_24_SHIFT_UNKNOWN_6) - | BK4819_REG_24_ENABLE - | BK4819_REG_24_SELECT_DTMF - | (14u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15 + BK4819_WriteRegister(BK4819_REG_24, // 1 00011000 1 1 1 1110 + (1u << BK4819_REG_24_SHIFT_UNKNOWN_15) | + (threshold << BK4819_REG_24_SHIFT_THRESHOLD) | // 0 ~ 255 + (1u << BK4819_REG_24_SHIFT_UNKNOWN_6) | + BK4819_REG_24_ENABLE | + BK4819_REG_24_SELECT_DTMF | + (14u << BK4819_REG_24_SHIFT_MAX_SYMBOLS)); // 0 ~ 15 } void BK4819_PlayTone(uint16_t Frequency, bool bTuningGainSwitch) @@ -967,13 +1027,12 @@ void BK4819_TurnsOffTones_TurnsOnRX(void) BK4819_WriteRegister(BK4819_REG_30, 0); BK4819_WriteRegister(BK4819_REG_30, - 0 - | BK4819_REG_30_ENABLE_VCO_CALIB - | BK4819_REG_30_ENABLE_RX_LINK - | BK4819_REG_30_ENABLE_AF_DAC - | BK4819_REG_30_ENABLE_DISC_MODE - | BK4819_REG_30_ENABLE_PLL_VCO - | BK4819_REG_30_ENABLE_RX_DSP); + BK4819_REG_30_ENABLE_VCO_CALIB | + BK4819_REG_30_ENABLE_RX_LINK | + BK4819_REG_30_ENABLE_AF_DAC | + BK4819_REG_30_ENABLE_DISC_MODE | + BK4819_REG_30_ENABLE_PLL_VCO | + BK4819_REG_30_ENABLE_RX_DSP); } #ifdef ENABLE_AIRCOPY @@ -1009,10 +1068,10 @@ void BK4819_ExitBypass(void) // REG_7E // - // <15> 0 AGC fix mode + // <15> 0 AGC fix mode // 1 = fix // 0 = auto - // + // // <14:12> 3 AGC fix index // 3 ( 3) = max // 2 ( 2) @@ -1022,22 +1081,22 @@ void BK4819_ExitBypass(void) // 6 (-2) // 5 (-3) // 4 (-4) = min - // - // <11:6> 0 ??? - // - // <5:3> 5 DC filter band width for Tx (MIC In) + // + // <11:6> 0 ??? + // + // <5:3> 5 DC filter band width for Tx (MIC In) // 0 ~ 7 // 0 = bypass DC filter - // - // <2:0> 6 DC filter band width for Rx (I.F In) + // + // <2:0> 6 DC filter band width for Rx (I.F In) // 0 ~ 7 // 0 = bypass DC filter - // + // BK4819_WriteRegister(BK4819_REG_7E, // 0x302E); // 0 011 000000 101 110 - (0u << 15) // 0 AGC fix mode - | (3u << 12) // 3 AGC fix index - | (5u << 3) // 5 DC Filter band width for Tx (MIC In) - | (6u << 0)); // 6 DC Filter band width for Rx (I.F In) + (0u << 15) | // 0 AGC fix mode + (3u << 12) | // 3 AGC fix index + (5u << 3) | // 5 DC Filter band width for Tx (MIC In) + (6u << 0)); // 6 DC Filter band width for Rx (I.F In) } void BK4819_PrepareTransmit(void) @@ -1057,15 +1116,42 @@ void BK4819_TxOn_Beep(void) void BK4819_ExitSubAu(void) { - // 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 + // 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(BK4819_REG_51, 0x0000); } @@ -1086,11 +1172,10 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback) BK4819_SetAF(bLocalLoopback ? BK4819_AF_BEEP : BK4819_AF_MUTE); BK4819_WriteRegister(BK4819_REG_70, - 0 - | BK4819_REG_70_MASK_ENABLE_TONE1 - | (83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) - | BK4819_REG_70_MASK_ENABLE_TONE2 - | (83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN)); + BK4819_REG_70_MASK_ENABLE_TONE1 | + (83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN) | + BK4819_REG_70_MASK_ENABLE_TONE2 | + (83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN)); BK4819_EnableTXLink(); } @@ -1109,17 +1194,16 @@ void BK4819_ExitDTMF_TX(bool bKeep) void BK4819_EnableTXLink(void) { BK4819_WriteRegister(BK4819_REG_30, - 0 - | BK4819_REG_30_ENABLE_VCO_CALIB - | BK4819_REG_30_ENABLE_UNKNOWN - | BK4819_REG_30_DISABLE_RX_LINK - | BK4819_REG_30_ENABLE_AF_DAC - | BK4819_REG_30_ENABLE_DISC_MODE - | BK4819_REG_30_ENABLE_PLL_VCO - | BK4819_REG_30_ENABLE_PA_GAIN - | BK4819_REG_30_DISABLE_MIC_ADC - | BK4819_REG_30_ENABLE_TX_DSP - | BK4819_REG_30_DISABLE_RX_DSP); + BK4819_REG_30_ENABLE_VCO_CALIB | + BK4819_REG_30_ENABLE_UNKNOWN | + BK4819_REG_30_DISABLE_RX_LINK | + BK4819_REG_30_ENABLE_AF_DAC | + BK4819_REG_30_ENABLE_DISC_MODE | + BK4819_REG_30_ENABLE_PLL_VCO | + BK4819_REG_30_ENABLE_PA_GAIN | + BK4819_REG_30_DISABLE_MIC_ADC | + BK4819_REG_30_ENABLE_TX_DSP | + BK4819_REG_30_DISABLE_RX_DSP); } void BK4819_PlayDTMF(char Code) @@ -1127,31 +1211,30 @@ void BK4819_PlayDTMF(char Code) uint16_t tone1 = 0; uint16_t tone2 = 0; - switch (Code) - { - case '0': tone1 = 9715; tone2 = 13793; break; // 941Hz 1336Hz - case '1': tone1 = 7196; tone2 = 12482; break; // 679Hz 1209Hz - case '2': tone1 = 7196; tone2 = 13793; break; // 697Hz 1336Hz - case '3': tone1 = 7196; tone2 = 15249; break; // 679Hz 1477Hz - case '4': tone1 = 7950; tone2 = 12482; break; // 770Hz 1209Hz - case '5': tone1 = 7950; tone2 = 13793; break; // 770Hz 1336Hz - case '6': tone1 = 7950; tone2 = 15249; break; // 770Hz 1477Hz - case '7': tone1 = 8796; tone2 = 12482; break; // 852Hz 1209Hz - case '8': tone1 = 8796; tone2 = 13793; break; // 852Hz 1336Hz - case '9': tone1 = 8796; tone2 = 15249; break; // 852Hz 1477Hz - case 'A': tone1 = 7196; tone2 = 16860; break; // 679Hz 1633Hz - case 'B': tone1 = 7950; tone2 = 16860; break; // 770Hz 1633Hz - case 'C': tone1 = 8796; tone2 = 16860; break; // 852Hz 1633Hz - case 'D': tone1 = 9715; tone2 = 16860; break; // 941Hz 1633Hz - case '*': tone1 = 9715; tone2 = 12482; break; // 941Hz 1209Hz - case '#': tone1 = 9715; tone2 = 15249; break; // 941Hz 1477Hz + switch (Code) // Hz Hz + { // + case '0': tone1 = 9715; tone2 = 13793; break; // 941 1336 + case '1': tone1 = 7196; tone2 = 12482; break; // 679 1209 + case '2': tone1 = 7196; tone2 = 13793; break; // 697 1336 + case '3': tone1 = 7196; tone2 = 15249; break; // 679 1477 + case '4': tone1 = 7950; tone2 = 12482; break; // 770 1209 + case '5': tone1 = 7950; tone2 = 13793; break; // 770 1336 + case '6': tone1 = 7950; tone2 = 15249; break; // 770 1477 + case '7': tone1 = 8796; tone2 = 12482; break; // 852 1209 + case '8': tone1 = 8796; tone2 = 13793; break; // 852 1336 + case '9': tone1 = 8796; tone2 = 15249; break; // 852 1477 + case 'A': tone1 = 7196; tone2 = 16860; break; // 679 1633 + case 'B': tone1 = 7950; tone2 = 16860; break; // 770 1633 + case 'C': tone1 = 8796; tone2 = 16860; break; // 852 1633 + case 'D': tone1 = 9715; tone2 = 16860; break; // 941 1633 + case '*': tone1 = 9715; tone2 = 12482; break; // 941 1209 + case '#': tone1 = 9715; tone2 = 15249; break; // 941 1477 } - if (tone1 > 0 && tone2 > 0) - { + if (tone1 > 0) BK4819_WriteRegister(BK4819_REG_71, tone1); + if (tone2 > 0) BK4819_WriteRegister(BK4819_REG_72, tone2); - } } void BK4819_PlayDTMFString(const char *pString, bool bDelayFirst, uint16_t FirstCodePersistTime, uint16_t HashCodePersistTime, uint16_t CodePersistTime, uint16_t CodeInternalTime) @@ -1183,19 +1266,21 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency) { BK4819_EnterTxMute(); - // REG_70 <15> 0 Enable TONE1 - // 1 = Enable - // 0 = Disable + // REG_70 // - // REG_70 <14:8> 0 TONE1 tuning gain - // 0 ~ 127 + // <15> 0 Enable TONE1 + // 1 = Enable + // 0 = Disable // - // REG_70 <7> 0 Enable TONE2 - // 1 = Enable - // 0 = Disable + // <14:8> 0 TONE1 tuning gain + // 0 ~ 127 // - // REG_70 <6:0> 0 TONE2/FSK tuning gain - // 0 ~ 127 + // <7> 0 Enable TONE2 + // 1 = Enable + // 0 = Disable + // + // <6:0> 0 TONE2/FSK amplitude + // 0 ~ 127 // // set the tone amplitude // @@ -1215,19 +1300,25 @@ void BK4819_TransmitTone(bool bLocalLoopback, uint32_t Frequency) void BK4819_GenTail(uint8_t Tail) { - // REG_52 <15> 0 Enable 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode - // 0 = Normal - // 1 = Enable - // REG_52 <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 - // REG_52 <12> 0 CTCSSDetectionThreshold Mode - // 1 = ~0.1% - // 0 = 0.1 Hz - // REG_52 <11:6> 0x0A CTCSS found detect threshold - // REG_52 <5:0> 0x0F CTCSS lost detect threshold + // REG_52 + // + // <15> 0 Enable 120/180/240 degree shift CTCSS or 134.4Hz Tail when CDCSS mode + // 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 + // + // <12> 0 CTCSSDetectionThreshold Mode + // 1 = ~0.1% + // 0 = 0.1 Hz + // + // <11:6> 0x0A CTCSS found detect threshold + // + // <5:0> 0x0F CTCSS lost detect threshold // REG_07 <15:0> // @@ -1282,32 +1373,42 @@ void BK4819_EnableCTCSS(void) BK4819_GenTail(4); // 55Hz tone freq #endif - // REG_51 <15> 0 - // 1 = Enable TxCTCSS/CDCSS - // 0 = Disable - // REG_51 <14> 0 - // 1 = GPIO0Input for CDCSS - // 0 = Normal Mode (for BK4819 v3) - // REG_51 <13> 0 - // 1 = Transmit negative CDCSS code - // 0 = Transmit positive CDCSS code - // 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 + // 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(BK4819_REG_51, 0x904A); // 1 0 0 1 0 0 0 0 0 1001010 } @@ -1386,25 +1487,52 @@ void BK4819_SetScanFrequency(uint32_t Frequency) { BK4819_SetFrequency(Frequency); - // REG_51 <15> 0 1 = Enable TxCTCSS/CDCSS 0 = Disable - // REG_51 <14> 0 1 = GPIO0 Input 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 - - BK4819_WriteRegister(BK4819_REG_51, 0 - | 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); + // 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(BK4819_REG_51, + 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); BK4819_RX_TurnOn(); } @@ -1527,7 +1655,7 @@ void BK4819_PlayRogerMDC(void) unsigned int i; BK4819_SetAF(BK4819_AF_MUTE); - + BK4819_WriteRegister(BK4819_REG_58, 0x37C3); // FSK Enable, // RX Bandwidth FFSK 1200/1800 // 0xAA or 0x55 Preamble diff --git a/firmware.bin b/firmware.bin index a203a70..59626d0 100644 Binary files a/firmware.bin and b/firmware.bin differ diff --git a/firmware.packed.bin b/firmware.packed.bin index 0552c32..55c1ef6 100644 Binary files a/firmware.packed.bin and b/firmware.packed.bin differ