“We are trying to develop a USB Host HID application where using the controller STM32F4, and the USB stack library available on the ST website, we are trying to send data/command to an USB HID device. But in the library we downloaded from ST site, the host HID application has examples for mouse and keyboard application only.In case of Mouse and keyboard, Host receives but does not transmit back anything while in our application we need to also transmit data.
So do you have any particular HID host example codes or guideline documents for STM32F4xx controller which demonstrates how to transmit the data to the attached external USB device using the ST USB library? “,
How about the alignment of the buffer? The buff parameter of USBH_InterruptSendData() is fed to USB_OTG_WritePacket() as its src parameter. In this routine, src is expected to be aligned in 4 bytes (DWORD).
STM32_USB-Host-Device_Lib_V2.1.0\Libraries\STM32_USB_OTG_Driver\src\usb_core.c USB_OTG_STS USB_OTG_WritePacket(USB_OTG_CORE_HANDLE *pdev, uint8_t *src, uint8_t ch_ep_num, uint16_t len) { USB_OTG_STS status = USB_OTG_OK; if (pdev->cfg.dma_enable == 0) { uint32_t count32b= 0 , i= 0; __IO uint32_t *fifo; count32b = (len + 3) / 4; fifo = pdev->regs.DFIFO[ch_ep_num]; for (i = 0; i < count32b; i++, src+=4) { USB_OTG_WRITE_REG32( fifo, *((__packed uint32_t *)src) ); } } return status; }
Tsuneo
Hello, Actually project was on hold.
Thanks again for help.
In my case above function(As Mr.Tsuneo suggested) is not calling by below Interrupt routine for data transmitt
I want to transmit uint8_t Disp_braille_data[20]={0x1b,0x01,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x16,0x16}; I used USBH_InterruptSendData(pdev, Disp_braille_data,//HID_Machine.buff, 20,//HID_Machine.length, HID_Machine.hc_num_out);
Above function is calling
USB_OTG_STS USB_OTG_HC_StartXfer(USB_OTG_CORE_HANDLE *pdev , uint8_t hc_num) { ...... ...... ...... ...... ...... if (pdev->cfg.dma_enable == 1) { USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCDMA, (unsigned int)pdev->host.hc[hc_num].xfer_buff); } hcchar.d32 = USB_OTG_READ_REG32(&pdev->regs.HC_REGS[hc_num]->HCCHAR); hcchar.b.oddfrm = USB_OTG_IsEvenFrame(pdev); /* Set host channel enable */ hcchar.b.chen = 1; hcchar.b.chdis = 0; USB_OTG_WRITE_REG32(&pdev->regs.HC_REGS[hc_num]->HCCHAR, hcchar.d32); ...... ...... ...... ...... ...... }
Above function is transmitting data. Sniffer: Totalphase analyser resource:\STM32_F105-07_F2xx_USB-Host-Device_Lib_V2.0.0\Project\USB_Host_Examples\HID\MDK-ARM
Sniffer log: OUT txn : 00 1B 01 03 04 05 06 07 08 09 10 11 12 13 14 15 16 16 16 - OUT Packet : E1 01 C1 - DATA0 Packet : C3 00 1B 01 03 04 05 06 07 08 09 10 11 12 13 14 15 16 16 16 9B 26 - ACK Packet : D2 (Status ok)
So again question is same why 0x00 ahead of original data frame.
I tried but unable to find solution. So please help me.
Regards, Krunal