macros for divisors and fix lf optimal freq display

This commit is contained in:
Philippe Teuwen 2019-10-03 18:25:21 +02:00
commit f29ad0fba2
4 changed files with 15 additions and 9 deletions

View file

@ -182,10 +182,10 @@ void MeasureAntennaTuning(void) {
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, i);
SpinDelay(20);
uint32_t adcval = ((MAX_ADC_LF_VOLTAGE * AvgAdc(ADC_CHAN_LF)) >> 10);
if (i == 96)
if (i == LF_DIVISOR_125)
payload.v_lf125 = adcval; // voltage at 125kHz
if (i == 89)
if (i == LF_DIVISOR_134)
payload.v_lf134 = adcval; // voltage at 134kHz
if (i == sc->divisor)

View file

@ -24,7 +24,7 @@ Default LF config is set to:
divisor = 95 (125kHz)
trigger_threshold = 0
*/
sample_config config = { 1, 8, 1, 96, 0, 0 } ;
sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0 } ;
void printConfig() {
uint32_t d = config.divisor;

View file

@ -1676,16 +1676,16 @@ int CmdTuneSamples(const char *Cmd) {
struct p* package = (struct p*)resp.data.asBytes;
if (package->v_lf125 > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - 125.00 kHz", (package->v_lf125 * ANTENNA_ERROR) / 1000.0);
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lf125 * ANTENNA_ERROR) / 1000.0, 12000.0 / LF_DIVISOR_125);
if (package->v_lf134 > NON_VOLTAGE)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - 134.00 kHz", (package->v_lf134 * ANTENNA_ERROR) / 1000.0);
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lf134 * ANTENNA_ERROR) / 1000.0, 12000.0 / LF_DIVISOR_134);
if (package->v_lfconf > NON_VOLTAGE && package->divisor > 0)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lfconf * ANTENNA_ERROR) / 1000.0, (12000.0 / package->divisor));
if (package->v_lfconf > NON_VOLTAGE && package->divisor > 0 && package->divisor != LF_DIVISOR_125 && package->divisor != LF_DIVISOR_134)
PrintAndLogEx(SUCCESS, "LF antenna: %5.2f V - %.2f kHz", (package->v_lfconf * ANTENNA_ERROR) / 1000.0, 12000.0 / package->divisor);
if (package->peak_v > NON_VOLTAGE && package->peak_f > 0)
PrintAndLogEx(SUCCESS, "LF optimal: %5.2f V - %6.2f kHz", (package->peak_v * ANTENNA_ERROR) / 1000.0, 12000.0 / (package->peak_f + 1));
PrintAndLogEx(SUCCESS, "LF optimal: %5.2f V - %6.2f kHz", (package->peak_v * ANTENNA_ERROR) / 1000.0, 12000.0 / package->peak_f);
char judgement[20];
memset(judgement, 0, sizeof(judgement));
@ -1729,7 +1729,8 @@ int CmdTuneSamples(const char *Cmd) {
}
if (test1 > 0) {
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor 89 is 134kHz, 96 is 125kHz.\n\n");
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor %d is %.2f kHz, %d is %.2f kHz.\n\n",
LF_DIVISOR_134, 12000.0 / LF_DIVISOR_134, LF_DIVISOR_125, 12000.0 / LF_DIVISOR_125);
GraphTraceLen = 256;
ShowGraphWindow();
RepaintGraphWindow();

View file

@ -578,6 +578,11 @@ typedef struct {
// Quit program client: reserved, order to quit the program
#define PM3_EFATAL -99
// LF
//#define LF_DIVISOR(f) ((12000 + (f)/2)/(f))
//Note that 90 = 133.33 is closer to 134 than 89 = 134.83
#define LF_DIVISOR_125 96
#define LF_DIVISOR_134 89
// Receiving from USART need more than 30ms as we used on USB
// else we get errors about partial packet reception