]> git.zerfleddert.de Git - proxmark3-svn/blob - armsrc/hfsnoop.c
The great work of Enio hf snoop is now ported into latest version in git
[proxmark3-svn] / armsrc / hfsnoop.c
1 #include "proxmark3.h"
2 #include "apps.h"
3 #include "BigBuf.h"
4 #include "util.h"
5
6 static void RAMFUNC optimizedSnoop(void);
7
8 static void RAMFUNC optimizedSnoop(void)
9 {
10 BigBuf_free();
11 int n = BigBuf_max_traceLen() / sizeof(uint16_t); // take all memory
12
13 uint16_t *dest = (uint16_t *)BigBuf_get_addr();
14 uint16_t *destend = dest + n;
15
16 AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame mode, 16 bits per word
17 // Reading data loop
18 while(dest <= destend)
19 {
20 if(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY)
21 {
22 *dest = (uint16_t)(AT91C_BASE_SSC->SSC_RHR);
23 dest = dest + 1;
24 }
25 }
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);
28 }
29
30 void HfSnoop(int samplesToSkip, int triggersToSkip)
31 {
32 Dbprintf("Skipping first %d sample pairs, Skipping %d triggers.\n", samplesToSkip, triggersToSkip);
33 bool trigger_cnt;
34 LED_D_OFF();
35 // Select correct configs
36 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
37 // Set up the synchronous serial port
38 FpgaSetupSsc();
39 // connect Demodulated Signal to ADC:
40 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
41 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP);
42 SpinDelay(100);
43
44 AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame Mode For better performance on high speed data transfer.
45
46 trigger_cnt = 0;
47 uint16_t r;
48 for(;;) {
49 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
50 r = (uint16_t)AT91C_BASE_SSC->SSC_RHR;
51 if (!(trigger_cnt == triggersToSkip) && ( (r >> 8) >= 240))
52 {
53 Dbprintf("Trigger kicked! Value: %d.", r >> 8);
54 trigger_cnt++;
55 break;
56 }
57 }
58 }
59 Dbprintf("Trigger kicked! Value: %d, Dumping Samples Hispeed now.", r >> 8);
60 int waitcount = samplesToSkip; // lets wait 40000 ticks of pck0
61 while(waitcount != 0) {
62 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
63 waitcount--;
64 }
65 }
66
67 // Snooooop!!!
68 optimizedSnoop();
69
70 DbpString("Done.");
71 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
72 LED_D_OFF();
73 }
74
Impressum, Datenschutz