mirror of
https://github.com/kamilsss655/uv-k5-firmware-custom
synced 2024-11-22 02:08:48 +00:00
Adding compander
This commit is contained in:
parent
2fe8cd3757
commit
cc36482580
5
Makefile
5
Makefile
@ -16,6 +16,7 @@ ENABLE_TX_WHEN_AM := 0
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1
|
||||
ENABLE_MAIN_KEY_HOLD := 1
|
||||
ENABLE_BOOT_BEEPS := 1
|
||||
ENABLE_COMPANDER := 1
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1
|
||||
#ENABLE_BAND_SCOPE := 1
|
||||
|
||||
@ -132,7 +133,6 @@ ifeq ($(ENABLE_OVERLAY),1)
|
||||
endif
|
||||
|
||||
#CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD
|
||||
#CFLAGS = -O2 -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD -fdata-sections -ffunction-sections
|
||||
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m0 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c11 -MMD -fdata-sections -ffunction-sections
|
||||
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
|
||||
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
|
||||
@ -181,6 +181,9 @@ endif
|
||||
ifeq ($(ENABLE_BOOT_BEEPS),1)
|
||||
CFLAGS += -DENABLE_BOOT_BEEPS
|
||||
endif
|
||||
ifeq ($(ENABLE_COMPANDER),1)
|
||||
CFLAGS += -DENABLE_COMPANDER
|
||||
endif
|
||||
ifeq ($(ENABLE_SINGLE_VFO_CHAN),1)
|
||||
CFLAGS += -DENABLE_SINGLE_VFO_CHAN
|
||||
endif
|
||||
|
@ -27,6 +27,7 @@ ENABLE_TX_WHEN_AM := 0 allow TX when RX set to AM
|
||||
ENABLE_CTCSS_TAIL_PHASE_SHIFT := 1 use CTCSS tail phase shift rather than QS's 55Hz tone method
|
||||
ENABLE_MAIN_KEY_HOLD := 1 keys 0-9 can be held down to bypass having to press the F-key
|
||||
ENABLE_BOOT_BEEPS := 1 gives the user some audio feedback on the volume level knob position at boot-up
|
||||
ENABLE_COMPANDER := 1 compander menu option - not yet fully operational
|
||||
#ENABLE_SINGLE_VFO_CHAN := 1 not yet implemented
|
||||
#ENABLE_BAND_SCOPE := 1 not yet implemented
|
||||
```
|
||||
|
@ -56,7 +56,8 @@ void ACTION_Power(void)
|
||||
if (++gTxVfo->OUTPUT_POWER > OUTPUT_POWER_HIGH)
|
||||
gTxVfo->OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||
|
||||
gRequestSaveChannel = 1;
|
||||
//gRequestSaveChannel = 1;
|
||||
gRequestSaveChannel = 2; // TODO: fix me
|
||||
|
||||
#ifdef ENABLE_VOICE
|
||||
gAnotherVoiceID = VOICE_ID_POWER;
|
||||
@ -77,8 +78,8 @@ static void ACTION_Monitor(void)
|
||||
#endif
|
||||
|
||||
RADIO_SetupRegisters(true);
|
||||
APP_StartListening(FUNCTION_MONITOR);
|
||||
|
||||
APP_StartListening(FUNCTION_MONITOR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,9 @@
|
||||
#include "ui/inputbox.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
// TEST ONLY
|
||||
#include "driver/bk4819.h"
|
||||
|
||||
//#ifndef ARRAY_SIZE
|
||||
// #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
|
||||
//#endif
|
||||
|
16
app/menu.c
16
app/menu.c
@ -187,6 +187,9 @@ int MENU_GetLimits(uint8_t Cursor, uint8_t *pMin, uint8_t *pMax)
|
||||
*pMax = 50;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
case MENU_COMPAND:
|
||||
#endif
|
||||
case MENU_W_N:
|
||||
case MENU_BCL:
|
||||
case MENU_BEEP:
|
||||
@ -495,6 +498,13 @@ void MENU_AcceptSetting(void)
|
||||
gFlagReconfigureVfos = true;
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
case MENU_COMPAND:
|
||||
gTxVfo->Compander = gSubMenuSelection;
|
||||
//gRequestSaveChannel = 2;
|
||||
return;
|
||||
#endif
|
||||
|
||||
case MENU_1_CALL:
|
||||
gEeprom.CHAN_1_CALL = gSubMenuSelection;
|
||||
break;
|
||||
@ -821,6 +831,12 @@ void MENU_ShowCurrentSetting(void)
|
||||
gSubMenuSelection = gEeprom.MIC_SENSITIVITY;
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
case MENU_COMPAND:
|
||||
gSubMenuSelection = gTxVfo->Compander;
|
||||
return;
|
||||
#endif
|
||||
|
||||
case MENU_1_CALL:
|
||||
gSubMenuSelection = gEeprom.CHAN_1_CALL;
|
||||
break;
|
||||
|
@ -384,7 +384,7 @@ void BK4819_EnableVox(uint16_t VoxEnableThreshold, uint16_t VoxDisableThreshold)
|
||||
BK4819_WriteRegister(BK4819_REG_7A, 0x289A); // vox disable delay = 128*5 = 640ms
|
||||
|
||||
// Enable VOX
|
||||
BK4819_WriteRegister(BK4819_REG_31, REG_31_Value | 4u); // bit 2 - VOX Enable
|
||||
BK4819_WriteRegister(BK4819_REG_31, REG_31_Value | (1u << 2)); // VOX Enable
|
||||
}
|
||||
|
||||
void BK4819_SetFilterBandwidth(BK4819_FilterBandwidth_t Bandwidth)
|
||||
@ -509,16 +509,33 @@ void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency)
|
||||
void BK4819_DisableScramble(void)
|
||||
{
|
||||
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value & 0xFFFD);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value & ~(1u << 1));
|
||||
}
|
||||
|
||||
void BK4819_EnableScramble(uint8_t Type)
|
||||
{
|
||||
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value | 2u);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value | (1u << 1));
|
||||
|
||||
BK4819_WriteRegister(BK4819_REG_71, 0x68DC + (Type * 1032));
|
||||
}
|
||||
|
||||
bool BK4819_CompanderEnabled(void)
|
||||
{
|
||||
return (BK4819_ReadRegister(BK4819_REG_31) & (1u < 3)) ? true : false;
|
||||
}
|
||||
void BK4819_DisableCompander(void)
|
||||
{
|
||||
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value & ~(1u < 3));
|
||||
}
|
||||
|
||||
void BK4819_EnableCompander(void)
|
||||
{
|
||||
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
|
||||
BK4819_WriteRegister(BK4819_REG_31, Value | (1u < 3));
|
||||
}
|
||||
|
||||
void BK4819_DisableVox(void)
|
||||
{
|
||||
const uint16_t Value = BK4819_ReadRegister(BK4819_REG_31);
|
||||
@ -675,9 +692,9 @@ void BK4819_EnterDTMF_TX(bool bLocalLoopback)
|
||||
BK4819_WriteRegister(BK4819_REG_70,
|
||||
0
|
||||
| BK4819_REG_70_MASK_ENABLE_TONE1
|
||||
| (83 << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)
|
||||
| (83u << BK4819_REG_70_SHIFT_TONE1_TUNING_GAIN)
|
||||
| BK4819_REG_70_MASK_ENABLE_TONE2
|
||||
| (83 << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
|
||||
| (83u << BK4819_REG_70_SHIFT_TONE2_TUNING_GAIN));
|
||||
|
||||
BK4819_EnableTXLink();
|
||||
}
|
||||
|
@ -84,6 +84,11 @@ void BK4819_RX_TurnOn(void);
|
||||
void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency);
|
||||
void BK4819_DisableScramble(void);
|
||||
void BK4819_EnableScramble(uint8_t Type);
|
||||
|
||||
bool BK4819_CompanderEnabled(void);
|
||||
void BK4819_DisableCompander(void);
|
||||
void BK4819_EnableCompander(void);
|
||||
|
||||
void BK4819_DisableVox(void);
|
||||
void BK4819_DisableDTMF(void);
|
||||
void BK4819_EnableDTMF(void);
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "driver/st7565.h"
|
||||
#include "driver/system.h"
|
||||
|
||||
#define LCD_WIDTH 128
|
||||
#define LCD_HEIGHT 64
|
||||
|
||||
uint8_t gStatusLine[128];
|
||||
uint8_t gFrameBuffer[7][128];
|
||||
|
||||
@ -96,7 +99,7 @@ void ST7565_BlitStatusLine(void)
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
ST7565_WriteByte(0x40);
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
|
||||
ST7565_SelectColumnAndLine(4, 0);
|
||||
|
||||
@ -141,36 +144,35 @@ void ST7565_Init(void)
|
||||
|
||||
SPI_ToggleMasterMode(&SPI0->CR, false);
|
||||
|
||||
// RESET command
|
||||
ST7565_WriteByte(0xE2);
|
||||
ST7565_WriteByte(0xE2); // internal reset
|
||||
|
||||
SYSTEM_DelayMs(120);
|
||||
|
||||
ST7565_WriteByte(0xA2);
|
||||
ST7565_WriteByte(0xC0);
|
||||
ST7565_WriteByte(0xA1);
|
||||
ST7565_WriteByte(0xA6);
|
||||
ST7565_WriteByte(0xA4);
|
||||
ST7565_WriteByte(0x24);
|
||||
ST7565_WriteByte(0x81);
|
||||
ST7565_WriteByte(0x1F);
|
||||
ST7565_WriteByte(0x2B);
|
||||
ST7565_WriteByte(0xA2); // bias 9
|
||||
ST7565_WriteByte(0xC0); // com normal
|
||||
ST7565_WriteByte(0xA1); // reverse ?
|
||||
ST7565_WriteByte(0xA6); // normal ?
|
||||
ST7565_WriteByte(0xA4); // all points normal
|
||||
ST7565_WriteByte(0x24); //
|
||||
ST7565_WriteByte(0x81); // volume first ?
|
||||
ST7565_WriteByte(0x1f); // contrast ?
|
||||
ST7565_WriteByte(0x2B); // power control ?
|
||||
|
||||
SYSTEM_DelayMs(1);
|
||||
|
||||
ST7565_WriteByte(0x2E);
|
||||
ST7565_WriteByte(0x2E); // power control ?
|
||||
|
||||
SYSTEM_DelayMs(1);
|
||||
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F);
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
ST7565_WriteByte(0x2F); //
|
||||
|
||||
SYSTEM_DelayMs(40);
|
||||
|
||||
ST7565_WriteByte(0x40);
|
||||
ST7565_WriteByte(0xAF);
|
||||
ST7565_WriteByte(0x40); // start line ?
|
||||
ST7565_WriteByte(0xAF); // display on ?
|
||||
|
||||
SPI_WaitForUndocumentedTxFifoStatusBit();
|
||||
|
||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
25
radio.c
25
radio.c
@ -129,7 +129,10 @@ void RADIO_InitInfo(VFO_Info_t *pInfo, uint8_t ChannelSave, uint8_t Band, uint32
|
||||
pInfo->pRX = &pInfo->ConfigRX;
|
||||
pInfo->pTX = &pInfo->ConfigTX;
|
||||
pInfo->FREQUENCY_OF_DEVIATION = 1000000;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
pInfo->Compander = false;
|
||||
#endif
|
||||
|
||||
if (ChannelSave == (FREQ_CHANNEL_FIRST + BAND2_108MHz))
|
||||
{
|
||||
pInfo->AM_CHANNEL_MODE = true;
|
||||
@ -312,7 +315,7 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
|
||||
{
|
||||
gEeprom.VfoInfo[VFO].FrequencyReverse = false;
|
||||
gEeprom.VfoInfo[VFO].CHANNEL_BANDWIDTH = 0;
|
||||
gEeprom.VfoInfo[VFO].OUTPUT_POWER = 2;
|
||||
gEeprom.VfoInfo[VFO].OUTPUT_POWER = OUTPUT_POWER_LOW;
|
||||
gEeprom.VfoInfo[VFO].BUSY_CHANNEL_LOCK = false;
|
||||
}
|
||||
else
|
||||
@ -406,6 +409,10 @@ void RADIO_ConfigureChannel(uint8_t VFO, uint32_t Arg)
|
||||
else
|
||||
gEeprom.VfoInfo[VFO].IsAM = false;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
gEeprom.VfoInfo[VFO].Compander = false;
|
||||
#endif
|
||||
|
||||
RADIO_ConfigureSquelchAndOutputPower(pRadio);
|
||||
}
|
||||
|
||||
@ -676,6 +683,13 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
|
||||
else
|
||||
BK4819_DisableVox();
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
if (gRxVfo->Compander)
|
||||
BK4819_EnableCompander();
|
||||
else
|
||||
BK4819_DisableCompander();
|
||||
#endif
|
||||
|
||||
if (gRxVfo->IsAM || (!gRxVfo->DTMF_DECODING_ENABLE && !gSetting_KILLED))
|
||||
{
|
||||
BK4819_DisableDTMF();
|
||||
@ -757,6 +771,13 @@ void RADIO_SetTxParameters(void)
|
||||
|
||||
BK4819_SetFrequency(gCurrentVfo->pTX->Frequency);
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
if (gCurrentVfo->Compander)
|
||||
BK4819_EnableCompander();
|
||||
else
|
||||
BK4819_DisableCompander();
|
||||
#endif
|
||||
|
||||
BK4819_PrepareTransmit();
|
||||
|
||||
SYSTEM_DelayMs(10);
|
||||
|
3
radio.h
3
radio.h
@ -124,6 +124,9 @@ typedef struct VFO_Info_t
|
||||
uint8_t BUSY_CHANNEL_LOCK;
|
||||
uint8_t AM_CHANNEL_MODE;
|
||||
bool IsAM;
|
||||
#ifdef ENABLE_COMPANDER
|
||||
bool Compander;
|
||||
#endif
|
||||
char Name[16];
|
||||
} VFO_Info_t;
|
||||
|
||||
|
@ -190,7 +190,7 @@ void SETTINGS_SaveChannel(uint8_t Channel, uint8_t VFO, const VFO_Info_t *pVFO,
|
||||
OffsetVFO += (Channel - FREQ_CHANNEL_FIRST) * 32;
|
||||
}
|
||||
|
||||
if (Mode == 2 || !IS_MR_CHANNEL(Channel))
|
||||
if (Mode >= 2 || !IS_MR_CHANNEL(Channel))
|
||||
{
|
||||
uint32_t State32[2];
|
||||
uint8_t State8[8];
|
||||
|
10
ui/menu.c
10
ui/menu.c
@ -63,6 +63,9 @@ const char MenuList[][7] =
|
||||
"STE",
|
||||
"RP-STE",
|
||||
"Mic",
|
||||
#ifdef ENABLE_COMPANDER
|
||||
"Compnd",
|
||||
#endif
|
||||
"1-Call",
|
||||
"S-List",
|
||||
"SList1",
|
||||
@ -100,7 +103,7 @@ const char MenuList[][7] =
|
||||
"350-EN", // was "350EN"
|
||||
"SCR-EN", // was "SCREN"
|
||||
|
||||
"" // indicate end of list
|
||||
"" // end of list
|
||||
};
|
||||
|
||||
#if 0
|
||||
@ -315,7 +318,7 @@ void UI_DisplayMenu(void)
|
||||
sprintf(String, "+%u.%01udB", mic / 2, mic % 2);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MENU_STEP:
|
||||
sprintf(String, "%u.%02uKHz", gSubMenu_Step[gSubMenuSelection] / 100, gSubMenu_Step[gSubMenuSelection] % 100);
|
||||
break;
|
||||
@ -410,6 +413,9 @@ void UI_DisplayMenu(void)
|
||||
strcpy(String, (gSubMenuSelection == 0) ? "OFF" : "AUTO");
|
||||
break;
|
||||
|
||||
#ifdef ENABLE_COMPANDER
|
||||
case MENU_COMPAND:
|
||||
#endif
|
||||
case MENU_BCL:
|
||||
case MENU_BEEP:
|
||||
case MENU_S_ADD1:
|
||||
|
Loading…
Reference in New Issue
Block a user