mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Added delay before bus reset and renamed some variables and cleanup example
This commit is contained in:
parent
859c9d0f80
commit
52858d502b
3 changed files with 59 additions and 56 deletions
10
XBOXRECV.cpp
10
XBOXRECV.cpp
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "XBOXRECV.h"
|
#include "XBOXRECV.h"
|
||||||
// To enable serial debugging uncomment "#define DEBUG_USB_HOST" in message.h
|
// To enable serial debugging see "settings.h"
|
||||||
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
//#define EXTRADEBUG // Uncomment to get even more debugging data
|
||||||
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
//#define PRINTREPORT // Uncomment to print the report send by the Xbox 360 Controller
|
||||||
|
|
||||||
|
@ -106,6 +106,8 @@ uint8_t XBOXRECV::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
|
epInfo[0].maxPktSize = (uint8_t)((USB_DEVICE_DESCRIPTOR*)buf)->bMaxPacketSize0; // Extract Max Packet Size from device descriptor
|
||||||
epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
|
epInfo[1].epAddr = ((USB_DEVICE_DESCRIPTOR*)buf)->bNumConfigurations; // Steal and abuse from epInfo structure to save memory
|
||||||
|
|
||||||
|
delay(20); // Wait a little before resetting device
|
||||||
|
|
||||||
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
return USB_ERROR_CONFIG_REQUIRES_ADDITIONAL_RESET;
|
||||||
|
|
||||||
/* Diagnostic messages */
|
/* Diagnostic messages */
|
||||||
|
@ -254,6 +256,7 @@ uint8_t XBOXRECV::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
#endif
|
#endif
|
||||||
XboxReceiverConnected = true;
|
XboxReceiverConnected = true;
|
||||||
bPollEnable = true;
|
bPollEnable = true;
|
||||||
|
checkStatusTimer = 0; // Reset timer
|
||||||
return 0; // Successful configuration
|
return 0; // Successful configuration
|
||||||
|
|
||||||
/* Diagnostic messages */
|
/* Diagnostic messages */
|
||||||
|
@ -298,10 +301,11 @@ uint8_t XBOXRECV::Release() {
|
||||||
uint8_t XBOXRECV::Poll() {
|
uint8_t XBOXRECV::Poll() {
|
||||||
if (!bPollEnable)
|
if (!bPollEnable)
|
||||||
return 0;
|
return 0;
|
||||||
if (!timer || ((millis() - timer) > 3000)) { // Run checkStatus every 3 seconds
|
if (!checkStatusTimer || ((millis() - checkStatusTimer) > 3000)) { // Run checkStatus every 3 seconds
|
||||||
timer = millis();
|
checkStatusTimer = millis();
|
||||||
checkStatus();
|
checkStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t inputPipe;
|
uint8_t inputPipe;
|
||||||
uint16_t bufferSize;
|
uint16_t bufferSize;
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
|
|
|
@ -259,7 +259,7 @@ private:
|
||||||
bool L2Clicked[4]; // These buttons are analog, so we use we use these bools to check if they where clicked or not
|
bool L2Clicked[4]; // These buttons are analog, so we use we use these bools to check if they where clicked or not
|
||||||
bool R2Clicked[4];
|
bool R2Clicked[4];
|
||||||
|
|
||||||
unsigned long timer; // Timing for checkStatus() signals
|
uint32_t checkStatusTimer; // Timing for checkStatus() signals
|
||||||
|
|
||||||
uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data
|
uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data
|
||||||
uint8_t writeBuf[7]; // General purpose buffer for output data
|
uint8_t writeBuf[7]; // General purpose buffer for output data
|
||||||
|
|
|
@ -108,5 +108,4 @@ void loop() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(1);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue