ChibiOS/testhal/STM32F4xx/USB_CDC

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Badger »

indigos wrote:
Badger wrote:On my linux I wrote a simple udev rule.

Thanks for those, they look handy. I ended up adding my user to the 'dialout' group which allowed me to access ttyACM0.
indigos
Posts: 14
Joined: Sat Jun 02, 2012 10:46 am

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by indigos »

Tectu wrote:I've never cared about USB before. Is there now any working example, which demonstrates how to use the USB driver of ChibiOS to do some stuff like USB HID or something else?

There is testhal/STM32F1xx/USB_MSC but I don't know is working. Actually I see only USB-CDC.
Tectu wrote:Maybe someone also got a linux-side example showing how to use the new /dev device?
for linux-side is better to use lib-usb.
- is present in every linux distributions
- lib-usb works also in windows and macosx so your code should be work also in other OS
- there are many projects and many examples for lib-usb
- very easy to use with good documentation
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

The MSC demo is not complete yet, it has been there for a while but always something with higher priority happens...

Giovanni
MartinP
Posts: 35
Joined: Mon Apr 02, 2012 11:54 am

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by MartinP »

Hi Giovanni,

your latest checkin for otgv1\usb_lld.c missed one rename dw-->w in line 334: *fifop = dw;
if I rename it to *fifop = w then compile works again

regards

Martin
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

Hi Martin,

Fixed thanks.

Giovanni
User avatar
Badger
Posts: 346
Joined: Mon Apr 18, 2011 6:07 pm

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Badger »

Code: Select all

void sduDataTransmitted(USBDriver *usbp, usbep_t ep) {
  size_t n;
  SerialUSBDriver *sdup = usbp->param;

  (void)ep;

  chSysLockFromIsr();
  chnAddFlagsI(sdup, CHN_OUTPUT_EMPTY);

  if ((n = chOQGetFullI(&sdup->oqueue)) > 0) {
    /* The endpoint cannot be busy, we are in the context of the callback,
       so it is safe to transmit without a check.*/
    chSysUnlockFromIsr();

    usbPrepareQueuedTransmit(sdup->config->usbp,
                             USB_CDC_DATA_REQUEST_EP,
                             &sdup->oqueue, n);

    chSysLockFromIsr();
    usbStartTransmitI(sdup->config->usbp, USB_CDC_DATA_REQUEST_EP);
  }

  chSysUnlockFromIsr();
}


is there a reason why usbPrepareQueuedTransmit and usbStartTransmitI both get a pointer to the USBDriver with sdup->config->usbp, rather than the seemingly obvious pointer that was passed to the function? (usbp)
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: ChibiOS/testhal/STM32F4xx/USB_CDC

Post by Giovanni »

There were other instances too, thanks for finding. Apparently just because I copied the code from the queue callbacks where "usbp" is not a parameter.

Giovanni
Post Reply