From 6fe5fe8d521821b6d9615d9c77031097c94ef50e Mon Sep 17 00:00:00 2001
From: Iceman <iceman@iuse.se>
Date: Sun, 25 Dec 2016 15:25:33 +0100
Subject: [PATCH 1/1] LF sim

 `lf sim` - use config values for setting the frequency.
---
 armsrc/lfops.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/armsrc/lfops.c b/armsrc/lfops.c
index 8e9c03a6..90b8d0b3 100644
--- a/armsrc/lfops.c
+++ b/armsrc/lfops.c
@@ -400,6 +400,17 @@ void SimulateTagLowFrequency(int period, int gap, int ledcontrol)
 	FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
 	//FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_READER_FIELD);
 	//FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT | FPGA_LF_EDGE_DETECT_TOGGLE_MODE );
+
+	// set frequency,  get values from 'lf config' command
+	sample_config *sc = getSamplingConfig();
+
+	if ( (sc->divisor == 1) || (sc->divisor < 0) || (sc->divisor > 255) )
+		FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
+	else if (sc->divisor == 0)
+		FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
+	else
+		FpgaSendCommand(FPGA_CMD_SET_DIVISOR, sc->divisor);
+	
 	SetAdcMuxFor(GPIO_MUXSEL_LOPKD);
 	
 	AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK;
-- 
2.39.5