cancel
Showing results for 
Search instead for 
Did you mean: 

USB Host Interrupt OUT

Richard Lowe
Senior III
Posted on May 15, 2018 at 01:08

STM32L4xx

HAL 1.11 Framework

Modifying the ST USB Host library to include the missing states in the

static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost)�?�?

method that runs the HID Class.

SEND_DATA - for sending packets TO the HID device

BUSY - used as a polling state after data sent.

Wondering if the USB experts on here can look at the state transitions and validate the state and transition correctness.

0690X0000060KigQAE.png

The last question is Data0/Data1 toggling. It appears that is happening somewhere in a lower level. Do I need to manually toggle the Data0/Data1 in the state?

#usb-hid #usb_host
1 ACCEPTED SOLUTION

Accepted Solutions
Richard Lowe
Senior III
Posted on May 17, 2018 at 19:01

Or for larger than single frames:

0690X0000060KpBQAU.png

View solution in original post

3 REPLIES 3
Richard Lowe
Senior III
Posted on May 15, 2018 at 08:19

I believe I've found the answer to the last question, 'does the data0/data1 need to be manually toggled'.

In the interrupt handler located in `stm32l4xx_hal_hcd.c` file:

static void HCD_HC_IN_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum)
{
...
else if(hhcd->hc[chnum].ep_type == EP_TYPE_INTR)
 {
 USBx_HC(chnum)->HCCHAR |= USB_OTG_HCCHAR_ODDFRM;
 hhcd->hc[chnum].urb_state = URB_DONE; 
 HAL_HCD_HC_NotifyURBChange_Callback(hhcd, chnum, hhcd->hc[chnum].urb_state);
 }
 hhcd->hc[chnum].toggle_in ^= 1;
...�?�?�?�?�?�?�?�?�?�?�?�?

The last line is the toggle.

Richard Lowe
Senior III
Posted on May 17, 2018 at 19:01

Or for larger than single frames:

0690X0000060KpBQAU.png
Richard Lowe
Senior III
Posted on May 28, 2018 at 21:52

static void HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum)�?

Tested. The above state transitions work with the existing ST HOST USB Library. However, I did find that the OutPipe does not toggle the Data0/1 line like the InPIpe does. Bug? Adding a data toggle after a successful frame transfer solved the issue.

case HID_BUSY:
 if(USBH_LL_GetURBState(phost, HID_Handle->OutPipe) == USBH_URB_DONE)
 {
 USBH_LL_SetToggle(phost, HID_Handle->OutPipe, 1 ^ USBH_LL_GetToggle(phost, HID_Handle->OutPipe));
�?�?�?�?�?�?�?�?�?

Confirmed: Out Interrupt handler doesn't implement an Interrupt transfer data toggle.

static void HCD_HC_OUT_IRQHandler (HCD_HandleTypeDef *hhcd, uint8_t chnum)�?