mirror of
https://github.com/OneOfEleven/uv-k5-firmware-custom.git
synced 2025-06-20 15:08:37 +03:00
Renamed lots more
This commit is contained in:
140
app/aircopy.c
140
app/aircopy.c
@ -30,99 +30,99 @@
|
||||
|
||||
static const uint16_t Obfuscation[8] = {0x6C16, 0xE614, 0x912E, 0x400D, 0x3521, 0x40D5, 0x0313, 0x80E9};
|
||||
|
||||
AIRCOPY_State_t gAircopyState;
|
||||
uint16_t gAirCopyBlockNumber;
|
||||
uint16_t gErrorsDuringAirCopy;
|
||||
uint8_t gAirCopyIsSendMode;
|
||||
aircopy_state_t g_aircopy_state;
|
||||
uint16_t g_air_copy_block_number;
|
||||
uint16_t g_errors_during_air_copyy;
|
||||
uint8_t g_air_copy_is_send_mode;
|
||||
|
||||
uint16_t g_FSK_Buffer[36];
|
||||
uint16_t g_fsk_buffer[36];
|
||||
|
||||
void AIRCOPY_SendMessage(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
g_FSK_Buffer[1] = (gAirCopyBlockNumber & 0x3FF) << 6;
|
||||
g_fsk_buffer[1] = (g_air_copy_block_number & 0x3FF) << 6;
|
||||
|
||||
EEPROM_ReadBuffer(g_FSK_Buffer[1], &g_FSK_Buffer[2], 64);
|
||||
EEPROM_ReadBuffer(g_fsk_buffer[1], &g_fsk_buffer[2], 64);
|
||||
|
||||
g_FSK_Buffer[34] = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||
g_fsk_buffer[34] = CRC_Calculate(&g_fsk_buffer[1], 2 + 64);
|
||||
|
||||
for (i = 0; i < 34; i++)
|
||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
g_fsk_buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
|
||||
if (++gAirCopyBlockNumber >= 0x78)
|
||||
gAircopyState = AIRCOPY_COMPLETE;
|
||||
if (++g_air_copy_block_number >= 0x78)
|
||||
g_aircopy_state = AIRCOPY_COMPLETE;
|
||||
|
||||
RADIO_SetTxParameters();
|
||||
|
||||
BK4819_SendFSKData(g_FSK_Buffer);
|
||||
BK4819_SendFSKData(g_fsk_buffer);
|
||||
BK4819_SetupPowerAmplifier(0, 0);
|
||||
BK4819_ToggleGpioOut(BK4819_GPIO5_PIN1, false);
|
||||
|
||||
gAircopySendCountdown = 30;
|
||||
g_air_copy_send_count_down = 30;
|
||||
}
|
||||
|
||||
void AIRCOPY_StorePacket(void)
|
||||
{
|
||||
uint16_t Status;
|
||||
|
||||
if (gFSKWriteIndex < 36)
|
||||
if (g_fsk_wite_index < 36)
|
||||
return;
|
||||
|
||||
gFSKWriteIndex = 0;
|
||||
gUpdateDisplay = true;
|
||||
Status = BK4819_ReadRegister(BK4819_REG_0B);
|
||||
g_fsk_wite_index = 0;
|
||||
g_update_display = true;
|
||||
Status = BK4819_ReadRegister(BK4819_REG_0B);
|
||||
BK4819_PrepareFSKReceive();
|
||||
|
||||
// Doc says bit 4 should be 1 = CRC OK, 0 = CRC FAIL, but original firmware checks for FAIL.
|
||||
|
||||
if ((Status & 0x0010U) == 0 && g_FSK_Buffer[0] == 0xABCD && g_FSK_Buffer[35] == 0xDCBA)
|
||||
if ((Status & 0x0010U) == 0 && g_fsk_buffer[0] == 0xABCD && g_fsk_buffer[35] == 0xDCBA)
|
||||
{
|
||||
uint16_t CRC;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < 34; i++)
|
||||
g_FSK_Buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
g_fsk_buffer[i + 1] ^= Obfuscation[i % 8];
|
||||
|
||||
CRC = CRC_Calculate(&g_FSK_Buffer[1], 2 + 64);
|
||||
if (g_FSK_Buffer[34] == CRC)
|
||||
CRC = CRC_Calculate(&g_fsk_buffer[1], 2 + 64);
|
||||
if (g_fsk_buffer[34] == CRC)
|
||||
{
|
||||
const uint16_t *pData;
|
||||
uint16_t Offset;
|
||||
|
||||
Offset = g_FSK_Buffer[1];
|
||||
Offset = g_fsk_buffer[1];
|
||||
if (Offset < 0x1E00)
|
||||
{
|
||||
pData = &g_FSK_Buffer[2];
|
||||
pData = &g_fsk_buffer[2];
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
EEPROM_WriteBuffer(Offset, pData);
|
||||
pData += 4;
|
||||
Offset += 8;
|
||||
}
|
||||
|
||||
if (Offset == 0x1E00)
|
||||
gAircopyState = AIRCOPY_COMPLETE;
|
||||
|
||||
gAirCopyBlockNumber++;
|
||||
if (Offset == 0x1E00)
|
||||
g_aircopy_state = AIRCOPY_COMPLETE;
|
||||
|
||||
g_air_copy_block_number++;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
gErrorsDuringAirCopy++;
|
||||
g_errors_during_air_copyy++;
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
static void AIRCOPY_Key_DIGITS(key_code_t Key, bool key_pressed, bool key_held)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
if (!key_held && key_pressed)
|
||||
{
|
||||
uint32_t Frequency;
|
||||
unsigned int i;
|
||||
|
||||
INPUTBOX_Append(Key);
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
if (gInputBoxIndex < 6)
|
||||
g_request_display_screen = DISPLAY_AIRCOPY;
|
||||
if (g_input_box_index < 6)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
@ -130,24 +130,24 @@ static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
return;
|
||||
}
|
||||
|
||||
gInputBoxIndex = 0;
|
||||
g_input_box_index = 0;
|
||||
|
||||
NUMBER_Get(gInputBox, &Frequency);
|
||||
NUMBER_Get(g_input_box, &Frequency);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(frequencyBandTable); i++)
|
||||
for (i = 0; i < ARRAY_SIZE(FREQ_BAND_TABLE); i++)
|
||||
{
|
||||
if (Frequency >= frequencyBandTable[i].lower && Frequency < frequencyBandTable[i].upper)
|
||||
if (Frequency >= FREQ_BAND_TABLE[i].lower && Frequency < FREQ_BAND_TABLE[i].upper)
|
||||
{
|
||||
#ifdef ENABLE_VOICE
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
g_another_voice_id = (voice_id_t)Key;
|
||||
#endif
|
||||
gRxVfo->band = i;
|
||||
Frequency += 75;
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, gRxVfo->step_freq, 0);
|
||||
gRxVfo->freq_config_rx.frequency = Frequency;
|
||||
gRxVfo->freq_config_tx.frequency = Frequency;
|
||||
RADIO_ConfigureSquelchAndOutputPower(gRxVfo);
|
||||
gCurrentVfo = gRxVfo;
|
||||
g_rx_vfo->band = i;
|
||||
Frequency += 75;
|
||||
Frequency = FREQUENCY_FloorToStep(Frequency, g_rx_vfo->step_freq, 0);
|
||||
g_rx_vfo->freq_config_rx.frequency = Frequency;
|
||||
g_rx_vfo->freq_config_tx.frequency = Frequency;
|
||||
RADIO_ConfigureSquelchAndOutputPower(g_rx_vfo);
|
||||
g_current_vfo = g_rx_vfo;
|
||||
RADIO_SetupRegisters(true);
|
||||
BK4819_SetupAircopy();
|
||||
BK4819_ResetFSK();
|
||||
@ -155,54 +155,54 @@ static void AIRCOPY_Key_DIGITS(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
}
|
||||
}
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
g_request_display_screen = DISPLAY_AIRCOPY;
|
||||
}
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_EXIT(bool bKeyPressed, bool bKeyHeld)
|
||||
static void AIRCOPY_Key_EXIT(bool key_pressed, bool key_held)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
if (!key_held && key_pressed)
|
||||
{
|
||||
if (gInputBoxIndex == 0)
|
||||
if (g_input_box_index == 0)
|
||||
{
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gErrorsDuringAirCopy = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gAirCopyIsSendMode = 0;
|
||||
g_fsk_wite_index = 0;
|
||||
g_air_copy_block_number = 0;
|
||||
g_errors_during_air_copyy = 0;
|
||||
g_input_box_index = 0;
|
||||
g_air_copy_is_send_mode = 0;
|
||||
|
||||
BK4819_PrepareFSKReceive();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
g_aircopy_state = AIRCOPY_TRANSFER;
|
||||
}
|
||||
else
|
||||
gInputBox[--gInputBoxIndex] = 10;
|
||||
g_input_box[--g_input_box_index] = 10;
|
||||
|
||||
gRequestDisplayScreen = DISPLAY_AIRCOPY;
|
||||
g_request_display_screen = DISPLAY_AIRCOPY;
|
||||
}
|
||||
}
|
||||
|
||||
static void AIRCOPY_Key_MENU(bool bKeyPressed, bool bKeyHeld)
|
||||
static void AIRCOPY_Key_MENU(bool key_pressed, bool key_held)
|
||||
{
|
||||
if (!bKeyHeld && bKeyPressed)
|
||||
if (!key_held && key_pressed)
|
||||
{
|
||||
gFSKWriteIndex = 0;
|
||||
gAirCopyBlockNumber = 0;
|
||||
gInputBoxIndex = 0;
|
||||
gAirCopyIsSendMode = 1;
|
||||
g_FSK_Buffer[0] = 0xABCD;
|
||||
g_FSK_Buffer[1] = 0;
|
||||
g_FSK_Buffer[35] = 0xDCBA;
|
||||
g_fsk_wite_index = 0;
|
||||
g_air_copy_block_number = 0;
|
||||
g_input_box_index = 0;
|
||||
g_air_copy_is_send_mode = 1;
|
||||
g_fsk_buffer[0] = 0xABCD;
|
||||
g_fsk_buffer[1] = 0;
|
||||
g_fsk_buffer[35] = 0xDCBA;
|
||||
|
||||
AIRCOPY_SendMessage();
|
||||
|
||||
GUI_DisplayScreen();
|
||||
|
||||
gAircopyState = AIRCOPY_TRANSFER;
|
||||
g_aircopy_state = AIRCOPY_TRANSFER;
|
||||
}
|
||||
}
|
||||
|
||||
void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
void AIRCOPY_ProcessKeys(key_code_t Key, bool key_pressed, bool key_held)
|
||||
{
|
||||
switch (Key)
|
||||
{
|
||||
@ -216,13 +216,13 @@ void AIRCOPY_ProcessKeys(key_code_t Key, bool bKeyPressed, bool bKeyHeld)
|
||||
case KEY_7:
|
||||
case KEY_8:
|
||||
case KEY_9:
|
||||
AIRCOPY_Key_DIGITS(Key, bKeyPressed, bKeyHeld);
|
||||
AIRCOPY_Key_DIGITS(Key, key_pressed, key_held);
|
||||
break;
|
||||
case KEY_MENU:
|
||||
AIRCOPY_Key_MENU(bKeyPressed, bKeyHeld);
|
||||
AIRCOPY_Key_MENU(key_pressed, key_held);
|
||||
break;
|
||||
case KEY_EXIT:
|
||||
AIRCOPY_Key_EXIT(bKeyPressed, bKeyHeld);
|
||||
AIRCOPY_Key_EXIT(key_pressed, key_held);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
Reference in New Issue
Block a user