Page 1 of 1

API question about usbPrepareQueued... in Kernel 3.xx

Posted: Thu Mar 25, 2021 10:48 pm
by chibi21
Hi there,

I'm using the latest ChibiOS Version (20.3.3 => Kernel 6.1) on a STM32L052 and want to implement an usb hid driver. I found a sample project (ChibiOS/rawHID USB example from flabbergast). Unfortunately it was implemented for ChibiOS Kernel 3 and there exists a function called usbPrepareQueuedReceive and usbPrepareQueuedTransmit as well. These functions doesn't exist in Kernel 6 anymore. How can this be done in Kernel 6 ?

These are the In/Out functions for Endpoint 1 from the example:

Code: Select all

static void ep1in_cb (USBDriver *usbp, usbep_t ep)
{
  (void)usbp;
  (void)ep;

  chSysLockFromISR ();

  // Check if there is data to send in the output queue
  if (oqGetFullI (&usb_output_queue) >= USB_HID_IN_REPORT_SIZE)
    {
      chSysUnlockFromISR ();
      // Prepare the transmission
      usbPrepareQueuedTransmit (&USB_DRIVER, USBD1_IN_EP, &usb_output_queue, USB_HID_IN_REPORT_SIZE);
      chSysLockFromISR ();
      usbStartTransmitI (&USB_DRIVER, USBD1_IN_EP);
    }

  chSysUnlockFromISR ();
}

static void ep1out_cb (USBDriver *usbp, usbep_t ep)
{
  (void)usbp;
  (void)ep;

  chSysLockFromISR ();

  // Check if there is still some space left in the input queue
  if (iqGetEmptyI (&usb_input_queue) >= USB_HID_OUT_REPORT_SIZE)
    {
      chSysUnlockFromISR ();
      // Prepares the reception of new data
      usbPrepareQueuedReceive (&USB_DRIVER, USBD1_OUT_EP, &usb_input_queue, USB_HID_OUT_REPORT_SIZE);
      chSysLockFromISR ();
      usbStartReceiveI (&USB_DRIVER, USBD1_OUT_EP);
    }

  chSysUnlockFromISR ();
}


Has somebody an advice for me or usb hid implemented for STM32 in Kernel 6 ?

Thank you in advance.

Re: API question about usbPrepareQueued... in Kernel 3.xx

Posted: Fri Mar 26, 2021 6:37 am
by Giovanni
Hi,

You should look at current examples, the USB API has changed since then and there is no more queues support. A new "I/O buffers" mechanism is present and is used specifically for USB buffering, it is generally more efficient.

Note that queues are no more in the RT kernel, those are part of HAL now.

Giovanni