From 50722269b6e7b1ce8601ee2fc8d30100e5639d34 Mon Sep 17 00:00:00 2001 From: skamkar Date: Sat, 8 Aug 2009 07:42:51 +0000 Subject: [PATCH] detect usb or no usb for standalone mode [ryan] --- armsrc/appmain.c | 13 ++++++------- common/usb.c | 8 ++++++++ include/proxmark3.h | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 74448fe5..33df93c4 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -13,7 +13,6 @@ #include "LCD.h" #endif -int usbattached = 0; //============================================================================= // A buffer where we can queue things up to be sent through the FPGA, for @@ -64,8 +63,8 @@ void ToSendStuffBit(int b) void DbpString(char *str) { /* this holds up stuff unless we're connected to usb */ -// if (!usbattached) -// return; + if (!UsbConnected()) + return; UsbCommand c; c.cmd = CMD_DEBUG_PRINT_STRING; @@ -80,8 +79,8 @@ void DbpString(char *str) void DbpIntegers(int x1, int x2, int x3) { /* this holds up stuff unless we're connected to usb */ -// if (!usbattached) -// return; + if (!UsbConnected()) + return; UsbCommand c; c.cmd = CMD_DEBUG_PRINT_INTEGERS; @@ -266,7 +265,7 @@ void SamyRun() for (;;) { - usbattached = UsbPoll(FALSE); + UsbPoll(FALSE); WDT_HIT(); // Was our button held down or pressed? @@ -715,7 +714,7 @@ void AppMain(void) #endif for(;;) { - usbattached = UsbPoll(FALSE); + UsbPoll(FALSE); WDT_HIT(); if (BUTTON_HELD(1000) > 0) diff --git a/common/usb.c b/common/usb.c index f0b95291..50a9fc69 100644 --- a/common/usb.c +++ b/common/usb.c @@ -436,6 +436,14 @@ void UsbStart(void) } } +BOOL UsbConnected() +{ + if (UDP_GLOBAL_STATE & UDP_GLOBAL_STATE_CONFIGURED) + return TRUE; + else + return FALSE; +} + BOOL UsbPoll(BOOL blinkLeds) { BOOL ret = FALSE; diff --git a/include/proxmark3.h b/include/proxmark3.h index a94435e8..2f3b4838 100644 --- a/include/proxmark3.h +++ b/include/proxmark3.h @@ -52,6 +52,7 @@ typedef signed short SWORD; // USB declarations void UsbSendPacket(BYTE *packet, int len); +BOOL UsbConnected(); BOOL UsbPoll(BOOL blinkLeds); void UsbStart(void); -- 2.39.2