USB_over_Serial Understanding

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
yosoufe
Posts: 7
Joined: Thu Jan 26, 2017 1:34 pm
Has thanked: 1 time

USB_over_Serial Understanding

Postby yosoufe » Fri Apr 13, 2018 9:41 am

Hi,
I am totally new to chibios and I have learned MCU programming by myself. So totally newbie.

I am trying to use only HAL and USB over Serial with STM32F407_discovery board. I have checked the USC_CDC example as well but that one has ch.h.

I have managed to send data PC like a hello world example and I can see the board as ttyACMx device with only hal.h.

The problem is I do not have any understanding of the callbacks in the examples. I would highly appreciate if somebody describe when the following callback are called in the example:

  • usb_event,
  • get_descriptor,
  • sduRequestsHook,
  • sof_handler

My goal is:
for first step, when a letter received from the PC, a callback will be called, and inside that callback I respond according to the letter.

If what I want to do is totally against USB specifications, let me know.

I highly appreciate any link to any tutorials about the followings:

  • USB specification,
  • General Chibi/HAL tutorial,
  • General osalSys

I am googling a lot :D

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

Re: USB_over_Serial Understanding

Postby Giovanni » Fri Apr 13, 2018 10:10 am

Hi,

Many tutorials are located on www.playembedded.org, you may start from there.

About USB callbacks, the meaning of many of those thing is buried in thousands pages of the USB specifications, what I can say is that if you use the provided usbcfg.c/.h then you should be fine. Changes are only required if you need to use custom descriptors and/or add non-standard endpoints, very complex matter.

For example SOF is called at 1mS intervals and is triggered by the USB host polling the device.

Giovanni

yosoufe
Posts: 7
Joined: Thu Jan 26, 2017 1:34 pm
Has thanked: 1 time

Re: USB_over_Serial Understanding

Postby yosoufe » Mon Apr 16, 2018 10:10 am

Thanks,
which callback is called when a letter arrived over usb??

yosoufe
Posts: 7
Joined: Thu Jan 26, 2017 1:34 pm
Has thanked: 1 time

Re: USB_over_Serial Understanding

Postby yosoufe » Wed Apr 18, 2018 7:30 am

I still do not understand how this works??
The documentation is not enough for me to understand if this is the only documentation
http://chibios.sourceforge.net/docs3/ha ... u_s_b.html

Any link or guide how this works?? How should it be used???

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

Re: USB_over_Serial Understanding

Postby Giovanni » Wed Apr 18, 2018 7:33 am

Hi,

The way to proceed is to understand the various USB demos, if you use the Serial_USB driver the use is very simple, you don't have to mess with callbacks at all, it is all done internally. Those callbacks are used by the Serial_USB driver so there is no need to change anything.

Using callbacks is only required if you want to implement a custom protocol or device type which should not be your case.

Giovanni


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 1 guest