mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
CtrlReq callback bugfix
This commit is contained in:
parent
cf1611cb48
commit
bc40559679
2 changed files with 11 additions and 6 deletions
12
Usb.cpp
12
Usb.cpp
|
@ -153,7 +153,7 @@ uint8_t USB::ctrlReq( uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequ
|
|||
|
||||
rcode = InTransfer( pep, nak_limit, &read, dataptr );
|
||||
|
||||
if (rcode /*&& rcode != hrSTALL*/)
|
||||
if (rcode)
|
||||
return rcode;
|
||||
|
||||
// Invoke callback function if inTransfer completed successfuly and callback function pointer is specified
|
||||
|
@ -161,6 +161,9 @@ uint8_t USB::ctrlReq( uint8_t addr, uint8_t ep, uint8_t bmReqType, uint8_t bRequ
|
|||
((USBReadParser*)p)->Parse( read, dataptr, total - left );
|
||||
|
||||
left -= read;
|
||||
|
||||
if (read < nbytes)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else //OUT transfer
|
||||
|
@ -222,15 +225,16 @@ uint8_t USB::InTransfer(EpInfo *pep, uint16_t nak_limit, uint16_t *nbytesptr, ui
|
|||
if (mem_left < 0)
|
||||
mem_left = 0;
|
||||
|
||||
data = bytesRd( rRCVFIFO, (pktsize > mem_left) ? mem_left : pktsize, data );
|
||||
data = bytesRd( rRCVFIFO, ((pktsize > mem_left) ? mem_left : pktsize), data );
|
||||
|
||||
regWr( rHIRQ, bmRCVDAVIRQ ); // Clear the IRQ & free the buffer
|
||||
*nbytesptr += pktsize; // add this packet's byte count to total transfer length
|
||||
|
||||
/* The transfer is complete under two conditions: */
|
||||
/* 1. The device sent a short packet (L.T. maxPacketSize) */
|
||||
/* 2. 'nbytes' have been transferred. */
|
||||
if (( pktsize < maxpktsize ) || (*nbytesptr >= nbytes )) // have we transferred 'nbytes' bytes?
|
||||
{
|
||||
if (/*pktsize == 6 ||*/ ( pktsize < maxpktsize ) || (*nbytesptr >= nbytes )) // have we transferred 'nbytes' bytes?
|
||||
{
|
||||
// Save toggle value
|
||||
pep->bmRcvToggle = ( regRd( rHRSL ) & bmRCVTOGRD ) ? 1 : 0;
|
||||
|
||||
|
|
5
hid.cpp
5
hid.cpp
|
@ -2,8 +2,8 @@
|
|||
|
||||
//const uint16_t HID::maxHidInterfaces = 3;
|
||||
//const uint16_t HID::maxEpPerInterface = 2;
|
||||
const uint8_t HID::epInterruptInIndex = 0;
|
||||
const uint8_t HID::epInterruptOutIndex = 1;
|
||||
const uint8_t HID::epInterruptInIndex = 1;
|
||||
const uint8_t HID::epInterruptOutIndex = 2;
|
||||
|
||||
HID::HID(USB *p) :
|
||||
pUsb(p),
|
||||
|
@ -278,6 +278,7 @@ uint8_t HID::Release()
|
|||
{
|
||||
pUsb->GetAddressPool().FreeAddress(bAddress);
|
||||
|
||||
bNumEP = 1;
|
||||
bAddress = 0;
|
||||
qNextPollTime = 0;
|
||||
bPollEnable = false;
|
||||
|
|
Loading…
Reference in a new issue