This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

usb hid to increase byte transfer from kit to pc

Dear freind,

i want to develop application to read adc value from stm32 kit to pc through usb.

for that i have transfer more bytes from kit to pc.

i have been using STM32_USBHID on kit side and HID_Client on host side.

also the application note below giving example to send more bytes from pc to kit.

http://www.keil.com/appnotes/docs/apnt_195.asp

my need is vice versa. to transfer 8/16/32/64 bytes from kit to pc instead of byte.

so please help me by providing sample application code to transfer more bytes from kit to pc

with regards

S.Venugopal

Parents Reply Children
  • Dear Mr.WesterMark

    sorry. i'm new to the forum. so that i'd noticed the formating.

    i'd modified as per your instruction in the following to send more bytes
    from kit to pc (for example 2 bytes)

    //*******************************************
    //in demo.c
    
    BYTE InReport[INREPORT_SIZE];
    
    void GetInReport (void) {
            InReport[1] = 0x55;
            InReport[0] = 0xaa;
    }
    //*******************************************
    //in demo.h
    
    #define INREPORT_SIZE   64
    extern BYTE   InReport[INREPORT_SIZE];
    //*******************************************
    //in usbuser.c
    
    #if USB_CONFIGURE_EVENT
    void USB_Configure_Event (void) {
    
    if (USB_Configuration){/*Check if USB is configured*/
        GetInReport();
        //USB_WriteEP(0x81, &InReport, sizeof(InReport));
        USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
      }
    }
    #endif
    
    void USB_EndPoint1 (DWORD event) {
      GetInReport();
    //  USB_WriteEP(0x81, &InReport, sizeof(InReport));
      USB_WriteEP(0x81, &InReport[0], sizeof(InReport));
    }
    //*******************************************
    //in hiduser.c
    
    BOOL HID_GetReport (void) {
    
      /* ReportID = SetupPacket.wValue.WB.L; */
      switch (SetupPacket.wValue.WB.H) {
        case HID_REPORT_INPUT:
          GetInReport();
            EP0Buf[0] = InReport[0];   //**********
            EP0Buf[1] = InReport[1];   //**********
          break;
        case HID_REPORT_OUTPUT:
          return (FALSE);        /* Not Supported */
        case HID_REPORT_FEATURE:
          /* EP0Buf[] = ...; */
          /* break; */
          return (FALSE);       /* Not Supported */
      }
      return (TRUE);
    }
    //*******************************************
    //in hiddesc.c
    
    /* HID Report Descriptor */
    const BYTE HID_ReportDescriptor[] = {
      HID_UsagePageVendor(0x00),
      HID_Usage(0x01),
      HID_Collection(HID_Application),
        HID_UsagePage(HID_USAGE_PAGE_BUTTON),
        HID_UsageMin(1),
        HID_UsageMax(2),
        HID_LogicalMin(0),
        HID_LogicalMax(0xff),
    //  HID_ReportCount(8),
    //  HID_ReportSize(2),
         HID_ReportCount(8),
         HID_ReportSize(INREPORT_SIZE),
        HID_Input(HID_Data | HID_Variable | HID_Absolute),
    //   HID_ReportCount(1),
    //   HID_ReportSize(6),
    //   HID_Input(HID_Constant),
        HID_UsagePage(HID_USAGE_PAGE_LED),
        HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR),
        HID_LogicalMin(0),
        HID_LogicalMax(1),
        HID_ReportCount(8),
        HID_ReportSize(1),
        HID_Output(HID_Data | HID_Variable | HID_Absolute),
      HID_EndCollection,
    };
    
    
    //in usb configuration
    //USB Configuration Descriptor
    
    const BYTE USB_ConfigDescriptor[] =
    
    //  WBVAL(0x0004),          /* wMaxPacketSize */
      WBVAL(0x0040),            /* wMaxPacketSize */
    //*******************************************
    //in the HID_Client VC++ program
    in the HIDClientDlg.cpp
    
    void CHIDClientDlg::OnInput()
    {
    //  int  n;
            int x,y;
      char buf[16];
    
            x = InReport[1];
            x = (x << 8);
            y = InReport[2];
            x = x | y ;
    
     // if (InValue == InReport[1]) return;
    //      if (z == x) return;
    //      z = x;
    //  InValue = InReport[1];
    
    //  for (n = 0; n < 8; n++) {
    //  m_Input[n].SetCheck((InValue & (1 << n)) ? 1 : 0);
    //  }
    //  sprintf(buf, "%04d", InValue);
            sprintf(buf, "%05x",x);
    
      m_In.SetWindowText(buf);
    }
    //*******************************************
    

    .

  • if you intend to send 2 bytes, why doesn't your report size reflect that?

    HID_ReportSize(1),
    

  • hi Tamir Michael,

    i'd modified the hid report size to 64 through Inreport size. it highlighted in Bold

    /* HID Report Descriptor */
    const BYTE HID_ReportDescriptor[] = {
      HID_UsagePageVendor(0x00),
      HID_Usage(0x01),
      HID_Collection(HID_Application),
        HID_UsagePage(HID_USAGE_PAGE_BUTTON),
        HID_UsageMin(1),
        HID_UsageMax(2),
        HID_LogicalMin(0),
        HID_LogicalMax(0xff),
    //  HID_ReportCount(8),
    //  HID_ReportSize(2),
     HID_ReportCount(8),
        HID_ReportSize(INREPORT_SIZE), 
        HID_Input(HID_Data | HID_Variable | HID_Absolute),
    

    only the output(Led indication) is 1 byte.

    with regards

    S.Venugopal