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

Discussions and support about ChibiOS/RT, the free embedded RTOS.
chibi21
Posts: 1
Joined: Thu Mar 25, 2021 3:12 pm

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

Postby chibi21 » Thu Mar 25, 2021 10:48 pm

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.

User avatar
Giovanni
Site Admin
Posts: 13427
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 836 times
Been thanked: 730 times
Contact:

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

Postby Giovanni » Fri Mar 26, 2021 6:37 am

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


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 4 guests