Skip to content

Commit 616475a

Browse files
committed
fix random init() call, set debug output to Serial1
1 parent 440afc5 commit 616475a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

libraries/USBHost/src/Usb.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ USBHost::USBHost() : bmHubPre(0) {
3636
uint32_t USBHost::Init() {
3737
//devConfigIndex = 0;
3838
// Init host stack
39-
init();
4039
bmHubPre = 0;
4140
UHD_Init();
4241
return 0;
@@ -124,7 +123,7 @@ uint32_t USBHost::SetPipeAddress(uint32_t addr, uint32_t ep, EpInfo **ppep, uint
124123
/* 01-0f = non-zero HRSLT */
125124
uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t bRequest, uint8_t wValLo, uint8_t wValHi,
126125
uint16_t wInd, uint16_t total, uint32_t nbytes, uint8_t* dataptr, USBReadParser *p) {
127-
126+
128127
uint32_t direction = 0; // Request direction, IN or OUT
129128
uint32_t rcode;
130129
SETUP_PKT setup_pkt;
@@ -143,7 +142,7 @@ uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t
143142
if (rcode)
144143
{
145144
TRACE_USBHOST(printf("/!\\ USBHost::ctrlReq : EP0 allocation error: %lu\r\n", rcode);)
146-
//USBTRACE2("\n\rUSBHost::ctrlReq : EP0 allocation error: ", rcode");
145+
//USBTRACE2("\n\rUSBHost::ctrlReq : EP0 allocation error: ", rcode");
147146
return rcode;
148147
}
149148

@@ -195,14 +194,14 @@ uint32_t USBHost::ctrlReq(uint32_t addr, uint32_t ep, uint8_t bmReqType, uint8_t
195194
((USBReadParser*)p)->Parse(read, dataptr, total - left);
196195
}
197196
else // OUT transfer
198-
{
197+
{
199198
pep->bmSndToggle = 1; //bmSNDTOG1;
200199
rcode = OutTransfer(pep, nak_limit, nbytes, dataptr);
201200
}
202201
if(rcode) //return error
203202
return (rcode);
204203
}
205-
204+
206205
// Status stage
207206
UHD_Pipe_CountZero(pep->epAddr);
208207
USB->HOST.HostPipe[pep->epAddr].PSTATUSSET.reg = USB_HOST_PSTATUSSET_DTGL;
@@ -268,11 +267,11 @@ uint32_t USBHost::InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr
268267
}
269268
/* check for RCVDAVIRQ and generate error if not present */
270269
/* the only case when absence of RCVDAVIRQ makes sense is when toggle error occurred. Need to add handling for that */
271-
270+
272271
pktsize = uhd_byte_count(pep->epAddr); // Number of received bytes
273-
272+
274273
USB->HOST.HostPipe[pep->epAddr].PSTATUSCLR.reg = USB_HOST_PSTATUSCLR_BK0RDY;
275-
274+
276275
//printf("Got %i bytes \r\n", pktsize);
277276
// This would be OK, but...
278277
//assert(pktsize <= nbytes);
@@ -297,7 +296,7 @@ uint32_t USBHost::InTransfer(EpInfo *pep, uint32_t nak_limit, uint8_t *nbytesptr
297296
/* 1. The device sent a short packet (L.T. maxPacketSize) */
298297
/* 2. 'nbytes' have been transferred. */
299298
if((pktsize < maxpktsize) || (*nbytesptr >= nbytes)) // have we transferred 'nbytes' bytes?
300-
{
299+
{
301300
// Save toggle value
302301
pep->bmRcvToggle = USB_HOST_DTGL(pep->epAddr);
303302
//printf("\r\n");
@@ -494,8 +493,7 @@ void USBHost::Task(void) //USB state machine
494493
TRACE_USBHOST(printf(" + USB_DETACHED_SUBSTATE_INITIALIZE\r\n");)
495494

496495
// Init USB stack and driver
497-
UHD_Init();
498-
init();
496+
Init();
499497

500498
// Free all USB resources
501499
for (uint32_t i = 0; i < USB_NUMDEVICES; ++i)

libraries/USBHost/src/Usb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ e-mail : support@circuitsathome.com
2727
// None of these should ever be included by a driver, or a user's sketch.
2828

2929
#include "variant.h"
30-
#define USB_HOST_SERIAL SERIAL_PORT_MONITOR
30+
#define USB_HOST_SERIAL Serial1
3131
#include "Print.h"
3232
#include "printhex.h"
3333
#include "message.h"

0 commit comments

Comments
 (0)