mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
styling
This commit is contained in:
parent
45a1a83752
commit
5665de56e9
1 changed files with 47 additions and 51 deletions
|
@ -8,12 +8,10 @@
|
|||
// Low frequency EM4x50 commands
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "BigBuf.h"
|
||||
#include "fpgaloader.h"
|
||||
#include "ticks.h"
|
||||
#include "dbprint.h"
|
||||
#include "lfadc.h"
|
||||
#include "lfsampling.h"
|
||||
#include "commonutil.h"
|
||||
#include "em4x50.h"
|
||||
|
||||
|
@ -74,7 +72,6 @@ static em4x50_tag_t tag = {
|
|||
#define EM4X50_T_TAG_HALF_PERIOD 32
|
||||
#define EM4X50_T_TAG_THREE_QUARTER_PERIOD 48
|
||||
#define EM4X50_T_TAG_FULL_PERIOD 64
|
||||
#define EM4X50_T_TAG_THREE_HALF_PERIOD 96
|
||||
#define EM4X50_T_TAG_TPP 64
|
||||
#define EM4X50_T_TAG_TWA 64
|
||||
#define EM4X50_T_WAITING_FOR_SNGLLIW 100
|
||||
|
@ -82,13 +79,11 @@ static em4x50_tag_t tag = {
|
|||
|
||||
#define EM4X50_TAG_TOLERANCE 8
|
||||
#define EM4X50_TAG_WORD 45
|
||||
#define EM4X50_SAMPLE_CNT_MAX 3000
|
||||
|
||||
#define EM4X50_BIT_0 0
|
||||
#define EM4X50_BIT_1 1
|
||||
#define EM4X50_BIT_OTHER 2
|
||||
|
||||
#define EM4X50_COMMAND_REQUEST 2
|
||||
#define EM4X50_COMMAND_LOGIN 0x01
|
||||
#define EM4X50_COMMAND_RESET 0x80
|
||||
#define EM4X50_COMMAND_WRITE 0x12
|
||||
|
@ -246,7 +241,6 @@ static bool get_signalproperties(void) {
|
|||
|
||||
bool signal_found = false;
|
||||
int no_periods = 32, pct = 75, noise = 140;
|
||||
uint8_t sample = 0;
|
||||
uint8_t sample_ref = 127;
|
||||
uint8_t sample_max_mean = 0;
|
||||
uint8_t sample_max[no_periods];
|
||||
|
@ -279,7 +273,7 @@ static bool get_signalproperties(void) {
|
|||
|
||||
if (BUTTON_PRESS()) return false;
|
||||
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
if (sample > sample_max[i])
|
||||
sample_max[i] = sample;
|
||||
|
||||
|
@ -324,10 +318,9 @@ static uint32_t get_pulse_length(void) {
|
|||
|
||||
// Dbprintf( _CYAN_("4x50 get_pulse_length A") );
|
||||
|
||||
int timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
int32_t timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
|
||||
// iterates pulse length (low -> high -> low)
|
||||
// to avoid endless loops - quit if timeout = 0
|
||||
|
||||
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
|
||||
|
@ -339,8 +332,8 @@ static uint32_t get_pulse_length(void) {
|
|||
return 0;
|
||||
|
||||
AT91C_BASE_TC1->TC_CCR = AT91C_TC_SWTRG;
|
||||
|
||||
timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
|
||||
while (sample < gHigh && (timeout--)) {
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
}
|
||||
|
@ -349,7 +342,7 @@ static uint32_t get_pulse_length(void) {
|
|||
return 0;
|
||||
|
||||
timeout = (T0 * 3 * EM4X50_T_TAG_FULL_PERIOD);
|
||||
while (sample > gLow && (timeout--) ) {
|
||||
while (sample > gLow && (timeout--)) {
|
||||
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
|
||||
}
|
||||
|
||||
|
@ -401,7 +394,7 @@ static void em4x50_reader_send_byte(uint8_t byte) {
|
|||
// send byte (without parity)
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
em4x50_reader_send_bit((byte >> (7-i)) & 1);
|
||||
em4x50_reader_send_bit((byte >> (7 - i)) & 1);
|
||||
|
||||
}
|
||||
|
||||
|
@ -412,7 +405,7 @@ static void em4x50_reader_send_byte_with_parity(uint8_t byte) {
|
|||
int parity = 0, bit = 0;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
bit = (byte >> (7-i)) & 1;
|
||||
bit = (byte >> (7 - i)) & 1;
|
||||
em4x50_reader_send_bit(bit);
|
||||
parity ^= bit;
|
||||
}
|
||||
|
@ -777,9 +770,10 @@ static bool selective_read(uint8_t addresses[4]) {
|
|||
// send address data
|
||||
em4x50_reader_send_word(addresses);
|
||||
|
||||
// look for ACK sequence -> save and verify via standard read mode
|
||||
// (compare number of words)
|
||||
// look for ACK sequence
|
||||
if (check_ack(false))
|
||||
|
||||
// save and verify via standard read mode (compare number of words)
|
||||
if (standard_read(&now))
|
||||
if (now == (lwr - fwr + 1))
|
||||
return true;
|
||||
|
@ -846,7 +840,8 @@ void em4x50_read(em4x50_data_t *etd) {
|
|||
em4x50_setup_read();
|
||||
|
||||
// set gHigh and gLow
|
||||
if (get_signalproperties()) {//} && find_em4x50_tag()) {
|
||||
if (get_signalproperties() && find_em4x50_tag()) {
|
||||
|
||||
if (etd->addr_given) {
|
||||
|
||||
// selective read mode
|
||||
|
@ -863,6 +858,7 @@ void em4x50_read(em4x50_data_t *etd) {
|
|||
|
||||
// standard read mode
|
||||
bsuccess = standard_read(&now);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1169,7 +1165,7 @@ bool em4x50_sim_send_word(uint32_t word) {
|
|||
|
||||
// 4 bytes each with even row parity bit
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (!em4x50_sim_send_byte_with_parity( (word >> ((3 - i) * 8)) & 0xFF))
|
||||
if (!em4x50_sim_send_byte_with_parity((word >> ((3 - i) * 8)) & 0xFF))
|
||||
return false;
|
||||
|
||||
// column parity
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue