Arduino Due Peripheral with Xbox One Controller


hi all,

i've been working on trying port code usb host shield library usbhost library
in order let me use xbox 1 controller due.

i downloaded shield code from:
https://github.com/felis/usb_host_shield_2.0

followed guide posted here:
http://forum.arduino.cc/index.php?topic=283058.0

i know method works because successful in using xbox 360 controller this.
i compared original usb host shield library modded 1 in winmerge , made same changes xbox 1 code still naks.

after enabling debugging print statements in xboxone.cpp , usb.cpp, output shown here:
code: [select]

xbox 1 controller disconnected
 + usb_attached_substate_settle
 + usb_attached_substate_reset_device
 + usb_attached_substate_wait_reset_complete
 + usb_attached_substate_wait_sof
 + usb_state_configuring

xboxone initctrlreq
 nak_limit before 2848409796 bmnakpower16 nak_limit after 65535     => setaddress deviceep=0 configued hostpipe=0 sending address=0
     => dispatchpkt token=0 pipe=0 nak_limit=65535
    => ctrldata in
nak_limit ffff
     => dispatchpkt token=256 pipe=0 nak_limit=65535
     => dispatchpkt token=512 pipe=0 nak_limit=65535
   => usbhost::setaddr
    => ctrlreq
 nak_limit before 0 bmnakpower0 nak_limit after 0 => setaddress deviceep=0 configued hostpipe=0 sending address=0
     => dispatchpkt token=0 pipe=0 nak_limit=0
     => dispatchpkt token=256 pipe=0 nak_limit=0

addr: 1    => ctrlreq
 nak_limit before 532847 bmnakpower16 nak_limit after 65535     => setaddress deviceep=0 configued hostpipe=0 sending address=1
     => dispatchpkt token=0 pipe=0 nak_limit=65535
     => dispatchpkt token=256 pipe=0 nak_limit=65535

xbox 1 controller connected
 nak_limit before 0 bmnakpower1 nak_limit after 1     => setaddress deviceep=1 configued hostpipe=0 sending address=1
     => dispatchpkt token=512 pipe=0 nak_limit=1

xboxcommand, return: 0 nak_limit before 0 bmnakpower1 nak_limit after 1address deviceep=1 configued hostpipe=0 sending address=1
     => dispatchpkt token=512 pipe=0 nak_limit=1

xboxcommand, return: 0t::configuring : found device class!
 + usb_state_running
 nak_limit before 0 bmnakpower1 nak_limit after 1=> setaddress deviceep=1 configued hostpipe=0 sending address=1
rcode 0nak_limit 1
    => dispatchpkt token=256 pipe=0 nak_limit=1
rcode: 1

xbox 1 poll failed, error code: 1 nak_limit before 0 bmnakpower1 nak_limit after 1    => setaddress deviceep=1 configued hostpipe=0 sending address=1
rcode 0nak_limit 1
    => dispatchpkt token=256 pipe=0 nak_limit=1
rcode: 1

xbox 1 poll failed, error code: 1 nak_limit before 0 bmnakpower1 nak_limit after 1=> setaddress deviceep=1 configued hostpipe=0 sending address=1
rcode 0nak_limit 1
     => dispatchpkt token=256 pipe=0 nak_limit=1
rcode: 1


i added own print statements , followed through usb.cpp code find nak_limit gets set 1 , causes problem here.
a nak returned if nak_limit 1 , should problem.

code: [select]

 // nak received?
 if (is_uhd_nak_received(hostpipenum))
 {
 uhd_ack_nak_received(hostpipenum);
 nak_count++;

 if (nak_limit && (nak_count == nak_limit))
 {
 // return nak
 return 1;
 }
 }



nak_limit gets 1 in setpipeaddress function piece of code here:

nak_limit = (0x0001ul << (((*ppep)->bmnakpower > usb_nak_max_power ) ? usb_nak_max_power : (*ppep)->bmnakpower));
nak_limit--;

the problem bmnakpower gets set 1 somehow , that's lost.

i think key in how piece of code works in address.h

code: [select]

struct epinfo
{
 uint32_t deviceepnum; // device endpoint number
 uint32_t hostpipenum; // host corresponding pipe number
 uint32_t maxpktsize; // maximum packet size

 union
 {
 uint8_t epattribs;

 struct
 {
 uint8_t bmsndtoggle : 1; // send toggle, when 0 bmsndtog0, bmsndtog1 otherwise
 uint8_t bmrcvtoggle : 1; // send toggle, when 0 bmrcvtog0, bmrcvtog1 otherwise
 uint8_t bmnakpower : 6; // binary order nak_limit value
 };
 };
};


i believe epattribs, bmsndtoggle, bmrcvtoggle , bmnakpower linked same space of memory per union , 1 of them gets set 1 causing bmnakpower 1.

attached wip files usbhost library , test code.

if has done before or lead me in right direction please let me know!

thanks,

owen

i receiving similar problems, same library, logitech extreme 3d pro joystick.


Arduino Forum > Products > Arduino Due (Moderator: fabioc84) > Arduino Due Peripheral with Xbox One Controller


arduino

Comments