]> git.zerfleddert.de Git - proxmark3-svn/blame - armsrc/hfsnoop.c
updated onlineshops
[proxmark3-svn] / armsrc / hfsnoop.c
CommitLineData
0472d76d 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{
0472d76d 10 int n = BigBuf_max_traceLen() / sizeof(uint16_t); // take all memory
031311c7 11
0472d76d 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);
22 dest = dest + 1;
23 }
24 }
25 //Resetting Frame mode (First set in fpgaloader.c)
031311c7 26 AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(8) | AT91C_SSC_MSBF | SSC_FRAME_MODE_WORDS_PER_TRANSFER(0);
0472d76d 27}
28
29void HfSnoop(int samplesToSkip, int triggersToSkip)
30{
5d0e1901 31 Dbprintf("Skipping first %d sample pairs, Skipping %d triggers.", samplesToSkip, triggersToSkip);
c87c4521 32 int trigger_cnt;
031311c7 33 LED_D_ON();
0472d76d 34 // Select correct configs
35 FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
36 // Set up the synchronous serial port
37 FpgaSetupSsc();
38 // connect Demodulated Signal to ADC:
39 SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
40 FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_SNOOP);
41 SpinDelay(100);
42
5d0e1901 43 BigBuf_free();
44 BigBuf_Clear();
45
0472d76d 46 AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(16); // Setting Frame Mode For better performance on high speed data transfer.
031311c7 47
0472d76d 48 trigger_cnt = 0;
031311c7 49 uint16_t r = 0;
50 while(!BUTTON_PRESS()) {
51 WDT_HIT();
0472d76d 52 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
53 r = (uint16_t)AT91C_BASE_SSC->SSC_RHR;
5d0e1901 54 r = MAX(r & 0xff, r >> 8);
55 if (r >= 240)
0472d76d 56 {
5d0e1901 57 if (++trigger_cnt > triggersToSkip) {
58 break;
59 }
031311c7 60 }
0472d76d 61 }
62 }
5d0e1901 63
031311c7 64 if(!BUTTON_PRESS()) {
031311c7 65 int waitcount = samplesToSkip; // lets wait 40000 ticks of pck0
66 while(waitcount != 0) {
67 if(AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
68 waitcount--;
69 }
0472d76d 70 }
031311c7 71 optimizedSnoop();
5d0e1901 72 Dbprintf("Trigger kicked! Value: %d, Dumping Samples Hispeed now.", r);
031311c7 73 }
0472d76d 74
031311c7 75 DbpString("HF Snoop end");
0472d76d 76 FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
77 LED_D_OFF();
78}
79
Impressum, Datenschutz