0
mirror of https://github.com/OneOfEleven/uv-k5-firmware-custom.git synced 2025-04-28 22:31:25 +03:00

Stopped user tuning into the 630MHz to 757MHz range - the BK4819 chip does not work there.

This commit is contained in:
OneOfEleven 2023-09-27 21:28:30 +01:00
parent 470297ea25
commit 3137a515ac
14 changed files with 131 additions and 55 deletions

View File

@ -20,7 +20,7 @@ ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
ENABLE_MAIN_KEY_HOLD := 1 ENABLE_MAIN_KEY_HOLD := 1
ENABLE_BOOT_BEEPS := 0 ENABLE_BOOT_BEEPS := 0
ENABLE_COMPANDER := 1 ENABLE_COMPANDER := 1
ENABLE_SHOW_CHARGE_LEVEL := 0 ENABLE_SHOW_CHARGE_LEVEL := 1
ENABLE_REVERSE_BAT_SYMBOL := 1 ENABLE_REVERSE_BAT_SYMBOL := 1
ENABLE_NO_SCAN_TIMEOUT := 1 ENABLE_NO_SCAN_TIMEOUT := 1
ENABLE_AM_FIX := 1 ENABLE_AM_FIX := 1

View File

@ -497,6 +497,8 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gUpdateStatus = true; gUpdateStatus = true;
} }
// ******************************************
// original setting // original setting
uint8_t lna_short = orig_lna_short; uint8_t lna_short = orig_lna_short;
uint8_t lna = orig_lna; uint8_t lna = orig_lna;
@ -505,7 +507,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
if (gRxVfo->IsAM) if (gRxVfo->IsAM)
{ // AM { // AM
/*
#ifndef ENABLE_AM_FIX #ifndef ENABLE_AM_FIX
const uint32_t rx_frequency = gRxVfo->pRX->Frequency; const uint32_t rx_frequency = gRxVfo->pRX->Frequency;
@ -526,7 +528,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
pga = 7; // 6 original, 7 increased pga = 7; // 6 original, 7 increased
} }
#endif #endif
*/
// what do these 4 other gain settings do ??? // what do these 4 other gain settings do ???
//BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011 //BK4819_WriteRegister(BK4819_REG_12, 0x037B); // 000000 11 011 11 011
//BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011 //BK4819_WriteRegister(BK4819_REG_11, 0x027B); // 000000 10 011 11 011
@ -539,6 +541,8 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
// apply the front end gain settings // apply the front end gain settings
BK4819_WriteRegister(BK4819_REG_13, ((uint16_t)lna_short << 8) | ((uint16_t)lna << 5) | ((uint16_t)mixer << 3) | ((uint16_t)pga << 0)); BK4819_WriteRegister(BK4819_REG_13, ((uint16_t)lna_short << 8) | ((uint16_t)lna << 5) | ((uint16_t)mixer << 3) | ((uint16_t)pga << 0));
// ******************************************
// AF gain - original // AF gain - original
BK4819_WriteRegister(BK4819_REG_48, BK4819_WriteRegister(BK4819_REG_48,
(11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference (11u << 12) | // ??? .. 0 to 15, doesn't seem to make any difference
@ -566,7 +570,7 @@ void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix)
gUpdateDisplay = true; gUpdateDisplay = true;
} }
void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step) uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
{ {
uint32_t Frequency = pInfo->freq_config_RX.Frequency + (Step * pInfo->StepFrequency); uint32_t Frequency = pInfo->freq_config_RX.Frequency + (Step * pInfo->StepFrequency);
@ -589,12 +593,12 @@ void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step)
if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band]) if (Frequency < LowerLimitFrequencyBandTable[pInfo->Band])
Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]); Frequency = FREQUENCY_FloorToStep(UpperLimitFrequencyBandTable[pInfo->Band], pInfo->StepFrequency, LowerLimitFrequencyBandTable[pInfo->Band]);
pInfo->freq_config_RX.Frequency = Frequency; return Frequency;
} }
static void FREQ_NextChannel(void) static void FREQ_NextChannel(void)
{ {
APP_SetFrequencyByStep(gRxVfo, gScanState); gRxVfo->freq_config_RX.Frequency = APP_SetFrequencyByStep(gRxVfo, gScanState);
RADIO_ApplyOffset(gRxVfo); RADIO_ApplyOffset(gRxVfo);
RADIO_ConfigureSquelchAndOutputPower(gRxVfo); RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
@ -1206,6 +1210,7 @@ void APP_CheckKeys(void)
while (i-- > 0) while (i-- > 0)
{ {
SYSTEM_DelayMs(1); SYSTEM_DelayMs(1);
if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT)) if (!GPIO_CheckBit(&GPIOC->DATA, GPIOC_PIN_PTT))
{ // PTT pressed { // PTT pressed
if (count > 0) if (count > 0)

View File

@ -18,14 +18,14 @@
#define APP_APP_H #define APP_APP_H
#include <stdbool.h> #include <stdbool.h>
#include "functions.h" #include "functions.h"
#include "radio.h" #include "radio.h"
void APP_EndTransmission(void); void APP_EndTransmission(void);
void CHANNEL_Next(bool bFlag, int8_t Direction); void CHANNEL_Next(bool bFlag, int8_t Direction);
void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix); void APP_StartListening(FUNCTION_Type_t Function, const bool reset_am_fix);
void APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step); uint32_t APP_SetFrequencyByStep(VFO_Info_t *pInfo, int8_t Step);
void APP_Update(void); void APP_Update(void);
void APP_TimeSlice10ms(void); void APP_TimeSlice10ms(void);
void APP_TimeSlice500ms(void); void APP_TimeSlice500ms(void);

View File

@ -294,7 +294,8 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_MAIN; gRequestDisplayScreen = DISPLAY_MAIN;
if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE)) if (IS_MR_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ { // user is entering channel number
uint16_t Channel; uint16_t Channel;
if (gInputBoxIndex != 3) if (gInputBoxIndex != 3)
@ -319,17 +320,20 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
gEeprom.MrChannel[Vfo] = (uint8_t)Channel; gEeprom.MrChannel[Vfo] = (uint8_t)Channel;
gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel; gEeprom.ScreenChannel[Vfo] = (uint8_t)Channel;
gRequestSaveVFO = true; gRequestSaveVFO = true;
gVfoConfigureMode = VFO_CONFIGURE_RELOAD; gVfoConfigureMode = VFO_CONFIGURE_RELOAD;
return; return;
} }
#ifdef ENABLE_NOAA // #ifdef ENABLE_NOAA
if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE)) // if (IS_NOT_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
#endif // #endif
{ if (IS_FREQ_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering frequency
uint32_t Frequency; uint32_t Frequency;
if (gInputBoxIndex < 6) if (gInputBoxIndex < 6)
@ -337,6 +341,7 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
#ifdef ENABLE_VOICE #ifdef ENABLE_VOICE
gAnotherVoiceID = (VOICE_ID_t)Key; gAnotherVoiceID = (VOICE_ID_t)Key;
#endif #endif
return; return;
} }
@ -344,7 +349,16 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
NUMBER_Get(gInputBox, &Frequency); NUMBER_Get(gInputBox, &Frequency);
if (gSetting_350EN || Frequency < 35000000 || Frequency >= 40000000) // if (Frequency < bx_start1_Hz || Frequency >= bx_stop2_Hz)
// { // the BK4819 chip does not do this frequency range
// }
// else
// if (Frequency >= bx_stop1_Hz && Frequency < bx_start2_Hz)
// { // the BK4819 chip does not do this frequency range
// }
// else
// if (gSetting_350EN || Frequency < 35000000 || Frequency >= 40000000)
if (RX_FREQUENCY_Check(Frequency) == 0)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
@ -376,10 +390,13 @@ static void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
} }
} }
} }
#ifdef ENABLE_NOAA #ifdef ENABLE_NOAA
else else
{ if (IS_NOAA_CHANNEL(gTxVfo->CHANNEL_SAVE))
{ // user is entering NOAA channel
uint8_t Channel; uint8_t Channel;
if (gInputBoxIndex != 2) if (gInputBoxIndex != 2)
@ -648,7 +665,7 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
if (bKeyHeld || !bKeyPressed) if (bKeyHeld || !bKeyPressed)
{ {
if (gInputBoxIndex) if (gInputBoxIndex > 0)
return; return;
if (!bKeyPressed) if (!bKeyPressed)
@ -669,11 +686,12 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
} }
else else
{ {
if (gInputBoxIndex) if (gInputBoxIndex > 0)
{ {
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL; gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return; return;
} }
gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL; gBeepToPlay = BEEP_1KHZ_60MS_OPTIONAL;
} }
@ -686,8 +704,17 @@ static void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
uint8_t Next; uint8_t Next;
if (IS_FREQ_CHANNEL(Channel)) if (IS_FREQ_CHANNEL(Channel))
{ { // step/down in frequency
APP_SetFrequencyByStep(gTxVfo, Direction); const uint32_t frequency = APP_SetFrequencyByStep(gTxVfo, Direction);
if (RX_FREQUENCY_Check(frequency) < 0)
{ // frequency not allowed
gBeepToPlay = BEEP_500HZ_60MS_DOUBLE_BEEP_OPTIONAL;
return;
}
gTxVfo->freq_config_RX.Frequency = frequency;
gRequestSaveChannel = 1; gRequestSaveChannel = 1;
return; return;
} }

View File

@ -33,7 +33,7 @@ enum GPIOA_PINS {
GPIOA_PIN_I2C_SDA = 11, // Shared with keyboard! GPIOA_PIN_I2C_SDA = 11, // Shared with keyboard!
GPIOA_PIN_VOICE_0 = 12, // Shared with keyboard! GPIOA_PIN_VOICE_0 = 12, // Shared with keyboard!
GPIOA_PIN_VOICE_1 = 13, // Shared with keyboard! GPIOA_PIN_VOICE_1 = 13 // Shared with keyboard!
}; };
enum GPIOB_PINS { enum GPIOB_PINS {
@ -45,7 +45,7 @@ enum GPIOB_PINS {
GPIOB_PIN_SWD_IO = 11, // Shared with ST7565! GPIOB_PIN_SWD_IO = 11, // Shared with ST7565!
GPIOB_PIN_SWD_CLK = 14, GPIOB_PIN_SWD_CLK = 14,
GPIOB_PIN_BK1080 = 15, GPIOB_PIN_BK1080 = 15
}; };
enum GPIOC_PINS { enum GPIOC_PINS {
@ -54,10 +54,8 @@ enum GPIOC_PINS {
GPIOC_PIN_BK4819_SDA = 2, GPIOC_PIN_BK4819_SDA = 2,
GPIOC_PIN_FLASHLIGHT = 3, GPIOC_PIN_FLASHLIGHT = 3,
GPIOC_PIN_AUDIO_PATH = 4, GPIOC_PIN_AUDIO_PATH = 4,
GPIOC_PIN_PTT = 5
GPIOC_PIN_PTT = 5,
}; };
void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit); void GPIO_ClearBit(volatile uint32_t *pReg, uint8_t Bit);

Binary file not shown.

Binary file not shown.

View File

@ -18,8 +18,13 @@
#include "misc.h" #include "misc.h"
#include "settings.h" #include "settings.h"
const uint32_t bx_min_Hz = 1800000; // 18MHz // the BK4819 has 2 bands it covers, 18MHz ~ 630MHz and 760MHz ~ 1300MHz
const uint32_t bx_max_Hz = 130000000; // 1300MHz
const uint32_t bx_start1_Hz = 1800000; // 18MHz
const uint32_t bx_stop1_Hz = 1800000; // 630MHz
const uint32_t bx_start2_Hz = 76000000; // 760MHz
const uint32_t bx_stop2_Hz = 130000000; // 1300MHz
const uint32_t LowerLimitFrequencyBandTable[7] = const uint32_t LowerLimitFrequencyBandTable[7] =
{ {
@ -166,8 +171,8 @@ uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
return Lower + (Step * Index); return Lower + (Step * Index);
} }
/*
int FREQUENCY_Check(VFO_Info_t *pInfo) int TX_FREQUENCY_Check(VFO_Info_t *pInfo)
{ // return '0' if TX frequency is allowed { // return '0' if TX frequency is allowed
// otherwise return '-1' // otherwise return '-1'
@ -177,6 +182,15 @@ int FREQUENCY_Check(VFO_Info_t *pInfo)
if (pInfo->CHANNEL_SAVE > FREQ_CHANNEL_LAST) if (pInfo->CHANNEL_SAVE > FREQ_CHANNEL_LAST)
return -1; return -1;
#endif #endif
*/
int TX_FREQUENCY_Check(const uint32_t Frequency)
{ // return '0' if TX frequency is allowed
// otherwise return '-1'
if (Frequency < LowerLimitFrequencyBandTable[0] || Frequency > UpperLimitFrequencyBandTable[6])
return -1;
if (Frequency >= 63000000 && Frequency < 75700000)
return -1;
switch (gSetting_F_LOCK) switch (gSetting_F_LOCK)
{ {
@ -233,3 +247,15 @@ int FREQUENCY_Check(VFO_Info_t *pInfo)
// dis-allowed TX frequency // dis-allowed TX frequency
return -1; return -1;
} }
int RX_FREQUENCY_Check(const uint32_t Frequency)
{ // return '0' if RX frequency is allowed
// otherwise return '-1'
if (Frequency < LowerLimitFrequencyBandTable[0] || Frequency > UpperLimitFrequencyBandTable[6])
return -1;
if (Frequency >= 63000000 && Frequency < 75700000)
return -1;
return 0; // OK frequency
}

View File

@ -21,8 +21,11 @@
#include "radio.h" #include "radio.h"
extern const uint32_t bx_min_Hz; extern const uint32_t bx_start1_Hz;
extern const uint32_t bx_max_Hz; extern const uint32_t bx_stop1_Hz;
extern const uint32_t bx_start2_Hz;
extern const uint32_t bx_stop2_Hz;
enum FREQUENCY_Band_t enum FREQUENCY_Band_t
{ {
@ -50,7 +53,10 @@ extern const uint16_t StepFrequencyTable[7];
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency); FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency);
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency); uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, int32_t LowerLimit, int32_t Middle, int32_t UpperLimit, int32_t Frequency);
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower); uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower);
int FREQUENCY_Check(VFO_Info_t *pInfo);
//int TX_FREQUENCY_Check(VFO_Info_t *pInfo);
int TX_FREQUENCY_Check(const uint32_t Frequency);
int RX_FREQUENCY_Check(const uint32_t Frequency);
#endif #endif

