Skip to content

Commit

Permalink
Fixed types of several things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dual Tachyon authored and Dual Tachyon committed Aug 29, 2023
1 parent 6960f69 commit 552daee
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion app/fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
32 changes: 16 additions & 16 deletions audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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];
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions dcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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]);
}
Expand Down
4 changes: 2 additions & 2 deletions dcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions driver/bk4819.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions driver/bk4819.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion driver/crc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions frequencies.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions frequencies.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 552daee

Please sign in to comment.