Make demodulation threshold for Legic configurable

This adds a new parameter to the "hw sethfthresh" command.
This commit is contained in:
Christian Zietz 2024-02-01 18:33:23 +01:00
commit 43b257ddb4
4 changed files with 18 additions and 9 deletions

View file

@ -64,7 +64,7 @@ static uint32_t last_frame_end; /* ts of last bit of previews rx or tx frame */
#define LEGIC_CARD_MEMSIZE 1024 /* The largest Legic Prime card is 1k */
#define WRITE_LOWERLIMIT 4 /* UID and MCC are not writable */
#define INPUT_THRESHOLD 8 /* heuristically determined, lower values */
static uint32_t input_threshold = 8; /* heuristically determined, lower values */
/* lead to detecting false ack during write */
//-----------------------------------------------------------------------------
@ -129,7 +129,7 @@ static bool rx_bit(void) {
int32_t power = (MAX(ABS(sum_ci), ABS(sum_cq)) + (MIN(ABS(sum_ci), ABS(sum_cq)) >> 1));
// compare average (power / 8) to threshold
return ((power >> 3) > INPUT_THRESHOLD);
return ((power >> 3) > input_threshold);
}
//-----------------------------------------------------------------------------
@ -566,3 +566,8 @@ OUT:
switch_off();
StopTicks();
}
void LegicRfSetThreshold(uint32_t threshold)
{
input_threshold = threshold;
}