]>
git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/hfsnoop.c
5 #include "usb_cdc.h" // for usb_poll_validate_length
7 static void RAMFUNC
optimizedSnoop(void);
9 static void RAMFUNC
optimizedSnoop(void)
11 int n
= BigBuf_max_traceLen() / sizeof(uint16_t); // take all memory
13 uint16_t *dest
= (uint16_t *)BigBuf_get_addr();
14 uint16_t *destend
= dest
+ n
;
16 AT91C_BASE_SSC
->SSC_RFMR
= SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame mode, 16 bits per word
18 while(dest
<= destend
)
20 if(AT91C_BASE_SSC
->SSC_SR
& AT91C_SSC_RXRDY
)
22 *dest
= (uint16_t)(AT91C_BASE_SSC
->SSC_RHR
);
26 //Resetting Frame mode (First set in fpgaloader.c)
27 AT91C_BASE_SSC
->SSC_RFMR
= SSC_FRAME_MODE_BITS_IN_WORD(8) | AT91C_SSC_MSBF
| SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
30 void HfSnoop(int samplesToSkip
, int triggersToSkip
)
32 BigBuf_free(); BigBuf_Clear();
34 Dbprintf("Skipping first %d sample pairs, Skipping %d triggers.\n", samplesToSkip
, triggersToSkip
);
37 // Select correct configs
38 FpgaDownloadAndGo(FPGA_BITSTREAM_HF
);
39 // Set up the synchronous serial port
40 FpgaSetupSsc(FPGA_MAJOR_MODE_HF_SNOOP
);
41 // connect Demodulated Signal to ADC:
42 SetAdcMuxFor(GPIO_MUXSEL_HIPKD
);
43 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP
);
46 AT91C_BASE_SSC
->SSC_RFMR
= SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame Mode For better performance on high speed data transfer.
50 while(!BUTTON_PRESS() && !usb_poll_validate_length()) {
52 if(AT91C_BASE_SSC
->SSC_SR
& (AT91C_SSC_RXRDY
)) {
53 r
= (uint16_t)AT91C_BASE_SSC
->SSC_RHR
;
54 r
= MAX(r
& 0xff, r
>> 8);
56 if (++trigger_cnt
> triggersToSkip
)
63 int waitcount
= samplesToSkip
; // lets wait 40000 ticks of pck0
64 while(waitcount
!= 0) {
65 if(AT91C_BASE_SSC
->SSC_SR
& (AT91C_SSC_RXRDY
))
69 Dbprintf("Trigger kicked! Value: %d, Dumping Samples Hispeed now.", r
);
72 DbpString("HF Snoop end");
73 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF
);