detect usb or no usb for standalone mode [ryan]

This commit is contained in:
skamkar 2009-08-08 07:42:51 +00:00
parent 14ac2f1ea0
commit 50722269b6
3 changed files with 15 additions and 7 deletions

View file

@ -13,7 +13,6 @@
#include "LCD.h" #include "LCD.h"
#endif #endif
int usbattached = 0;
//============================================================================= //=============================================================================
// A buffer where we can queue things up to be sent through the FPGA, for // 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) void DbpString(char *str)
{ {
/* this holds up stuff unless we're connected to usb */ /* this holds up stuff unless we're connected to usb */
// if (!usbattached) if (!UsbConnected())
// return; return;
UsbCommand c; UsbCommand c;
c.cmd = CMD_DEBUG_PRINT_STRING; c.cmd = CMD_DEBUG_PRINT_STRING;
@ -80,8 +79,8 @@ void DbpString(char *str)
void DbpIntegers(int x1, int x2, int x3) void DbpIntegers(int x1, int x2, int x3)
{ {
/* this holds up stuff unless we're connected to usb */ /* this holds up stuff unless we're connected to usb */
// if (!usbattached) if (!UsbConnected())
// return; return;
UsbCommand c; UsbCommand c;
c.cmd = CMD_DEBUG_PRINT_INTEGERS; c.cmd = CMD_DEBUG_PRINT_INTEGERS;
@ -266,7 +265,7 @@ void SamyRun()
for (;;) for (;;)
{ {
usbattached = UsbPoll(FALSE); UsbPoll(FALSE);
WDT_HIT(); WDT_HIT();
// Was our button held down or pressed? // Was our button held down or pressed?
@ -715,7 +714,7 @@ void AppMain(void)
#endif #endif
for(;;) { for(;;) {
usbattached = UsbPoll(FALSE); UsbPoll(FALSE);
WDT_HIT(); WDT_HIT();
if (BUTTON_HELD(1000) > 0) if (BUTTON_HELD(1000) > 0)

View file

@ -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 UsbPoll(BOOL blinkLeds)
{ {
BOOL ret = FALSE; BOOL ret = FALSE;

View file

@ -52,6 +52,7 @@ typedef signed short SWORD;
// USB declarations // USB declarations
void UsbSendPacket(BYTE *packet, int len); void UsbSendPacket(BYTE *packet, int len);
BOOL UsbConnected();
BOOL UsbPoll(BOOL blinkLeds); BOOL UsbPoll(BOOL blinkLeds);
void UsbStart(void); void UsbStart(void);