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

AIRCOPY TX power reduced from full power to it's bare minimum (a couple of mW's).

This commit is contained in:
OneOfEleven 2023-10-12 15:38:30 +01:00
parent 17deb5a237
commit d1c9d184d0
10 changed files with 41 additions and 37 deletions

View File

@ -44,11 +44,14 @@ uint16_t g_aircopy_fsk_buffer[36];
uint8_t g_aircopy_send_count_down_10ms; uint8_t g_aircopy_send_count_down_10ms;
unsigned int g_aircopy_fsk_write_index; unsigned int g_aircopy_fsk_write_index;
void AIRCOPY_SendMessage(void) void AIRCOPY_SendMessage(const uint8_t request_packet)
{ {
unsigned int i; unsigned int i;
const uint16_t eeprom_addr = (uint16_t)g_aircopy_block_number * 64; const uint16_t eeprom_addr = (uint16_t)g_aircopy_block_number * 64;
// will be used to ask the TX/ing radio to resend a missing/corrupted packet
(void)request_packet;
// ********* // *********
// packet start // packet start
@ -72,11 +75,12 @@ void AIRCOPY_SendMessage(void)
for (i = 0; i < 34; i++) for (i = 0; i < 34; i++)
g_aircopy_fsk_buffer[1 + i] ^= Obfuscation[i % ARRAY_SIZE(Obfuscation)]; g_aircopy_fsk_buffer[1 + i] ^= Obfuscation[i % ARRAY_SIZE(Obfuscation)];
// TX the packet
RADIO_SetTxParameters(); RADIO_SetTxParameters();
BK4819_SetupPowerAmplifier(0, g_current_vfo->pTX->frequency); // VERY low TX power
BK4819_SendFSKData(g_aircopy_fsk_buffer); BK4819_SendFSKData(g_aircopy_fsk_buffer);
BK4819_SetupPowerAmplifier(0, 0); BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false); BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, false);
if (++g_aircopy_block_number >= g_aircopy_block_max) if (++g_aircopy_block_number >= g_aircopy_block_max)
{ {
@ -250,11 +254,11 @@ static void AIRCOPY_Key_MENU(bool key_pressed, bool key_held)
g_aircopy_fsk_write_index = 0; g_aircopy_fsk_write_index = 0;
g_aircopy_block_number = 0; g_aircopy_block_number = 0;
g_aircopy_fsk_buffer[0] = AIRCOPY_MAGIC_START;
g_aircopy_fsk_buffer[1] = 0; // block number
g_aircopy_fsk_buffer[35] = AIRCOPY_MAGIC_END;
AIRCOPY_SendMessage(); // send initial packet
//AIRCOPY_SendMessage(0xff);
g_aircopy_send_count_down_10ms = 30 / 10; // 30ms
} }
} }

View File

@ -37,7 +37,7 @@ extern uint16_t g_aircopy_fsk_buffer[36];
extern uint8_t g_aircopy_send_count_down_10ms; extern uint8_t g_aircopy_send_count_down_10ms;
extern unsigned int g_aircopy_fsk_write_index; extern unsigned int g_aircopy_fsk_write_index;
void AIRCOPY_SendMessage(void); void AIRCOPY_SendMessage(const uint8_t request_packet);
void AIRCOPY_StorePacket(void); void AIRCOPY_StorePacket(void);
void AIRCOPY_ProcessKeys(key_code_t key, bool key_pressed, bool key_held); void AIRCOPY_ProcessKeys(key_code_t key, bool key_pressed, bool key_held);

View File

