mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 13:23:51 -07:00
ARM code cleanup (lfops)
This commit is contained in:
parent
6f5cb60c46
commit
0d974852ce
2 changed files with 35 additions and 42 deletions
|
@ -25,7 +25,7 @@ void ToSendStuffBit(int b);
|
||||||
void ToSendReset(void);
|
void ToSendReset(void);
|
||||||
void ListenReaderField(int limit);
|
void ListenReaderField(int limit);
|
||||||
void AcquireRawAdcSamples125k(BOOL at134khz);
|
void AcquireRawAdcSamples125k(BOOL at134khz);
|
||||||
void DoAcquisition125k(BOOL at134khz);
|
void DoAcquisition125k(void);
|
||||||
extern int ToSendMax;
|
extern int ToSendMax;
|
||||||
extern BYTE ToSend[];
|
extern BYTE ToSend[];
|
||||||
extern DWORD BigBuf[];
|
extern DWORD BigBuf[];
|
||||||
|
@ -71,9 +71,8 @@ void SetAdcMuxFor(DWORD whichGpio);
|
||||||
|
|
||||||
/// lfops.h
|
/// lfops.h
|
||||||
void AcquireRawAdcSamples125k(BOOL at134khz);
|
void AcquireRawAdcSamples125k(BOOL at134khz);
|
||||||
void DoAcquisition125k(BOOL at134khz);
|
|
||||||
void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYTE *command);
|
void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYTE *command);
|
||||||
void ReadTItag();
|
void ReadTItag(void);
|
||||||
void WriteTItag(DWORD idhi, DWORD idlo, WORD crc);
|
void WriteTItag(DWORD idhi, DWORD idlo, WORD crc);
|
||||||
void AcquireTiType(void);
|
void AcquireTiType(void);
|
||||||
void AcquireRawBitsTI(void);
|
void AcquireRawBitsTI(void);
|
||||||
|
|
|
@ -13,13 +13,12 @@ int sprintf(char *dest, const char *fmt, ...);
|
||||||
|
|
||||||
void AcquireRawAdcSamples125k(BOOL at134khz)
|
void AcquireRawAdcSamples125k(BOOL at134khz)
|
||||||
{
|
{
|
||||||
if(at134khz) {
|
if (at134khz)
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
else
|
||||||
} else {
|
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
||||||
}
|
|
||||||
|
|
||||||
// Connect the A/D to the peak-detected low-frequency path.
|
// Connect the A/D to the peak-detected low-frequency path.
|
||||||
SetAdcMuxFor(GPIO_MUXSEL_LOPKD);
|
SetAdcMuxFor(GPIO_MUXSEL_LOPKD);
|
||||||
|
@ -31,37 +30,37 @@ void AcquireRawAdcSamples125k(BOOL at134khz)
|
||||||
FpgaSetupSsc();
|
FpgaSetupSsc();
|
||||||
|
|
||||||
// Now call the acquisition routine
|
// Now call the acquisition routine
|
||||||
DoAcquisition125k(at134khz);
|
DoAcquisition125k();
|
||||||
}
|
}
|
||||||
|
|
||||||
// split into two routines so we can avoid timing issues after sending commands //
|
// split into two routines so we can avoid timing issues after sending commands //
|
||||||
void DoAcquisition125k(BOOL at134khz)
|
void DoAcquisition125k(void)
|
||||||
{
|
{
|
||||||
BYTE *dest = (BYTE *)BigBuf;
|
BYTE *dest = (BYTE *)BigBuf;
|
||||||
int n = sizeof(BigBuf);
|
int n = sizeof(BigBuf);
|
||||||
int i;
|
int i;
|
||||||
char output_string[64];
|
char output_string[64];
|
||||||
|
|
||||||
memset(dest,0,n);
|
memset(dest, 0, n);
|
||||||
i = 0;
|
i = 0;
|
||||||
for(;;) {
|
for(;;) {
|
||||||
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
|
||||||
AT91C_BASE_SSC->SSC_THR = 0x43;
|
AT91C_BASE_SSC->SSC_THR = 0x43;
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
}
|
}
|
||||||
if(AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
|
||||||
dest[i] = (BYTE)AT91C_BASE_SSC->SSC_RHR;
|
dest[i] = (BYTE)AT91C_BASE_SSC->SSC_RHR;
|
||||||
i++;
|
i++;
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
if (i >= n) break;
|
if (i >= n) break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sprintf(output_string, "read samples, dest[0]=%x dest[1]=%x at134khz=%d",
|
sprintf(output_string, "read samples, dest[0]=%x dest[1]=%x",
|
||||||
dest[0], dest[1], at134khz);
|
dest[0], dest[1]);
|
||||||
DbpString(output_string);
|
DbpString(output_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYTE *command)
|
void ModThenAcquireRawAdcSamples125k(int delay_off, int period_0, int period_1, BYTE *command)
|
||||||
{
|
{
|
||||||
BOOL at134khz;
|
BOOL at134khz;
|
||||||
|
|
||||||
|
@ -70,18 +69,17 @@ void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYT
|
||||||
SpinDelay(2500);
|
SpinDelay(2500);
|
||||||
|
|
||||||
// see if 'h' was specified
|
// see if 'h' was specified
|
||||||
if(command[strlen((char *) command) - 1] == 'h')
|
if (command[strlen((char *) command) - 1] == 'h')
|
||||||
at134khz= TRUE;
|
at134khz = TRUE;
|
||||||
else
|
else
|
||||||
at134khz= FALSE;
|
at134khz = FALSE;
|
||||||
|
|
||||||
if(at134khz) {
|
if (at134khz)
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
else
|
||||||
} else {
|
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
||||||
}
|
|
||||||
|
|
||||||
// Give it a bit of time for the resonant antenna to settle.
|
// Give it a bit of time for the resonant antenna to settle.
|
||||||
SpinDelay(50);
|
SpinDelay(50);
|
||||||
|
@ -92,38 +90,34 @@ void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYT
|
||||||
FpgaSetupSsc();
|
FpgaSetupSsc();
|
||||||
|
|
||||||
// now modulate the reader field
|
// now modulate the reader field
|
||||||
while(*command != '\0' && *command != ' ')
|
while(*command != '\0' && *command != ' ') {
|
||||||
{
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
SpinDelayUs(delay_off);
|
SpinDelayUs(delay_off);
|
||||||
if(at134khz) {
|
if (at134khz)
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
else
|
||||||
} else {
|
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
||||||
}
|
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
if(*(command++) == '0') {
|
if(*(command++) == '0')
|
||||||
SpinDelayUs(period_0);
|
SpinDelayUs(period_0);
|
||||||
} else {
|
else
|
||||||
SpinDelayUs(period_1);
|
SpinDelayUs(period_1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
|
||||||
LED_D_OFF();
|
LED_D_OFF();
|
||||||
SpinDelayUs(delay_off);
|
SpinDelayUs(delay_off);
|
||||||
if(at134khz) {
|
if (at134khz)
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 88); //134.8Khz
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
else
|
||||||
} else {
|
|
||||||
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
FpgaSendCommand(FPGA_CMD_SET_DIVISOR, 95); //125Khz
|
||||||
|
|
||||||
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER);
|
||||||
}
|
|
||||||
|
|
||||||
// now do the read
|
// now do the read
|
||||||
DoAcquisition125k(at134khz);
|
DoAcquisition125k();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* blank r/w tag data stream
|
/* blank r/w tag data stream
|
||||||
|
@ -135,7 +129,7 @@ void ModThenAcquireRawAdcSamples125k(int delay_off,int period_0,int period_1,BYT
|
||||||
|
|
||||||
[5555fe852c5555555555555555fe0000]
|
[5555fe852c5555555555555555fe0000]
|
||||||
*/
|
*/
|
||||||
void ReadTItag()
|
void ReadTItag(void)
|
||||||
{
|
{
|
||||||
// some hardcoded initial params
|
// some hardcoded initial params
|
||||||
// when we read a TI tag we sample the zerocross line at 2Mhz
|
// when we read a TI tag we sample the zerocross line at 2Mhz
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue