diff --git a/armsrc/appmain.c b/armsrc/appmain.c index c12f49196..69b628d7a 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -65,6 +65,9 @@ #include "spiffs.h" #endif +int DBGLEVEL = DBG_ERROR; +uint8_t g_trigger = 0; +bool g_hf_field_active = false; extern uint32_t _stack_start, _stack_end; struct common_area common_area __attribute__((section(".commonarea"))); static int button_status = BUTTON_NO_CLICK; @@ -88,6 +91,12 @@ int tearoff_hook(void) { } } +void hf_field_off(void) { + FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); + LEDsoff(); + g_hf_field_active = false; +} + void send_wtx(uint16_t wtx) { if (allow_send_wtx) { reply_ng(CMD_WTX, PM3_SUCCESS, (uint8_t *)&wtx, sizeof(wtx)); diff --git a/armsrc/appmain.h b/armsrc/appmain.h index 092e88d0e..1a12f2858 100644 --- a/armsrc/appmain.h +++ b/armsrc/appmain.h @@ -13,9 +13,9 @@ #include "common.h" -extern int g_rsamples; // = 0; extern uint8_t g_trigger; - +extern bool g_hf_field_active; +void hf_field_off(void); int tearoff_hook(void); // ADC Vref = 3300mV, and an (10M+1M):1M voltage divider on the HF input can measure voltages up to 36300 mV diff --git a/armsrc/hitagS.c b/armsrc/hitagS.c index 7a49d65cd..022730075 100644 --- a/armsrc/hitagS.c +++ b/armsrc/hitagS.c @@ -103,8 +103,6 @@ static bool end = false; #define HITAG_T_TAG_CAPTURE_THREE_HALF 41 #define HITAG_T_TAG_CAPTURE_FOUR_HALF 57 -#define DBGLEVEL 0 - /* * Implementation of the crc8 calculation from Hitag S * from http://www.proxmark.org/files/Documents/125%20kHz%20-%20Hitag/HitagS.V11.pdf diff --git a/armsrc/iso14443a.c b/armsrc/iso14443a.c index 0ca42c9ee..a70b9b953 100644 --- a/armsrc/iso14443a.c +++ b/armsrc/iso14443a.c @@ -28,12 +28,9 @@ #define MAX_ISO14A_TIMEOUT 524288 static uint32_t iso14a_timeout; -// if iso14443a not active - transmit/receive dont try to execute -static bool hf_field_active = false; static uint8_t colpos = 0; -int g_rsamples = 0; -uint8_t g_trigger = 0; + // the block number for the ISO14443-4 PCB static uint8_t iso14_pcb_blocknum = 0; @@ -1814,7 +1811,7 @@ static void PrepareDelayedTransfer(uint16_t delay) { //------------------------------------------------------------------------------------- static void TransmitFor14443a(const uint8_t *cmd, uint16_t len, uint32_t *timing) { - if (!hf_field_active) { + if (!g_hf_field_active) { Dbprintf("Warning: HF field is off, ignoring TransmitFor14443a command"); return; } @@ -2214,7 +2211,7 @@ bool EmLogTrace(uint8_t *reader_data, uint16_t reader_len, uint32_t reader_Start //----------------------------------------------------------------------------- bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint8_t *received_len) { - if (!hf_field_active) { + if (!g_hf_field_active) { Dbprintf("Warning: HF field is off, ignoring GetIso14443aAnswerFromTag_Thinfilm command"); return false; } @@ -2264,7 +2261,7 @@ bool GetIso14443aAnswerFromTag_Thinfilm(uint8_t *receivedResponse, uint8_t *rec static int GetIso14443aAnswerFromTag(uint8_t *receivedResponse, uint8_t *receivedResponsePar, uint16_t offset) { uint32_t c = 0; - if (!hf_field_active) + if (!g_hf_field_active) return false; // Set FPGA mode to "reader listen mode", no modulation (listen @@ -2758,13 +2755,7 @@ void iso14443a_setup(uint8_t fpga_minor_mode) { NextTransferTime = 2 * DELAY_ARM2AIR_AS_READER; iso14a_set_timeout(1060); // 106 * 10ms default - hf_field_active = true; -} - -void hf_field_off(void) { - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); - LEDsoff(); - hf_field_active = false; + g_hf_field_active = true; } /* Peter Fillmore 2015 diff --git a/armsrc/iso14443a.h b/armsrc/iso14443a.h index 200653764..49317628b 100644 --- a/armsrc/iso14443a.h +++ b/armsrc/iso14443a.h @@ -144,7 +144,6 @@ int iso14_apdu(uint8_t *cmd, uint16_t cmd_len, bool send_chaining, void *data, u int iso14443a_select_card(uint8_t *uid_ptr, iso14a_card_select_t *p_card, uint32_t *cuid_ptr, bool anticollision, uint8_t num_cascades, bool no_rats); int iso14443a_fast_select_card(uint8_t *uid_ptr, uint8_t num_cascades); void iso14a_set_trigger(bool enable); -void hf_field_off(void); int EmSendCmd14443aRaw(uint8_t *resp, uint16_t respLen); int EmSend4bit(uint8_t resp); diff --git a/armsrc/iso14443b.c b/armsrc/iso14443b.c index c3701dbfe..9d29e4cda 100644 --- a/armsrc/iso14443b.c +++ b/armsrc/iso14443b.c @@ -1365,6 +1365,7 @@ static void CodeAndTransmit14443bAsReader(const uint8_t *cmd, int len, uint32_t tosend_t *ts = get_tosend(); CodeIso14443bAsReader(cmd, len); TransmitFor14443b_AsReader(start_time); + if (g_trigger) LED_A_ON(); *eof_time = *start_time + (10 * ts->max) + 10 + 2 + 10; LogTrace(cmd, len, *start_time, *eof_time, NULL, true); } diff --git a/armsrc/mifareutil.c b/armsrc/mifareutil.c index 5d8989ef8..07cf7b098 100644 --- a/armsrc/mifareutil.c +++ b/armsrc/mifareutil.c @@ -20,8 +20,6 @@ #include "protocols.h" #include "desfire_crypto.h" -int DBGLEVEL = DBG_ERROR; - // crypto1 helpers void mf_crypto1_decryptEx(struct Crypto1State *pcs, uint8_t *data_in, int len, uint8_t *data_out) { if (len != 1) {