Skip to content

Commit

Permalink
Merge branch 'DualTachyon:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
RE3CON authored Aug 15, 2023
2 parents dd6d57c + 66f6c7f commit 065c533
Show file tree
Hide file tree
Showing 18 changed files with 337 additions and 164 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ OBJS += driver/uart.o
OBJS += aircopy.o
OBJS += audio.o
OBJS += battery.o
OBJS += bitmaps.o
OBJS += board.o
OBJS += dcs.o
OBJS += dtmf.o
Expand Down
60 changes: 58 additions & 2 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ void AUDIO_PlaySingleVoice(bool bFlag)
goto Bailout;
}
Delay = VoiceClipLengthChinese[VoiceID];
VoiceID += 0x10;
VoiceID += VOICE_ID_CHI_BASE;
} else {
// English
if (VoiceID >= sizeof(VoiceClipLengthEnglish)) {
goto Bailout;
}
Delay = VoiceClipLengthEnglish[VoiceID];
VoiceID += 0x60;
VoiceID += VOICE_ID_ENG_BASE;
}

if (gCurrentFunction == FUNCTION_4 || gCurrentFunction == FUNCTION_2) {
Expand Down Expand Up @@ -282,3 +282,59 @@ uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint32_t Value)
return Count + 1;
}

void AUDIO_PlayQueuedVoice(void)
{
uint8_t VoiceID;
uint8_t Delay;
bool Skip;

Skip = false;
gVoiceReadIndex = gVoiceReadIndex;
if (gVoiceReadIndex != gVoiceWriteIndex && gEeprom.KEYPAD_TONE != 0) {
VoiceID = gVoiceID[gVoiceReadIndex];
if (gEeprom.KEYPAD_TONE == 1) {
if (VoiceID < 58) {
Delay = VoiceClipLengthChinese[VoiceID];
VoiceID += VOICE_ID_CHI_BASE;
} else {
Skip = true;
}
} else {
if (VoiceID < 76) {
Delay = VoiceClipLengthEnglish[VoiceID];
VoiceID += VOICE_ID_ENG_BASE;
} else {
Skip = true;
}
}
gVoiceReadIndex++;
if (!Skip) {
if (gVoiceReadIndex == gVoiceWriteIndex) {
Delay += 3;
}
AUDIO_PlayVoice(VoiceID);
gCountdownToPlayNextVoice = Delay;
gFlagPlayQueuedVoice = false;
g_200003B6 = 2000;
return;
}
}

if (gCurrentFunction == FUNCTION_4 || gCurrentFunction == FUNCTION_2) {
if (gInfoCHAN_A->_0x0033 == true) {
BK4819_SetAF(BK4819_AF_7);
} else {
BK4819_SetAF(BK4819_AF_OPEN);
}
}
if (gFmMute == true) {
BK1080_Mute(false);
}
if (g_2000036B == 0) {
GPIO_ClearBit(&GPIOC->DATA, GPIOC_PIN_AUDIO_PATH);
}
g_200003B6 = 0x50;
gVoiceWriteIndex = 0;
gVoiceReadIndex = 0;
}

158 changes: 82 additions & 76 deletions audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,83 +29,88 @@ enum BEEP_Type_t {

typedef enum BEEP_Type_t BEEP_Type_t;

enum {
VOICE_ID_CHI_BASE = 0x10U,
VOICE_ID_ENG_BASE = 0x60U,
};

enum VOICE_ID_t {
VOICE_ID_ENG_0 = 0x60U,
VOICE_ID_ENG_1 = 0x61U,
VOICE_ID_ENG_2 = 0x62U,
VOICE_ID_ENG_3 = 0x63U,
VOICE_ID_ENG_4 = 0x64U,
VOICE_ID_ENG_5 = 0x65U,
VOICE_ID_ENG_6 = 0x66U,
VOICE_ID_ENG_7 = 0x67U,
VOICE_ID_ENG_8 = 0x68U,
VOICE_ID_ENG_9 = 0x69U,
VOICE_ID_ENG_10 = 0x6AU,
VOICE_ID_ENG_100 = 0x6BU,
VOICE_ID_ENG_WELCOME = 0x6CU,
VOICE_ID_ENG_LOCK = 0x6DU,
VOICE_ID_ENG_M_LOCK = 0x6EU,
VOICE_ID_ENG_SCANNING_BEGIN = 0x6FU,
VOICE_ID_ENG_SCANNING_STOP = 0x70U,
VOICE_ID_ENG_SCRAMBLER_ON = 0x71U,
VOICE_ID_ENG_SCRAMBLER_OFF = 0x72U,
VOICE_ID_ENG_FUNCTION = 0x73U,
VOICE_ID_ENG_CTCSS = 0x74U,
VOICE_ID_ENG_DCS = 0x75U,
VOICE_ID_ENG_POWER = 0x76U,
VOICE_ID_ENG_SAVE_MODE = 0x77U,
VOICE_ID_ENG_MEMORY_CHANNEL = 0x78U,
VOICE_ID_ENG_DELETE_CHANNEL = 0x79U,
VOICE_ID_ENG_FREQUENCY_STEP = 0x7AU,
VOICE_ID_ENG_SQUELCH = 0x7BU,
VOICE_ID_ENG_TRANSMIT_OVER_TIME = 0x7CU,
VOICE_ID_ENG_BACKLIGHT_SELECTION = 0x7DU,
VOICE_ID_ENG_VOX = 0x7EU,
VOICE_ID_ENG_FREQUENCY_DIRECTION = 0x7FU,
VOICE_ID_ENG_OFFSET_FREQUENCY = 0x80U,
VOICE_ID_ENG_TRANSMITING_MEMORY = 0x81U,
VOICE_ID_ENG_RECEIVING_MEMORY = 0x82U,
VOICE_ID_ENG_EMERGENCY_CALL = 0x83U,
VOICE_ID_ENG_LOW_VOLTAGE = 0x84U,
VOICE_ID_ENG_CHANNEL_MODE = 0x85U,
VOICE_ID_ENG_FREQUENCY_MODE = 0x86U,
VOICE_ID_ENG_VOICE_PROMPT = 0x87U,
VOICE_ID_ENG_BAND_SELECTION = 0x88U,
VOICE_ID_ENG_DUAL_STANDBY = 0x89U,
VOICE_ID_ENG_CHANNEL_BANDWIDTH = 0x8AU,
VOICE_ID_ENG_OPTIONAL_SIGNAL = 0x8BU,
VOICE_ID_ENG_MUTE_MODE = 0x8CU,
VOICE_ID_ENG_BUSY_LOCKOUT = 0x8DU,
VOICE_ID_ENG_BEEP_PROMPT = 0x8EU,
VOICE_ID_ENG_ANI_CODE = 0x8FU,
VOICE_ID_ENG_INITIALISATION = 0x90U,
VOICE_ID_ENG_CONFIRM = 0x91U,
VOICE_ID_ENG_CANCEL = 0x92U,
VOICE_ID_ENG_ON = 0x93U,
VOICE_ID_ENG_OFF = 0x94U,
VOICE_ID_ENG_2_TONE = 0x95U,
VOICE_ID_ENG_5_TONE = 0x96U,
VOICE_ID_ENG_DIGITAL_SIGNAL = 0x97U,
VOICE_ID_ENG_REPEATER = 0x98U,
VOICE_ID_ENG_MENU = 0x99U,
VOICE_ID_ENG_11 = 0x9AU,
VOICE_ID_ENG_12 = 0x9BU,
VOICE_ID_ENG_13 = 0x9CU,
VOICE_ID_ENG_14 = 0x9DU,
VOICE_ID_ENG_15 = 0x9EU,
VOICE_ID_ENG_16 = 0x9FU,
VOICE_ID_ENG_17 = 0xA0U,
VOICE_ID_ENG_18 = 0xA1U,
VOICE_ID_ENG_19 = 0xA2U,
VOICE_ID_ENG_20 = 0xA3U,
VOICE_ID_ENG_30 = 0xA4U,
VOICE_ID_ENG_40 = 0xA5U,
VOICE_ID_ENG_50 = 0xA6U,
VOICE_ID_ENG_60 = 0xA7U,
VOICE_ID_ENG_70 = 0xA8U,
VOICE_ID_ENG_80 = 0xA9U,
VOICE_ID_ENG_90 = 0xAAU,
VOICE_ID_ENG_END = 0xABU,
VOICE_ID_0 = 0x00U,
VOICE_ID_1 = 0x01U,
VOICE_ID_2 = 0x02U,
VOICE_ID_3 = 0x03U,
VOICE_ID_4 = 0x04U,
VOICE_ID_5 = 0x05U,
VOICE_ID_6 = 0x06U,
VOICE_ID_7 = 0x07U,
VOICE_ID_8 = 0x08U,
VOICE_ID_9 = 0x09U,
VOICE_ID_10 = 0x0AU,
VOICE_ID_100 = 0x0BU,
VOICE_ID_WELCOME = 0x0CU,
VOICE_ID_LOCK = 0x0DU,
VOICE_ID_M_LOCK = 0x0EU,
VOICE_ID_SCANNING_BEGIN = 0x0FU,
VOICE_ID_SCANNING_STOP = 0x10U,
VOICE_ID_SCRAMBLER_ON = 0x11U,
VOICE_ID_SCRAMBLER_OFF = 0x12U,
VOICE_ID_FUNCTION = 0x13U,
VOICE_ID_CTCSS = 0x14U,
VOICE_ID_DCS = 0x15U,
VOICE_ID_POWER = 0x16U,
VOICE_ID_SAVE_MODE = 0x17U,
VOICE_ID_MEMORY_CHANNEL = 0x18U,
VOICE_ID_DELETE_CHANNEL = 0x19U,
VOICE_ID_FREQUENCY_STEP = 0x1AU,
VOICE_ID_SQUELCH = 0x1BU,
VOICE_ID_TRANSMIT_OVER_TIME = 0x1CU,
VOICE_ID_BACKLIGHT_SELECTION = 0x1DU,
VOICE_ID_VOX = 0x1EU,
VOICE_ID_FREQUENCY_DIRECTION = 0x1FU,
VOICE_ID_OFFSET_FREQUENCY = 0x20U,
VOICE_ID_TRANSMITING_MEMORY = 0x21U,
VOICE_ID_RECEIVING_MEMORY = 0x22U,
VOICE_ID_EMERGENCY_CALL = 0x23U,
VOICE_ID_LOW_VOLTAGE = 0x24U,
VOICE_ID_CHANNEL_MODE = 0x25U,
VOICE_ID_FREQUENCY_MODE = 0x26U,
VOICE_ID_VOICE_PROMPT = 0x27U,
VOICE_ID_BAND_SELECTION = 0x28U,
VOICE_ID_DUAL_STANDBY = 0x29U,
VOICE_ID_CHANNEL_BANDWIDTH = 0x2AU,
VOICE_ID_OPTIONAL_SIGNAL = 0x2BU,
VOICE_ID_MUTE_MODE = 0x2CU,
VOICE_ID_BUSY_LOCKOUT = 0x2DU,
VOICE_ID_BEEP_PROMPT = 0x2EU,
VOICE_ID_ANI_CODE = 0x2FU,
VOICE_ID_INITIALISATION = 0x30U,
VOICE_ID_CONFIRM = 0x31U,
VOICE_ID_CANCEL = 0x32U,
VOICE_ID_ON = 0x33U,
VOICE_ID_OFF = 0x34U,
VOICE_ID_2_TONE = 0x35U,
VOICE_ID_5_TONE = 0x36U,
VOICE_ID_DIGITAL_SIGNAL = 0x37U,
VOICE_ID_REPEATER = 0x38U,
VOICE_ID_MENU = 0x39U,
VOICE_ID_11 = 0x3AU,
VOICE_ID_12 = 0x3BU,
VOICE_ID_13 = 0x3CU,
VOICE_ID_14 = 0x3DU,
VOICE_ID_15 = 0x3EU,
VOICE_ID_16 = 0x3FU,
VOICE_ID_17 = 0x40U,
VOICE_ID_18 = 0x41U,
VOICE_ID_19 = 0x42U,
VOICE_ID_20 = 0x43U,
VOICE_ID_30 = 0x44U,
VOICE_ID_40 = 0x45U,
VOICE_ID_50 = 0x46U,
VOICE_ID_60 = 0x47U,
VOICE_ID_70 = 0x48U,
VOICE_ID_80 = 0x49U,
VOICE_ID_90 = 0x4AU,
VOICE_ID_END = 0x4BU,
};

typedef enum VOICE_ID_t VOICE_ID_t;
Expand All @@ -121,6 +126,7 @@ void AUDIO_PlayVoice(VOICE_ID_t VoiceID);
void AUDIO_PlaySingleVoice(bool bFlag);
void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID);
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint32_t Value);
void AUDIO_PlayQueuedVoice(void);

