kopia lustrzana https://github.com/sq8vps/vp-digi
timer frq change, hamming distance using built-in fun
rodzic
743f2d7d1d
commit
2f894ab5a3
|
@ -768,7 +768,7 @@ void ModemInit(void)
|
|||
TIM1->DIER |= TIM_DIER_UIE;
|
||||
|
||||
//baudrate timer
|
||||
TIM3->PSC = 71; //72/72=1 MHz
|
||||
TIM3->PSC = 3; //72/9=18 MHz
|
||||
TIM3->DIER |= TIM_DIER_UIE;
|
||||
|
||||
if(ModemConfig.modem > MODEM_9600)
|
||||
|
@ -927,7 +927,7 @@ void ModemInit(void)
|
|||
|
||||
markStep = 4000000 / (DAC_SINE_SIZE * markFreq) - 1;
|
||||
spaceStep = 4000000 / (DAC_SINE_SIZE * spaceFreq) - 1;
|
||||
baudRateStep = 1000000 / baudRate - 1;
|
||||
baudRateStep = 18000000 / baudRate - 1;
|
||||
|
||||
|
||||
TIM3->ARR = baudRateStep;
|
||||
|
|
14
Src/fx25.c
14
Src/fx25.c
|
@ -25,23 +25,13 @@ const struct Fx25Mode Fx25ModeList[11] =
|
|||
{.tag = 0x4A4ABEC4A724B796, .K = 64, .T = 64}
|
||||
};
|
||||
|
||||
static uint8_t hammingDistance(uint64_t x, uint64_t y)
|
||||
{
|
||||
x ^= y;
|
||||
uint8_t distance = 0;
|
||||
for(uint8_t i = 0; i < 64; i++)
|
||||
{
|
||||
distance += (x & 1);
|
||||
x >>= 1;
|
||||
}
|
||||
return distance;
|
||||
}
|
||||
|
||||
|
||||
const struct Fx25Mode* Fx25GetModeForTag(uint64_t tag)
|
||||
{
|
||||
for(uint8_t i = 0; i < sizeof(Fx25ModeList) / sizeof(*Fx25ModeList); i++)
|
||||
{
|
||||
if(hammingDistance(tag, Fx25ModeList[i].tag) <= FX25_MAX_DISTANCE)
|
||||
if(__builtin_popcountll(tag ^ Fx25ModeList[i].tag) <= FX25_MAX_DISTANCE)
|
||||
return &Fx25ModeList[i];
|
||||
}
|
||||
return NULL;
|
||||
|
|
Ładowanie…
Reference in New Issue