Fixed CTCSS int overflow bug

This commit is contained in:
OneOfEleven 2023-10-02 01:19:14 +01:00
parent aea80cb046
commit bbf8a7061e
5 changed files with 3 additions and 3 deletions

2
dcs.c
View File

@ -91,7 +91,7 @@ uint8_t DCS_GetCdcssCode(uint32_t Code)
return 0xFF;
}
uint8_t DCS_GetCtcssCode(uint16_t Code)
uint8_t DCS_GetCtcssCode(int Code)
{
unsigned int i;
uint8_t Result = 0xFF;

2
dcs.h
View File

@ -39,7 +39,7 @@ extern const uint16_t DCS_Options[104];
uint32_t DCS_GetGolayCodeWord(DCS_CodeType_t CodeType, uint8_t Option);
uint8_t DCS_GetCdcssCode(uint32_t Code);
uint8_t DCS_GetCtcssCode(uint16_t Code);
uint8_t DCS_GetCtcssCode(int Code);
#endif

View File

@ -465,7 +465,7 @@ void BK4819_SetCTCSSFrequency(uint32_t FreqControlWord)
// freq(Hz) * 20.64888 for XTAL 13M/26M or
// freq(Hz) * 20.97152 for XTAL 12.8M/19.2M/25.6M/38.4M
//
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | (((FreqControlWord * 2064888u) + 500000u) / 1000000u)); // with rounding
BK4819_WriteRegister(BK4819_REG_07, BK4819_REG_07_MODE_CTC1 | (((FreqControlWord * 206488u) + 50000u) / 100000u)); // with rounding
}
// freq_10Hz is CTCSS Hz * 10

Binary file not shown.

Binary file not shown.