#endif

10 changes: 9 additions & 1 deletion bitmaps.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "bitmap.h"
#include "bitmaps.h"

const uint8_t BITMAP_PowerSave[8] = { 0x00, 0x26, 0x49, 0x49, 0x49, 0x49, 0x49, 0x32 };

Expand All @@ -22,3 +22,11 @@ const uint8_t BITMAP_KEYPAD_TONE[9] = { 0x00, 0x18, 0x18, 0x24, 0x24, 0x42, 0x42
const uint8_t BITMAP_FM_Mute[12] = { 0x00, 0x7F, 0x09, 0x09, 0x09, 0x01, 0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F };
const uint8_t BITMAP_NOAA[12] = { 0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F, 0x00, 0x46, 0x49, 0x49, 0x49, 0x31 };

const uint8_t BITMAP_Antenna[5] = { 0x03, 0x05, 0x7F, 0x05, 0x03 };
const uint8_t BITMAP_AntennaLevel1[3] = { 0x60, 0x60, 0x00 };
const uint8_t BITMAP_AntennaLevel2[3] = { 0x70, 0x70, 0x00 };
const uint8_t BITMAP_AntennaLevel3[3] = { 0x78, 0x78, 0x00 };
const uint8_t BITMAP_AntennaLevel4[3] = { 0x7C, 0x7C, 0x00 };
const uint8_t BITMAP_AntennaLevel5[3] = { 0x7E, 0x7E, 0x00 };
const uint8_t BITMAP_AntennaLevel6[3] = { 0x7F, 0x7F, 0x00 };

40 changes: 25 additions & 15 deletions bitmaps.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
#ifndef BITMAP_H
#define BITMAP_H

const uint8_t BITMAP_PowerSave[8];
#include <stdint.h>

const uint8_t BITMAP_BatteryLevel1[18];
const uint8_t BITMAP_BatteryLevel2[18];
const uint8_t BITMAP_BatteryLevel3[18];
const uint8_t BITMAP_BatteryLevel4[18];
const uint8_t BITMAP_BatteryLevel5[18];
extern const uint8_t BITMAP_PowerSave[8];

const uint8_t BITMAP_USB_C[9];
const uint8_t BITMAP_KeyLock[9];
extern const uint8_t BITMAP_BatteryLevel1[18];
extern const uint8_t BITMAP_BatteryLevel2[18];
extern const uint8_t BITMAP_BatteryLevel3[18];
extern const uint8_t BITMAP_BatteryLevel4[18];
extern const uint8_t BITMAP_BatteryLevel5[18];

const uint8_t BITMAP_F_Key[10];
extern const uint8_t BITMAP_USB_C[9];
extern const uint8_t BITMAP_KeyLock[9];

const uint8_t BITMAP_VOX[18];
extern const uint8_t BITMAP_F_Key[10];

const uint8_t BITMAP_WX[12];
const uint8_t BITMAP_TDR[12];
const uint8_t BITMAP_KEYPAD_TONE[9];
extern const uint8_t BITMAP_VOX[18];

const uint8_t BITMAP_FM_Mute[12];
const uint8_t BITMAP_NOAA[12];
extern const uint8_t BITMAP_WX[12];
extern const uint8_t BITMAP_TDR[12];
extern const uint8_t BITMAP_KEYPAD_TONE[9];

extern const uint8_t BITMAP_FM_Mute[12];
extern const uint8_t BITMAP_NOAA[12];

extern const uint8_t BITMAP_Antenna[5];
extern const uint8_t BITMAP_AntennaLevel1[3];
extern const uint8_t BITMAP_AntennaLevel2[3];
extern const uint8_t BITMAP_AntennaLevel3[3];
extern const uint8_t BITMAP_AntennaLevel4[3];
extern const uint8_t BITMAP_AntennaLevel5[3];
extern const uint8_t BITMAP_AntennaLevel6[3];

#endif

22 changes: 11 additions & 11 deletions board.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,9 +771,9 @@ void BOARD_EEPROM_LoadMoreSettings(void)
memcpy(gEEPROM_1EC0_2, gEEPROM_1EC0_0, 8);
memcpy(gEEPROM_1EC0_3, gEEPROM_1EC0_0, 8);

EEPROM_ReadBuffer(0x1EC8, gEEPROM_1EC8_0, 8);
memcpy(gEEPROM_1EC8_1, gEEPROM_1EC8_0, 8);
memcpy(gEEPROM_1EC8_2, gEEPROM_1EC8_0, 8);
EEPROM_ReadBuffer(0x1EC8, gEEPROM_RSSI_CALIB[0], 8);
memcpy(gEEPROM_RSSI_CALIB[1], gEEPROM_RSSI_CALIB[0], 8);
memcpy(gEEPROM_RSSI_CALIB[2], gEEPROM_RSSI_CALIB[0], 8);

EEPROM_ReadBuffer(0x1F40, gBatteryCalibration, 12);
if (gBatteryCalibration[0] >= 5000) {
Expand All @@ -795,8 +795,8 @@ void BOARD_EEPROM_LoadMoreSettings(void)
int16_t BK4819_XtalFreqLow;
uint16_t EEPROM_1F8A;
uint16_t EEPROM_1F8C;
uint8_t EEPROM_1F8E;
uint8_t EEPROM_1F8F;
uint8_t VOLUME_GAIN;
uint8_t DAC_GAIN;
} Misc;

EEPROM_ReadBuffer(0x1F88, &Misc, 8);
Expand All @@ -809,16 +809,16 @@ void BOARD_EEPROM_LoadMoreSettings(void)
gEEPROM_1F8A = Misc.EEPROM_1F8A & 0x01FF;
gEEPROM_1F8C = Misc.EEPROM_1F8C & 0x01FF;

if (Misc.EEPROM_1F8E < 64) {
gEeprom.EEPROM_1F8E = Misc.EEPROM_1F8E;
if (Misc.VOLUME_GAIN < 64) {
gEeprom.VOLUME_GAIN = Misc.VOLUME_GAIN;
} else {
gEeprom.EEPROM_1F8E = 58;
gEeprom.VOLUME_GAIN = 58;
}

if (Misc.EEPROM_1F8F < 16) {
gEeprom.EEPROM_1F8F = Misc.EEPROM_1F8F;
if (Misc.DAC_GAIN < 16) {
gEeprom.DAC_GAIN = Misc.DAC_GAIN;
} else {
gEeprom.EEPROM_1F8F = 8;
gEeprom.DAC_GAIN = 8;
}

BK4819_WriteRegister(BK4819_REG_3B, gEeprom.BK4819_XTAL_FREQ_LOW + 22656);
Expand Down
3 changes: 1 addition & 2 deletions dcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ uint32_t DCS_CalculateGolay(uint32_t CodeWord)
return CodeWord | ((Word & 0x0FFE) << 12);
}

uint32_t DCS_GetGolayCodeWord(uint8_t CodeType, uint8_t Option)

uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option)
{
uint32_t Code;

Expand Down
5 changes: 5 additions & 0 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,8 @@ void BK4819_EnableCTCSS(void)
BK4819_WriteRegister(BK4819_REG_51, 0x904A);
}

uint16_t BK4819_GetRSSI(void)
{
return BK4819_GetRegister(BK4819_REG_67) & 0x01FF;
}

Loading

0 comments on commit 065c533

Please sign in to comment.