View File

@ -139,6 +139,7 @@ void FUNCTION_Select(FUNCTION_Type_t Function)
BK4819_DisableVox(); BK4819_DisableVox();
BK4819_Sleep(); BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false);
gUpdateStatus = true; gUpdateStatus = true;

View File

@ -955,13 +955,17 @@ void RADIO_PrepareTX(void)
// disable the TX when VFO/Channel is set to AM // disable the TX when VFO/Channel is set to AM
// the radio does NOT do AM, the adverts are false // the radio does NOT do AM, the adverts are false
if (gCurrentVfo->IsAM) if (gCurrentVfo->IsAM)
{
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
}
else else
#endif #endif
if (!gSetting_TX_EN) if (!gSetting_TX_EN)
{
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
}
else else
if (!FREQUENCY_Check(gCurrentVfo)) if (TX_FREQUENCY_Check(gCurrentVfo->pTX->Frequency) == 0 && gCurrentVfo->CHANNEL_SAVE <= FREQ_CHANNEL_LAST)
{ {
if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE) if (gCurrentVfo->BUSY_CHANNEL_LOCK && gCurrentFunction == FUNCTION_RECEIVE)
State = VFO_STATE_BUSY; State = VFO_STATE_BUSY;
@ -976,7 +980,9 @@ void RADIO_PrepareTX(void)
goto Skip; goto Skip;
} }
else else
{
State = VFO_STATE_TX_DISABLE; State = VFO_STATE_TX_DISABLE;
}
RADIO_SetVfoState(State); RADIO_SetVfoState(State);