@ -916,13 +916,13 @@ void APP_CheckRadioInterrupts(void)
if (interrupt_status_bits & BK4819_REG_02_SQUELCH_LOST) if (interrupt_status_bits & BK4819_REG_02_SQUELCH_LOST)
{ {
g_squelch_lost = true; g_squelch_lost = true;
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, true); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_GREEN, true);
} }
if (interrupt_status_bits & BK4819_REG_02_SQUELCH_FOUND) if (interrupt_status_bits & BK4819_REG_02_SQUELCH_FOUND)
{ {
g_squelch_lost = false; g_squelch_lost = false;
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_GREEN, false);
} }
#ifdef ENABLE_AIRCOPY #ifdef ENABLE_AIRCOPY
@ -1298,7 +1298,7 @@ void APP_Update(void)
BK4819_DisableVox(); BK4819_DisableVox();
BK4819_Sleep(); BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, false);
// Authentic device checked removed // Authentic device checked removed
@ -1562,7 +1562,7 @@ void APP_TimeSlice10ms(void)
{ {
if (--g_aircopy_send_count_down_10ms == 0) if (--g_aircopy_send_count_down_10ms == 0)
{ {
AIRCOPY_SendMessage(); AIRCOPY_SendMessage(0xff);
GUI_DisplayScreen(); GUI_DisplayScreen();
} }
} }
@ -1639,9 +1639,9 @@ void APP_TimeSlice10ms(void)
RADIO_EnableCxCSS(); RADIO_EnableCxCSS();
BK4819_SetupPowerAmplifier(0, 0); BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false); BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, false);
BK4819_Enable_AfDac_DiscMode_TxDsp(); BK4819_Enable_AfDac_DiscMode_TxDsp();
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false); BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, false);
GUI_DisplayScreen(); GUI_DisplayScreen();
} }
@ -1651,7 +1651,7 @@ void APP_TimeSlice10ms(void)
GUI_DisplayScreen(); GUI_DisplayScreen();
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, true);
RADIO_SetTxParameters(); RADIO_SetTxParameters();
BK4819_TransmitTone(true, 500); BK4819_TransmitTone(true, 500);
SYSTEM_DelayMs(2); SYSTEM_DelayMs(2);

View File

@ -364,7 +364,7 @@ static void ToggleRX(bool on) {
ToggleTX(false); ToggleTX(false);
} }
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, on); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_GREEN, on);
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
ToggleAudio(on); ToggleAudio(on);
@ -399,7 +399,7 @@ static void ToggleTX(bool on) {
ToggleRX(false); ToggleRX(false);
} }
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, on); BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, on);
if (on) { if (on) {
ToggleAudio(false); ToggleAudio(false);
@ -434,8 +434,8 @@ static void ToggleTX(bool on) {
SetF(fMeasure); SetF(fMeasure);
} }
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, !on); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, !on);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, on); BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, on);
} }
// Scan info // Scan info

View File

@ -347,7 +347,7 @@ void BK4819_SetAGC(uint8_t Value)
} }
} }
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet) void BK4819_set_GPIO_pin(BK4819_GPIO_PIN_t Pin, bool bSet)
{ {
if (bSet) if (bSet)
gBK4819_GpioOutState |= (0x40u >> Pin); gBK4819_GpioOutState |= (0x40u >> Pin);
@ -703,7 +703,7 @@ void BK4819_SetupPowerAmplifier(const uint8_t bias, const uint32_t frequency)
// 280MHz gain 1 = 1 gain 2 = 0 gain 1 = 4 gain 2 = 2 // 280MHz gain 1 = 1 gain 2 = 0 gain 1 = 4 gain 2 = 2
const uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0); const uint8_t gain = (frequency < 28000000) ? (1u << 3) | (0u << 0) : (4u << 3) | (2u << 0);
const uint8_t enable = 1; const uint8_t enable = 1;
BK4819_WriteRegister(BK4819_REG_36, (bias << 8) | (enable << 7) | (gain << 0)); BK4819_WriteRegister(BK4819_REG_36, ((uint16_t)bias << 8) | ((uint16_t)enable << 7) | ((uint16_t)gain << 0));
} }
void BK4819_SetFrequency(uint32_t Frequency) void BK4819_SetFrequency(uint32_t Frequency)
@ -845,19 +845,19 @@ void BK4819_PickRXFilterPathBasedOnFrequency(uint32_t Frequency)
{ {
if (Frequency < 28000000) if (Frequency < 28000000)
{ {
BK4819_ToggleGpioOut(BK4819_GPIO2_PIN30, true); BK4819_set_GPIO_pin(BK4819_GPIO2_PIN30, true);
BK4819_ToggleGpioOut(BK4819_GPIO3_PIN31, false); BK4819_set_GPIO_pin(BK4819_GPIO3_PIN31, false);
} }
else else
if (Frequency == 0xFFFFFFFF) if (Frequency == 0xFFFFFFFF)
{ {
BK4819_ToggleGpioOut(BK4819_GPIO2_PIN30, false); BK4819_set_GPIO_pin(BK4819_GPIO2_PIN30, false);
BK4819_ToggleGpioOut(BK4819_GPIO3_PIN31, false); BK4819_set_GPIO_pin(BK4819_GPIO3_PIN31, false);
} }
else else
{ {
BK4819_ToggleGpioOut(BK4819_GPIO2_PIN30, false); BK4819_set_GPIO_pin(BK4819_GPIO2_PIN30, false);
BK4819_ToggleGpioOut(BK4819_GPIO3_PIN31, true); BK4819_set_GPIO_pin(BK4819_GPIO3_PIN31, true);
} }
} }
@ -1203,7 +1203,7 @@ void BK4819_Conditional_RX_TurnOn_and_GPIO6_Enable(void)
{ {
if (g_rx_idle_mode) if (g_rx_idle_mode)
{ {
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, true);
BK4819_RX_TurnOn(); BK4819_RX_TurnOn();
} }
} }

