Fixed types of several things.

This commit is contained in:
Dual Tachyon 2023-08-29 19:17:01 +01:00
parent 6960f69b11
commit 552daee633
12 changed files with 49 additions and 47 deletions

View File

@ -1091,7 +1091,7 @@ void APP_TimeSlice10ms(void)
}
}
if (gScreenToDisplay == DISPLAY_SCANNER) {
int32_t Result;
uint32_t Result;
int32_t Delta;
BK4819_CssScanResult_t ScanResult;
uint16_t CtcssFreq;

View File

@ -190,7 +190,7 @@ void FM_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gRequestDisplayScreen = DISPLAY_FM;
return;
}
gEeprom.FM_CurrentFrequency = Frequency;
gEeprom.FM_CurrentFrequency = (uint16_t)Frequency;
gAnotherVoiceID = (VOICE_ID_t)Key;
gEeprom.FM_FrequencyToPlay = gEeprom.FM_CurrentFrequency;
BK1080_SetFrequency(gEeprom.FM_FrequencyToPlay);

View File

@ -199,7 +199,7 @@ void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gEeprom.ScreenChannel[Vfo] = Channel;
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, Channel + 1);
gAnotherVoiceID = 0xFE;
gAnotherVoiceID = (VOICE_ID_t)0xFE;
gRequestSaveVFO = true;
g_2000039A = 2;
break;
@ -248,7 +248,7 @@ void MAIN_Key_DIGITS(KEY_Code_t Key, bool bKeyPressed, bool bKeyHeld)
gEeprom.ScreenChannel[Vfo] = gEeprom.CHAN_1_CALL;
AUDIO_SetVoiceID(0, VOICE_ID_CHANNEL_MODE);
AUDIO_SetDigitVoice(1, gEeprom.CHAN_1_CALL + 1);
gAnotherVoiceID = 0xFE;
gAnotherVoiceID = (VOICE_ID_t)0xFE;
gRequestSaveVFO = true;
g_2000039A = 2;
break;
@ -370,7 +370,7 @@ void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
return;
}
AUDIO_SetDigitVoice(0, gTxRadioInfo->CHANNEL_SAVE + 1);
gAnotherVoiceID = 0xFE;
gAnotherVoiceID = (VOICE_ID_t)0xFE;
return;
}
} else {
@ -401,7 +401,7 @@ void MAIN_Key_UP_DOWN(bool bKeyPressed, bool bKeyHeld, int8_t Direction)
gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] = Next;
if (!bKeyHeld) {
AUDIO_SetDigitVoice(0, Next + 1);
gAnotherVoiceID = 0xFE;
gAnotherVoiceID = (VOICE_ID_t)0xFE;
}
} else {
Channel = NOAA_CHANNEL_FIRST + NUMBER_AddWithWraparound(gEeprom.ScreenChannel[gEeprom.TX_CHANNEL] - NOAA_CHANNEL_FIRST, Direction, 0, 9);

32
audio.c
View File

@ -51,7 +51,7 @@ static const uint8_t VoiceClipLengthEnglish[76] = {
0x41, 0x32, 0x3C, 0x37,
};
uint8_t gVoiceID[8];
VOICE_ID_t gVoiceID[8];
uint8_t gVoiceReadIndex;
uint8_t gVoiceWriteIndex;
volatile uint16_t gCountdownToPlayNextVoice;
@ -149,7 +149,7 @@ void AUDIO_PlayBeep(BEEP_Type_t Beep)
}
}
void AUDIO_PlayVoice(VOICE_ID_t VoiceID)
void AUDIO_PlayVoice(uint8_t VoiceID)
{
uint8_t i;
@ -172,7 +172,7 @@ void AUDIO_PlayVoice(VOICE_ID_t VoiceID)
void AUDIO_PlaySingleVoice(bool bFlag)
{
VOICE_ID_t VoiceID;
uint8_t VoiceID;
uint8_t Delay;
VoiceID = gVoiceID[0];
@ -251,7 +251,7 @@ void AUDIO_SetVoiceID(uint8_t Index, VOICE_ID_t VoiceID)
gVoiceWriteIndex++;
}
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint32_t Value)
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value)
{
uint16_t Remainder;
uint8_t Result;
@ -263,27 +263,27 @@ uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint32_t Value)
}
Count = 0;
Result = Value / 1000;
Remainder = Value % 1000;
if (Remainder < 100) {
if (Remainder < 10) {
Result = Value / 1000U;
Remainder = Value % 1000U;
if (Remainder < 100U) {
if (Remainder < 10U) {
goto Skip;
}
} else {
Result = Remainder / 100;
gVoiceID[gVoiceWriteIndex++] = Result;
Result = Remainder / 100U;
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
Count++;
Remainder -= Result * 100;
Remainder -= Result * 100U;
}
Result = Remainder / 10;
gVoiceID[gVoiceWriteIndex++] = Result;
Result = Remainder / 10U;
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Result;
Count++;
Remainder -= Result * 10;
Remainder -= Result * 10U;
Skip:
gVoiceID[gVoiceWriteIndex++] = Remainder;
gVoiceID[gVoiceWriteIndex++] = (VOICE_ID_t)Remainder;
return Count + 1;
return Count + 1U;
}
void AUDIO_PlayQueuedVoice(void)

View File

@ -117,7 +117,7 @@ enum VOICE_ID_t {
typedef enum VOICE_ID_t VOICE_ID_t;
extern uint8_t gVoiceID[8];
extern VOICE_ID_t gVoiceID[8];
extern uint8_t gVoiceReadIndex;
extern uint8_t gVoiceWriteIndex;
extern volatile uint16_t gCountdownToPlayNextVoice;
@ -126,10 +126,10 @@ extern VOICE_ID_t gAnotherVoiceID;
extern BEEP_Type_t gBeepToPlay;
void AUDIO_PlayBeep(BEEP_Type_t Beep);
void AUDIO_PlayVoice(VOICE_ID_t VoiceID);
void AUDIO_PlayVoice(uint8_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);
uint8_t AUDIO_SetDigitVoice(uint8_t Index, uint16_t Value);
void AUDIO_PlayQueuedVoice(void);
#endif

12
dcs.c
View File

@ -18,7 +18,7 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
const int16_t CTCSS_Options[50] = {
const uint16_t CTCSS_Options[50] = {
0x029E, 0x02B5, 0x02CF, 0x02E8,
0x0302, 0x031D, 0x0339, 0x0356,
0x0375, 0x0393, 0x03B4, 0x03CE,
@ -34,7 +34,7 @@ const int16_t CTCSS_Options[50] = {
0x09C7, 0x09ED,
};
const int16_t DCS_Options[104] = {
const uint16_t DCS_Options[104] = {
0x0013, 0x0015, 0x0016, 0x0019,
0x001A, 0x001E, 0x0023, 0x0027,
0x0029, 0x002B, 0x002C, 0x0035,
@ -82,7 +82,7 @@ uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option)
{
uint32_t Code;
Code = DCS_CalculateGolay(DCS_Options[Option] + 0x800);
Code = DCS_CalculateGolay(DCS_Options[Option] + 0x800U);
if (CodeType == CODE_TYPE_REVERSE_DIGITAL) {
Code ^= 0x7FFFFF;
}
@ -121,14 +121,14 @@ uint8_t DCS_GetCdcssIndex(uint32_t Code)
uint8_t DCS_GetCtcssIndex(uint16_t Code)
{
uint8_t i;
uint16_t Smallest;
int Smallest;
uint8_t Result = 0xFF;
Smallest = ARRAY_SIZE(CTCSS_Options);
for (i = 0; i < ARRAY_SIZE(CTCSS_Options); i++) {
int16_t Delta;
int Delta;
Delta = (int16_t)Code - CTCSS_Options[i];
Delta = Code - CTCSS_Options[i];
if (Delta < 0) {
Delta = -(Code - CTCSS_Options[i]);
}

4
dcs.h
View File

@ -28,8 +28,8 @@ enum DCS_CodeType_t {
typedef enum DCS_CodeType_t DCS_CodeType_t;
extern const int16_t CTCSS_Options[50];
extern const int16_t DCS_Options[104];
extern const uint16_t CTCSS_Options[50];
extern const uint16_t DCS_Options[104];
uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option);
uint8_t DCS_GetCdcssIndex(uint32_t Code);

View File

@ -737,7 +737,7 @@ uint16_t BK4819_GetRSSI(void)
return BK4819_GetRegister(BK4819_REG_67) & 0x01FF;
}
bool BK4819_GetFrequencyScanResult(int32_t *pFrequency)
bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency)
{
uint16_t High, Low;
bool Finished;
@ -746,13 +746,13 @@ bool BK4819_GetFrequencyScanResult(int32_t *pFrequency)
Finished = (High & 0x8000) == 0;
if (Finished) {
Low = BK4819_GetRegister(BK4819_REG_0E);
*pFrequency = ((High & 0x7FF) << 16) | Low;
*pFrequency = (uint32_t)((High & 0x7FF) << 16) | Low;
}
return Finished;
}
BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(int32_t *pCdcssFreq, uint16_t *pCtcssFreq)
BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq)
{
uint16_t High, Low;
@ -782,7 +782,7 @@ void BK4819_EnableFrequencyScan(void)
BK4819_WriteRegister(BK4819_REG_32, 0x0245);
}
void BK4819_SetScanFrequency(int32_t Frequency)
void BK4819_SetScanFrequency(uint32_t Frequency)
{
BK4819_SetFrequency(Frequency);
BK4819_WriteRegister(BK4819_REG_51, 0

View File

@ -110,11 +110,11 @@ void BK4819_EnableCTCSS(void);
uint16_t BK4819_GetRSSI(void);
bool BK4819_GetFrequencyScanResult(int32_t *pFrequency);
BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(int32_t *pCdcssFreq, uint16_t *pCtcssFreq);
bool BK4819_GetFrequencyScanResult(uint32_t *pFrequency);
BK4819_CssScanResult_t BK4819_GetCxCSSScanResult(uint32_t *pCdcssFreq, uint16_t *pCtcssFreq);
void BK4819_DisableFrequencyScan(void);
void BK4819_EnableFrequencyScan(void);
void BK4819_SetScanFrequency(int32_t Frequency);
void BK4819_SetScanFrequency(uint32_t Frequency);
void BK4819_Disable(void);

View File

@ -41,7 +41,7 @@ uint16_t CRC_Calculate(const void *pBuffer, uint16_t Size)
for (i = 0; i < Size; i++) {
CRC_DATAIN = pData[i];
}
Crc = CRC_DATAOUT;
Crc = (uint16_t)CRC_DATAOUT;
CRC_CR = (CRC_CR & ~CRC_CR_CRC_EN_MASK) | CRC_CR_CRC_EN_BITS_DISABLE;

View File

@ -98,7 +98,7 @@ FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency)
return BAND6_400MHz;
}
uint32_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, uint32_t LowerLimit, uint32_t Middle, uint32_t UpperLimit, uint32_t Frequency)
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, uint32_t LowerLimit, uint32_t Middle, uint32_t UpperLimit, uint32_t Frequency)
{
if (Frequency <= LowerLimit) {
return TxpLow;
@ -107,13 +107,15 @@ uint32_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t
return TxpHigh;
}
if (Frequency <= Middle) {
return TxpMid + ((TxpMid - TxpLow) * (Frequency - LowerLimit)) / (Middle - LowerLimit);
TxpMid += ((TxpMid - TxpLow) * (Frequency - LowerLimit)) / (Middle - LowerLimit);
return TxpMid;
}
return TxpMid + ((TxpHigh - TxpMid) * (Frequency - Middle)) / (UpperLimit - Middle);
TxpMid += ((TxpHigh - TxpMid) * (Frequency - Middle)) / (UpperLimit - Middle);
return TxpMid;
}
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, int32_t Step, uint32_t Lower)
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower)
{
uint32_t Index;

View File

@ -39,8 +39,8 @@ extern const uint32_t NoaaFrequencyTable[10];
extern const uint16_t StepFrequencyTable[6];
FREQUENCY_Band_t FREQUENCY_GetBand(uint32_t Frequency);
uint32_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, uint32_t LowerLimit, uint32_t Middle, uint32_t UpperLimit, uint32_t Frequency);
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, int32_t Step, uint32_t Lower);
uint8_t FREQUENCY_CalculateOutputPower(uint8_t TxpLow, uint8_t TxpMid, uint8_t TxpHigh, uint32_t LowerLimit, uint32_t Middle, uint32_t UpperLimit, uint32_t Frequency);
uint32_t FREQUENCY_FloorToStep(uint32_t Upper, uint32_t Step, uint32_t Lower);
int FREQUENCY_Check(VFO_Info_t *pInfo);
#endif