View File

@ -23,12 +23,12 @@ uint8_t gInputBoxIndex;
void INPUTBOX_Append(char Digit) void INPUTBOX_Append(char Digit)
{ {
if (gInputBoxIndex == 0)
memset(gInputBox, 10, sizeof(gInputBox));
else
if (gInputBoxIndex >= sizeof(gInputBox)) if (gInputBoxIndex >= sizeof(gInputBox))
return; return;
if (gInputBoxIndex == 0)
memset(gInputBox, 10, sizeof(gInputBox));
gInputBox[gInputBoxIndex++] = Digit; gInputBox[gInputBoxIndex++] = Digit;
} }

View File

@ -293,8 +293,15 @@ void UI_DisplayMain(void)
{ {
const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"}; const char *state_list[] = {"", "BUSY", "BAT LOW", "TX DISABLE", "TIMEOUT", "ALARM", "VOLT HIGH"};
if (State >= 0 && State < ARRAY_SIZE(state_list)) if (State >= 0 && State < ARRAY_SIZE(state_list))
{
UI_PrintString(state_list[State], 31, 0, Line, 8); UI_PrintString(state_list[State], 31, 0, Line, 8);
} }
//else
//{
// sprintf(String, "State %u ?", State);
// UI_PrintString(String, 31, 0, Line, 8);
//}
}
else else
if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num) if (gInputBoxIndex > 0 && IS_FREQ_CHANNEL(gEeprom.ScreenChannel[vfo_num]) && gEeprom.TX_CHANNEL == vfo_num)
{ // user entering a frequency { // user entering a frequency