View File

@ -69,7 +69,7 @@ void BK4819_WriteU16(uint16_t Data);
void BK4819_SetAGC(uint8_t Value); void BK4819_SetAGC(uint8_t Value);
void BK4819_ToggleGpioOut(BK4819_GPIO_PIN_t Pin, bool bSet); void BK4819_set_GPIO_pin(BK4819_GPIO_PIN_t Pin, bool bSet);
void BK4819_SetCDCSSCodeWord(uint32_t CodeWord); void BK4819_SetCDCSSCodeWord(uint32_t CodeWord);
void BK4819_SetCTCSSFrequency(uint32_t BaudRate); void BK4819_SetCTCSSFrequency(uint32_t BaudRate);

Binary file not shown.

Binary file not shown.

View File

@ -167,7 +167,7 @@ void FUNCTION_Select(function_type_t Function)
BK4819_DisableVox(); BK4819_DisableVox();
BK4819_Sleep(); BK4819_Sleep();
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, false);
g_update_status = true; g_update_status = true;
@ -229,7 +229,7 @@ void FUNCTION_Select(function_type_t Function)
RADIO_SetTxParameters(); RADIO_SetTxParameters();
// turn the RED LED on // turn the RED LED on
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, true); BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, true);
DTMF_Reply(); DTMF_Reply();

12
radio.c
View File

@ -589,7 +589,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
g_enable_speaker = false; g_enable_speaker = false;
BK4819_ToggleGpioOut(BK4819_GPIO0_PIN28_GREEN, false); BK4819_set_GPIO_pin(BK4819_GPIO0_PIN28_GREEN, false);
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
@ -611,11 +611,11 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
BK4819_ToggleGpioOut(BK4819_GPIO1_PIN29_RED, false); BK4819_set_GPIO_pin(BK4819_GPIO1_PIN29_RED, false);
BK4819_SetupPowerAmplifier(0, 0); BK4819_SetupPowerAmplifier(0, 0);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false); BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, false);
while (1) while (1)
{ {
@ -649,7 +649,7 @@ void RADIO_SetupRegisters(bool bSwitchToFunction0)
BK4819_PickRXFilterPathBasedOnFrequency(Frequency); BK4819_PickRXFilterPathBasedOnFrequency(Frequency);
// what does this in do ? // what does this in do ?
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, true); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, true);
// AF RX Gain and DAC // AF RX Gain and DAC
BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); // 1011 00 111010 1000 BK4819_WriteRegister(BK4819_REG_48, 0xB3A8); // 1011 00 111010 1000
@ -843,7 +843,7 @@ void RADIO_SetTxParameters(void)
g_enable_speaker = false; g_enable_speaker = false;
BK4819_ToggleGpioOut(BK4819_GPIO6_PIN2, false); BK4819_set_GPIO_pin(BK4819_GPIO6_PIN2, false);
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough=" #pragma GCC diagnostic ignored "-Wimplicit-fallthrough="
@ -876,7 +876,7 @@ void RADIO_SetTxParameters(void)
BK4819_PickRXFilterPathBasedOnFrequency(g_current_vfo->pTX->frequency); BK4819_PickRXFilterPathBasedOnFrequency(g_current_vfo->pTX->frequency);
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, true); BK4819_set_GPIO_pin(BK4819_GPIO5_PIN1, true);
SYSTEM_DelayMs(5); SYSTEM_DelayMs(5);