Browse Source

timer frq change, hamming distance using built-in fun

pull/32/head
Piotr Wilkon 2 years ago
parent
commit
2f894ab5a3
2 changed files with 4 additions and 14 deletions
  1. +2
    -2
      Src/drivers/modem.c
  2. +2
    -12
      Src/fx25.c

+ 2
- 2
Src/drivers/modem.c View File

@ -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;


+ 2
- 12
Src/fx25.c View File

@ -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;


Loading…
Cancel
Save