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