-//Testing to fix timing issues by marshmellow (MM)
-void SimulateTagLowFrequencyMM(int period, int gap, int ledcontrol)
-{
- int i;
- uint8_t *tab = BigBuf_get_addr();
-
- FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
- FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_EDGE_DETECT);
-
- AT91C_BASE_PIOA->PIO_PER = GPIO_SSC_DOUT | GPIO_SSC_CLK;
-
- AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
- AT91C_BASE_PIOA->PIO_ODR = GPIO_SSC_CLK;
-
- #define SHORT_COIL() LOW(GPIO_SSC_DOUT)
- #define OPEN_COIL() HIGH(GPIO_SSC_DOUT)
-
- i = 0;
- while(!BUTTON_PRESS()) {
-
- WDT_HIT();
- //wait until reader carrier is HIGH
- while(!(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK)) {
- WDT_HIT();
- }
- if (i>0){
- if (tab[i]!=tab[i-1]){
- // transition
- if (ledcontrol)
- LED_D_ON();
-
- // modulate coil
- if(tab[i])
- OPEN_COIL();
- else
- SHORT_COIL();
-
- if (ledcontrol)
- LED_D_OFF();
-
- } else { //no transition
- //NOTE: it appears the COIL transition messes with the detection of the carrier, so if a transition happened
- // skip test for readers Carrier = LOW, otherwise we get a bit behind
-
- //wait until reader carrier is LOW
- while(AT91C_BASE_PIOA->PIO_PDSR & GPIO_SSC_CLK) {
- WDT_HIT();
- }
- }
- } else {
- // transition
- if (ledcontrol)
- LED_D_ON();
-
- // modulate coil
- if(tab[i])
- OPEN_COIL();
- else
- SHORT_COIL();
-
- if (ledcontrol)
- LED_D_OFF();
- }
- WDT_HIT();
-
-
- i++;
- if(i == period) {
- // end of data stream, gap then repeat
- i = 0;
- if (gap) {
- SHORT_COIL();
- SpinDelayUs(gap);
- }
- }
- }
- DbpString("Stopped");
- return;
-}
-