mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-04-28 22:31:25 +03:00
fix sqrt, turn mic off before mdc bot starts, adjust bot timing
This commit is contained in:
parent
4153389778
commit
9eb3f765e0
2
Makefile
2
Makefile
@ -70,7 +70,7 @@ ENABLE_RX_SIGNAL_BAR := 0
|
|||||||
# Tx Timeout Bar 0.2 kB
|
# Tx Timeout Bar 0.2 kB
|
||||||
ENABLE_TX_TIMEOUT_BAR := 0
|
ENABLE_TX_TIMEOUT_BAR := 0
|
||||||
# Tx Audio Bar 0.3 kB
|
# Tx Audio Bar 0.3 kB
|
||||||
ENABLE_TX_AUDIO_BAR := 0
|
ENABLE_TX_AUDIO_BAR := 1
|
||||||
# Side Button Menu 0.3 kB
|
# Side Button Menu 0.3 kB
|
||||||
ENABLE_SIDE_BUTT_MENU := 1
|
ENABLE_SIDE_BUTT_MENU := 1
|
||||||
# Key Lock 0.4 kB
|
# Key Lock 0.4 kB
|
||||||
|
184
driver/bk4819.c
184
driver/bk4819.c
@ -2226,75 +2226,8 @@ void BK4819_reset_fsk(void)
|
|||||||
// create the MDC1200 packet
|
// create the MDC1200 packet
|
||||||
const unsigned int size = MDC1200_encode_single_packet(packet, op, arg, id);
|
const unsigned int size = MDC1200_encode_single_packet(packet, op, arg, id);
|
||||||
|
|
||||||
BK4819_ExitTxMute();
|
//BK4819_ExitTxMute();
|
||||||
|
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
|
||||||
#if 1
|
|
||||||
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
|
||||||
#else
|
|
||||||
// let the user hear the FSK being sent
|
|
||||||
BK4819_SetAF(BK4819_AF_BEEP);
|
|
||||||
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// *******************
|
|
||||||
// need to turn off CTCSS/CDCSS during FFSK
|
|
||||||
|
|
||||||
// REG_51
|
|
||||||
//
|
|
||||||
// <15> 1 = Enable TxCTCSS/CDCSS
|
|
||||||
// 0 = Disable
|
|
||||||
//
|
|
||||||
const uint16_t css_val = BK4819_ReadRegister(0x51);
|
|
||||||
BK4819_WriteRegister(0x51, 0);
|
|
||||||
|
|
||||||
// *******************************************
|
|
||||||
|
|
||||||
// REG_40
|
|
||||||
//
|
|
||||||
// <15:13> 0 ???
|
|
||||||
// 0 ~ 7
|
|
||||||
//
|
|
||||||
// <12> 1 enable RF TX deviation
|
|
||||||
// 1 = enable
|
|
||||||
// 0 = disable
|
|
||||||
//
|
|
||||||
// <11:0> 0x04D0 RF TX deviation tuning (both in-band signal and sub-audio)
|
|
||||||
// 0 ~ 4095
|
|
||||||
|
|
||||||
const uint16_t tx_dev = BK4819_ReadRegister(0x40);
|
|
||||||
// BK4819_WriteRegister(0x40, (0u << 12) | (1232 << 0)); // 000 0 010011010000
|
|
||||||
BK4819_WriteRegister(0x40, (tx_dev & 0xf000) | (1000 << 0)); // reduce the deviation a little
|
|
||||||
|
|
||||||
// REG_2B 0
|
|
||||||
//
|
|
||||||
// <10> 0 AF RX HPF 300Hz filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
// <9> 0 AF RX LPF 3kHz filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
// <8> 0 AF RX de-emphasis filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
// <2> 0 AF TX HPF 300Hz filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
// <1> 0 AF TX LPF filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
// <0> 0 AF TX pre-emphasis filter
|
|
||||||
// 0 = enable
|
|
||||||
// 1 = disable
|
|
||||||
//
|
|
||||||
BK4819_WriteRegister(0x2B, (1u << 2) | (1u << 0));
|
|
||||||
|
|
||||||
// *******************************************
|
|
||||||
|
|
||||||
BK4819_WriteRegister(0x30,
|
BK4819_WriteRegister(0x30,
|
||||||
(1u << 15) | // enable VCO calibration
|
(1u << 15) | // enable VCO calibration
|
||||||
@ -2308,10 +2241,52 @@ void BK4819_reset_fsk(void)
|
|||||||
(1u << 1) | // enable TX DSP
|
(1u << 1) | // enable TX DSP
|
||||||
(0u << 0)); // disable RX DSP
|
(0u << 0)); // disable RX DSP
|
||||||
|
|
||||||
SYSTEM_DelayMs(10);
|
#if 1
|
||||||
|
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||||
|
BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
#else
|
||||||
|
// let the user hear the FSK being sent
|
||||||
|
BK4819_SetAF(BK4819_AF_BEEP);
|
||||||
|
GPIO_SetBit(&GPIOC->DATA, GPIOC_PIN_SPEAKER);
|
||||||
|
#endif
|
||||||
|
SYSTEM_DelayMs(2);
|
||||||
|
|
||||||
|
// REG_51
|
||||||
|
//
|
||||||
|
// <15> TxCTCSS/CDCSS 0 = disable 1 = Enable
|
||||||
|
//
|
||||||
|
// turn off CTCSS/CDCSS during FFSK
|
||||||
|
const uint16_t css_val = BK4819_ReadRegister(0x51);
|
||||||
|
BK4819_WriteRegister(0x51, 0);
|
||||||
|
|
||||||
|
// REG_40
|
||||||
|
//
|
||||||
|
// <15:13> 0 ??? 0 ~ 7
|
||||||
|
// <12> 1 enable RF TX deviation 0 = disable 1 = enable
|
||||||
|
// <11:0> 0x04D0 RF TX deviation tuning (both in-band signal and sub-audio) 0 ~ 4095
|
||||||
|
//
|
||||||
|
// reduce the deviation a little
|
||||||
|
//
|
||||||
|
const uint16_t tx_dev = BK4819_ReadRegister(0x40);
|
||||||
|
//BK4819_WriteRegister(0x40, (0u << 12) | (1232 << 0)); // 000 0 010011010000
|
||||||
|
BK4819_WriteRegister(0x40, (tx_dev & 0xf000) | (1000 << 0));
|
||||||
|
|
||||||
|
// REG_2B 0
|
||||||
|
//
|
||||||
|
// <10> 0 AF RX HPF 300Hz filter 0 = enable 1 = disable
|
||||||
|
// <9> 0 AF RX LPF 3kHz filter 0 = enable 1 = disable
|
||||||
|
// <8> 0 AF RX de-emphasis filter 0 = enable 1 = disable
|
||||||
|
// <2> 0 AF TX HPF 300Hz filter 0 = enable 1 = disable
|
||||||
|
// <1> 0 AF TX LPF filter 0 = enable 1 = disable
|
||||||
|
// <0> 0 AF TX pre-emphasis filter 0 = enable 1 = disable
|
||||||
|
//
|
||||||
|
// disable the 300Hz HPF and FM pre-emphasis filter
|
||||||
|
//
|
||||||
|
BK4819_WriteRegister(0x2B, (1u << 2) | (1u << 0));
|
||||||
|
|
||||||
// *******************************************
|
// *******************************************
|
||||||
|
// setup the FFSK modem as best we can for MDC1200
|
||||||
|
|
||||||
// MDC1200 uses 1200/1800 Hz FSK tone frequencies 1200 bits/s
|
// MDC1200 uses 1200/1800 Hz FSK tone frequencies 1200 bits/s
|
||||||
//
|
//
|
||||||
BK4819_WriteRegister(0x58, // 0x37C3); // 001 101 11 11 00 001 1
|
BK4819_WriteRegister(0x58, // 0x37C3); // 001 101 11 11 00 001 1
|
||||||
@ -2397,27 +2372,13 @@ void BK4819_reset_fsk(void)
|
|||||||
|
|
||||||
// REG_59
|
// REG_59
|
||||||
//
|
//
|
||||||
// <15> 0 TX FIFO
|
// <15> 0 TX FIFO 1 = clear
|
||||||
// 1 = clear
|
// <14> 0 RX FIFO 1 = clear
|
||||||
//
|
// <13> 0 FSK Scramble 1 = Enable
|
||||||
// <14> 0 RX FIFO
|
// <12> 0 FSK RX 1 = Enable
|
||||||
// 1 = clear
|
// <11> 0 FSK TX 1 = Enable
|
||||||
//
|
// <10> 0 FSK data when RX 1 = Invert
|
||||||
// <13> 0 FSK Scramble
|
// <9> 0 FSK data when TX 1 = Invert
|
||||||
// 1 = Enable
|
|
||||||
//
|
|
||||||
// <12> 0 FSK RX
|
|
||||||
// 1 = Enable
|
|
||||||
//
|
|
||||||
// <11> 0 FSK TX
|
|
||||||
// 1 = Enable
|
|
||||||
//
|
|
||||||
// <10> 0 FSK data when RX
|
|
||||||
// 1 = Invert
|
|
||||||
//
|
|
||||||
// <9> 0 FSK data when TX
|
|
||||||
// 1 = Invert
|
|
||||||
//
|
|
||||||
// <8> 0 ???
|
// <8> 0 ???
|
||||||
//
|
//
|
||||||
// <7:4> 0 FSK preamble length selection
|
// <7:4> 0 FSK preamble length selection
|
||||||
@ -2432,16 +2393,16 @@ void BK4819_reset_fsk(void)
|
|||||||
//
|
//
|
||||||
// <2:0> 0 ???
|
// <2:0> 0 ???
|
||||||
//
|
//
|
||||||
fsk_reg59 = (0u << 15) | // 0 ~ 1 1 = clear TX FIFO
|
fsk_reg59 = (0u << 15) | // 0/1 1 = clear TX FIFO
|
||||||
(0u << 14) | // 0 ~ 1 1 = clear RX FIFO
|
(0u << 14) | // 0/1 1 = clear RX FIFO
|
||||||
(0u << 13) | // 0 ~ 1 1 = scramble
|
(0u << 13) | // 0/1 1 = scramble
|
||||||
(0u << 12) | // 0 ~ 1 1 = enable RX
|
(0u << 12) | // 0/1 1 = enable RX
|
||||||
(0u << 11) | // 0 ~ 1 1 = enable TX
|
(0u << 11) | // 0/1 1 = enable TX
|
||||||
(0u << 10) | // 0 ~ 1 1 = invert data when RX
|
(0u << 10) | // 0/1 1 = invert data when RX
|
||||||
(0u << 9) | // 0 ~ 1 1 = invert data when TX
|
(0u << 9) | // 0/1 1 = invert data when TX
|
||||||
(0u << 8) | // 0 ~ 1 ???
|
(0u << 8) | // 0/1 ???
|
||||||
(0u << 4) | // 0 ~ 15 preamble length
|
(1u << 4) | // 0 ~ 15 preamble length
|
||||||
(0u << 3) | // 0 ~ 1 sync length
|
(1u << 3) | // 0/1 sync length
|
||||||
(0u << 0); // 0 ~ 7 ???
|
(0u << 0); // 0 ~ 7 ???
|
||||||
|
|
||||||
// Set entire packet length (not including the pre-amble and sync bytes we can't seem to disable)
|
// Set entire packet length (not including the pre-amble and sync bytes we can't seem to disable)
|
||||||
@ -2470,9 +2431,7 @@ void BK4819_reset_fsk(void)
|
|||||||
//
|
//
|
||||||
// <15:7> ???
|
// <15:7> ???
|
||||||
//
|
//
|
||||||
// <6> 1 CRC option enable
|
// <6> 1 CRC option enable 0 = disable 1 = enable
|
||||||
// 0 = disable
|
|
||||||
// 1 = enable
|
|
||||||
//
|
//
|
||||||
// <5:0> ???
|
// <5:0> ???
|
||||||
//
|
//
|
||||||
@ -2501,9 +2460,9 @@ void BK4819_reset_fsk(void)
|
|||||||
// 173ms for PTT ID, acks, emergency
|
// 173ms for PTT ID, acks, emergency
|
||||||
// 266ms for call alert and sel-calls
|
// 266ms for call alert and sel-calls
|
||||||
|
|
||||||
// allow up to 350ms for the TX to complete
|
// allow up to 310ms for the TX to complete
|
||||||
// if it takes any longer then somethings gone wrong, we shut the TX down
|
// if it takes any longer then somethings gone wrong, we shut the TX down
|
||||||
unsigned int timeout = 350 / 5;
|
unsigned int timeout = 310 / 5;
|
||||||
|
|
||||||
while (timeout-- > 0)
|
while (timeout-- > 0)
|
||||||
{
|
{
|
||||||
@ -2535,11 +2494,11 @@ void BK4819_reset_fsk(void)
|
|||||||
// restore the CTCSS/CDCSS setting
|
// restore the CTCSS/CDCSS setting
|
||||||
BK4819_WriteRegister(0x51, css_val);
|
BK4819_WriteRegister(0x51, css_val);
|
||||||
|
|
||||||
// ****************
|
//BK4819_EnterTxMute();
|
||||||
|
BK4819_WriteRegister(0x50, 0xBB20); // 1011 1011 0010 0000
|
||||||
|
|
||||||
BK4819_EnterTxMute();
|
//BK4819_SetAF(BK4819_AF_MUTE);
|
||||||
|
BK4819_WriteRegister(0x47, (6u << 12) | (BK4819_AF_MUTE << 8) | (1u << 6) | (0u << 0));
|
||||||
BK4819_SetAF(BK4819_AF_MUTE);
|
|
||||||
|
|
||||||
BK4819_WriteRegister(0x30,
|
BK4819_WriteRegister(0x30,
|
||||||
(1u << 15) | // enable VCO calibration
|
(1u << 15) | // enable VCO calibration
|
||||||
@ -2553,7 +2512,8 @@ void BK4819_reset_fsk(void)
|
|||||||
(1u << 1) | // enable TX DSP
|
(1u << 1) | // enable TX DSP
|
||||||
(0u << 0)); // disable RX DSP
|
(0u << 0)); // disable RX DSP
|
||||||
|
|
||||||
BK4819_ExitTxMute();
|
//BK4819_ExitTxMute();
|
||||||
|
BK4819_WriteRegister(0x50, 0x3B20); // 0011 1011 0010 0000
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
BIN
firmware.bin
BIN
firmware.bin
Binary file not shown.
Binary file not shown.
35
functions.c
35
functions.c
@ -280,18 +280,45 @@ void FUNCTION_Select(function_type_t Function)
|
|||||||
#ifdef ENABLE_MDC1200
|
#ifdef ENABLE_MDC1200
|
||||||
if (g_current_vfo->mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->mdc1200_mode == MDC1200_MODE_BOTH)
|
if (g_current_vfo->mdc1200_mode == MDC1200_MODE_BOT || g_current_vfo->mdc1200_mode == MDC1200_MODE_BOTH)
|
||||||
{
|
{
|
||||||
SYSTEM_DelayMs(150);
|
BK4819_WriteRegister(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
|
||||||
|
(0u << 2) | // disable MIC ADC
|
||||||
|
(1u << 1) | // enable TX DSP
|
||||||
|
(0u << 0)); // disable RX DSP
|
||||||
|
SYSTEM_DelayMs(120);
|
||||||
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.mdc1200_id);
|
BK4819_send_MDC1200(MDC1200_OP_CODE_PTT_ID, 0x80, g_eeprom.mdc1200_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
|
if (g_current_vfo->dtmf_ptt_id_tx_mode == PTT_ID_APOLLO)
|
||||||
|
{
|
||||||
BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0);
|
BK4819_PlayTone(APOLLO_TONE1_HZ, APOLLO_TONE_MS, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
BK4819_WriteRegister(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_current_vfo->scrambling_type > 0 && g_setting_scramble_enable)
|
||||||
|
{
|
||||||
|
BK4819_EnableScramble(g_current_vfo->scrambling_type - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_current_vfo->scrambling_type > 0 && g_setting_scramble_enable)
|
|
||||||
BK4819_EnableScramble(g_current_vfo->scrambling_type - 1);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUNCTION_PANADAPTER:
|
case FUNCTION_PANADAPTER:
|
||||||
|
27
ui/main.c
27
ui/main.c
@ -158,22 +158,19 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
|
|||||||
|
|
||||||
#ifdef ENABLE_TX_AUDIO_BAR
|
#ifdef ENABLE_TX_AUDIO_BAR
|
||||||
|
|
||||||
uint32_t sqrt16(uint32_t value)
|
// linear search, ascending, using addition
|
||||||
{ // return square root of 'value'
|
uint16_t isqrt(const uint32_t y)
|
||||||
unsigned int shift = 16; // this is the number of bits supplied in 'value' .. 2 ~ 32
|
{
|
||||||
uint32_t bit = 1u << --shift;
|
uint16_t L = 0;
|
||||||
uint32_t sqrti = 0;
|
uint32_t a = 1;
|
||||||
while (bit)
|
uint32_t d = 3;
|
||||||
|
while (a <= y)
|
||||||
{
|
{
|
||||||
const uint32_t temp = ((sqrti << 1) | bit) << shift--;
|
a += d; // (a + 1) ^ 2
|
||||||
if (value >= temp)
|
d += 2;
|
||||||
{
|
L += 1;
|
||||||
value -= temp;
|
|
||||||
sqrti |= bit;
|
|
||||||
}
|
|
||||||
bit >>= 1;
|
|
||||||
}
|
}
|
||||||
return sqrti;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UI_DisplayAudioBar(const bool now)
|
bool UI_DisplayAudioBar(const bool now)
|
||||||
@ -223,7 +220,7 @@ void UI_drawBars(uint8_t *p, const unsigned int level)
|
|||||||
|
|
||||||
// make non-linear to make more sensitive at low values
|
// make non-linear to make more sensitive at low values
|
||||||
const unsigned int level = voice_amp * 8;
|
const unsigned int level = voice_amp * 8;
|
||||||
const unsigned int sqrt_level = sqrt16((level < 65535) ? level : 65535);
|
const unsigned int sqrt_level = isqrt((level < 65535) ? level : 65535);
|
||||||
const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
|
const unsigned int len = (sqrt_level <= bar_width) ? sqrt_level : bar_width;
|
||||||
|
|
||||||
draw_bar(p_line + bar_x, len, bar_width);
|
draw_bar(p_line + bar_x, len, bar_width);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user