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 Device Custom Class - MDK Pro Pack Middleware 6.1.0

I am looking for an example or documentation on creating a custom USB device class with the MDK Pro Pack Middleware v6.1.0 for the NXP LPC43xx series processor. When I look at the documentation accessible by double clicking on the USB component class icon and navigate to "USB Device->USB Device Examples->Custom USB Device" I am greeted with a helpful "More information coming soon" page.

Furthermore the documentation on the Device Class Functions is not very helpful or thorough in providing any help in designing a custom device using the MDK-Pro Middleware's USB library.

At the moment the device will show up in windows but a USB Device Not Recognized balloon pops up. On sniffing the bus traffic I see that the device never responds to a GET_DESCRIPTOR Setup packet request. Where does this need to get implemented? I thought that using the wizards associated with USBD_Config_CustomClass.h and USBD_Config.c would configure the proper information and then let the library handle descriptor requests. Unfortunately there is NO Documentation to tell me if that is correct or not.

Any documentation or example code would be much appreciated!

Parents
  • Hi,

    here is example of two functions needed to implement for Endpoint 1 Bulk IN and Endpoint 1 Bulk OUT communication on Custom Class.

    void USBD_CustomClass0_EventEndpointStart (uint8_t ep_addr) {
      // Start communication on Endpoint
    
      if (!(ep_addr & 0x80)) {              // If Endpoint type is OUT
        switch (ep_addr & 0x0F) {
          case 1:
            USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64);
            break;
          default:
            break;
        }
      }
    }
    

    so when start is called, reception on Bulk OUT is started with USBD_EndpointRead

    void USBD_CustomClass0_Endpoint1_Event  (uint32_t event) {
      // Handle Endpoint 1 events
      uint32_t i;
    
      switch (event) {
        case ARM_USBD_EVENT_OUT:
          class0_bulk_len = USBD_EndpointReadGetResult(0, USB_ENDPOINT_OUT(1));
          USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64);
          switch (class0_bulk_out_buf[0]) {
            case 0:
              for (i = 1; i < class0_bulk_len; i++)
                class0_bulk_in_buf[i] = (class0_bulk_out_buf[i] << 4);
              USBD_EndpointWrite(0, USB_ENDPOINT_IN(1), class0_bulk_in_buf, class0_bulk_len);
              break;
          }
          break;
        case ARM_USBD_EVENT_IN:
          break;
        default:
          break;
      }
    };
    

    in this function case ARM_USBD_EVENT_OUT is entered when data was received on Bulk OUT Endpoint, number of received bytes is read with USBD_EndpointReadGetResult then new reception is started on Bulk OUT Endpoint with USBD_EndpointRead and response is returned on Bulk IN Endpoint with USBD_EndpointWrite function

Reply
  • Hi,

    here is example of two functions needed to implement for Endpoint 1 Bulk IN and Endpoint 1 Bulk OUT communication on Custom Class.

    void USBD_CustomClass0_EventEndpointStart (uint8_t ep_addr) {
      // Start communication on Endpoint
    
      if (!(ep_addr & 0x80)) {              // If Endpoint type is OUT
        switch (ep_addr & 0x0F) {
          case 1:
            USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64);
            break;
          default:
            break;
        }
      }
    }
    

    so when start is called, reception on Bulk OUT is started with USBD_EndpointRead

    void USBD_CustomClass0_Endpoint1_Event  (uint32_t event) {
      // Handle Endpoint 1 events
      uint32_t i;
    
      switch (event) {
        case ARM_USBD_EVENT_OUT:
          class0_bulk_len = USBD_EndpointReadGetResult(0, USB_ENDPOINT_OUT(1));
          USBD_EndpointRead(0, USB_ENDPOINT_OUT(1), class0_bulk_out_buf, 64);
          switch (class0_bulk_out_buf[0]) {
            case 0:
              for (i = 1; i < class0_bulk_len; i++)
                class0_bulk_in_buf[i] = (class0_bulk_out_buf[i] << 4);
              USBD_EndpointWrite(0, USB_ENDPOINT_IN(1), class0_bulk_in_buf, class0_bulk_len);
              break;
          }
          break;
        case ARM_USBD_EVENT_IN:
          break;
        default:
          break;
      }
    };
    

    in this function case ARM_USBD_EVENT_OUT is entered when data was received on Bulk OUT Endpoint, number of received bytes is read with USBD_EndpointReadGetResult then new reception is started on Bulk OUT Endpoint with USBD_EndpointRead and response is returned on Bulk IN Endpoint with USBD_EndpointWrite function

Children