Page 11 of 12

Re: example interfacing a STM32F4 with libusb

Posted: Fri Aug 17, 2012 9:52 am
by Mathias
Giovanni wrote:There are three new configuration option that should be considered when using this driver.

Do you mean "txpending", "thd_ptr" and "thd_wait" ? Those are the only new options I found and as far as I can tell I don't have to fiddle with them at all.
Without changing anything, the new driver works like a charm, many thanks for improving it, much appreciated!

@Kjell I'm still trying to use the asynchronous libUSB api, but I don't have much free time to do so. If you get something working, I'd be happy to test your code.
*edit* I have an asynchronous version ready, but it uses ~20x more CPU power, because its braindead implemented. I'll push it when its fixed.

Re: example interfacing a STM32F4 with libusb

Posted: Sat Aug 18, 2012 11:23 am
by Mathias
So I added the asynchronous libUSB example. I'm not sure if its elegant or something, from the example point of view it looks quite weired, because there is still a main while loop that processes all the events, but thats how libUSB works. It can't create a callback out of nowhere. For a real application this event handler has to be moved to somewhere sane.

From my point of view I'm done working on this example. The speed is up to what USB FS can do and I even have an example doing something remotely useful. Maybe this thread should be moved back to the code samples forum? Or split into a dev and an example thread?

Re: example interfacing a STM32F4 with libusb

Posted: Sat Aug 18, 2012 11:46 am
by Giovanni
The thread can stay here, I have no time to do all the splitting, probably we need a dedicated global moderator.

About your example, IMHO examples are best kept simple, I suggest to focus it on code readability and freeze it (then you could open another topic in the other forum with all the info and the package).

Giovanni

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 7:22 pm
by kab
with latest trunk i try to compile:

Code: Select all

d:\chibios.git\testhal\STM32F4xx\USB_CDC>make
Compiling ../../../test/test.c
In file included from ../../../os/hal/include/hal.h:35:0,
                 from ../../../test/test.c:30:
../../../os/hal/platforms/STM32F4xx/hal_lld.h:967:2: error: #error "STM32_PLLCLKIN outside acceptable range (STM32_PLLIN_MIN...STM32_PLLIN_MAX)"
../../../os/hal/platforms/STM32F4xx/hal_lld.h:1187:2: error: #error "STM32_PLLI2SVCO outside acceptable range (STM32_PLLVCO_MIN...STM32_PLLVCO_MAX)"
In file included from ../../../os/hal/include/usb.h:314:0,
                 from ../../../os/hal/include/hal.h:60,
                 from ../../../test/test.c:30:
../../../os/hal/platforms/STM32/OTGv1/usb_lld.h:182:2: error: #error "the USB OTG driver requires a 48MHz clock"
make.EXE: *** [build/obj/test.o] Error 1


Only one difference - i change board from Olimex to STM32 F4 Discovery...

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 7:33 pm
by Badger
Have you updated your halconf.h? they have changed and now have USB options

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 7:35 pm
by Giovanni
Correct, and not all STM32 halconf.h are equal, make sure to use the right one for your device.

Giovanni

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 7:49 pm
by kab
once again, i take fresh copy from git and try to compile test.
only once thing is modified - i change board include in Makefile to:

Code: Select all

include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk


nothing else was changed in sources from git. i try to use another halconf.h (from \chibios.git\testhal\STM32F4xx\UART\ and enable USB in it) and got same error.

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 8:02 pm
by kab
i've try again, get fresh copy from git, run make in \chibios.git\testhal\STM32F4xx\USB_CDC\ - all fine, all compiled.

now change
include $(CHIBIOS)/boards/OLIMEX_STM32_E407/board.mk
to
include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk

in Makefile.

try to compile - got same error as above. this test should work with STM F4 Discovery? or some modifications required?

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 8:04 pm
by Giovanni
Are you using an F1 device or an F4 device? USB is different among the two.

Giovanni

Re: example interfacing a STM32F4 with libusb

Posted: Sun Sep 16, 2012 8:13 pm
by kab
i try to compile both (at least one) ))

i have a lot of boards and try to build STM32 F4 Discovery and custom F103RET6 (problem described in another thread).