mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
additional init
This commit is contained in:
parent
5784999002
commit
eeb7ac981c
1 changed files with 32 additions and 19 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "hfops.h"
|
#include "hfops.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include "proxmark3_arm.h"
|
#include "proxmark3_arm.h"
|
||||||
#include "cmd.h"
|
#include "cmd.h"
|
||||||
#include "BigBuf.h"
|
#include "BigBuf.h"
|
||||||
|
@ -33,15 +34,19 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
|
||||||
if (ledcontrol) LEDsoff();
|
if (ledcontrol) LEDsoff();
|
||||||
|
|
||||||
BigBuf_Clear_ext(false);
|
BigBuf_Clear_ext(false);
|
||||||
|
// connect Demodulated Signal to ADC:
|
||||||
|
SetAdcMuxFor(GPIO_MUXSEL_HIPKD);
|
||||||
|
|
||||||
|
FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
|
||||||
// And put the FPGA in the appropriate mode
|
// And put the FPGA in the appropriate mode
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_MODE_RECEIVE_AMPLITUDE);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_HF_READER | FPGA_HF_READER_2SUBCARRIERS_424_484_KHZ | FPGA_HF_READER_MODE_RECEIVE_AMPLITUDE);
|
||||||
|
|
||||||
// Setup and start DMA.
|
// Setup and start DMA.
|
||||||
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
|
FpgaSetupSsc(FPGA_MAJOR_MODE_HF_READER);
|
||||||
|
|
||||||
// The DMA buffer, used to stream samples from the FPGA
|
// The DMA buffer, used to stream samples from the FPGA
|
||||||
dmabuf16_t *dma = get_dma16();
|
dmabuf16_t *dma = get_dma16();
|
||||||
|
memset((uint8_t *) dma->buf, 0, DMA_BUFFER_SIZE);
|
||||||
|
|
||||||
// Setup and start DMA.
|
// Setup and start DMA.
|
||||||
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
|
if (FpgaSetupSscDma((uint8_t *) dma->buf, DMA_BUFFER_SIZE) == false) {
|
||||||
|
@ -69,16 +74,24 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
|
||||||
if (behindBy == 0)
|
if (behindBy == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
uint16_t sample = *upTo;
|
// FPGA side:
|
||||||
logSample(sample & 0xff, 1, 8, false);
|
// corr_i_out <= {2'b00, corr_amplitude[13:8]};
|
||||||
logSample((sample >> 8) & 0xff, 1, 8, false);
|
// corr_q_out <= corr_amplitude[7:0];
|
||||||
upTo++;
|
// ci = upTo >> 8, cq = upTo
|
||||||
|
volatile uint16_t sample = *upTo++;
|
||||||
|
//if (sample & 0xc000) {
|
||||||
|
// Dbprintf("sample!!!! %d \r\n", getSampleCounter());
|
||||||
|
// break;
|
||||||
|
//}
|
||||||
|
|
||||||
|
logSample((sample >> 6) & 0xff, 1, 8, false);
|
||||||
|
|
||||||
if (getSampleCounter() >= samplesCount)
|
if (getSampleCounter() >= samplesCount)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (upTo >= dma->buf + DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
|
if (upTo >= dma->buf + DMA_BUFFER_SIZE) { // we have read all of the DMA buffer content.
|
||||||
upTo = dma->buf; // start reading the circular buffer from the beginning
|
upTo = dma->buf; // start reading the circular buffer from the beginning
|
||||||
|
}
|
||||||
|
|
||||||
// DMA Counter Register had reached 0, already rotated.
|
// DMA Counter Register had reached 0, already rotated.
|
||||||
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_ENDRX)) {
|
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_ENDRX)) {
|
||||||
|
@ -87,6 +100,7 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
|
||||||
if (AT91C_BASE_PDC_SSC->PDC_RCR == false) {
|
if (AT91C_BASE_PDC_SSC->PDC_RCR == false) {
|
||||||
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t) dma->buf;
|
AT91C_BASE_PDC_SSC->PDC_RPR = (uint32_t) dma->buf;
|
||||||
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
AT91C_BASE_PDC_SSC->PDC_RCR = DMA_BUFFER_SIZE;
|
||||||
|
Dbprintf("blew\r\n");
|
||||||
}
|
}
|
||||||
// secondary buffer sets as primary, secondary buffer was stopped
|
// secondary buffer sets as primary, secondary buffer was stopped
|
||||||
if (AT91C_BASE_PDC_SSC->PDC_RNCR == false) {
|
if (AT91C_BASE_PDC_SSC->PDC_RNCR == false) {
|
||||||
|
@ -97,7 +111,6 @@ int HfReadADC(uint32_t samplesCount, bool ledcontrol) {
|
||||||
WDT_HIT();
|
WDT_HIT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FpgaDisableSscDma();
|
FpgaDisableSscDma();
|
||||||
FpgaDisableTracing();
|
FpgaDisableTracing();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue