Thursday, November 28, 2013

STM32F4xx Libraries

I wrote a tutorial before on how to setup a toolchain and build the STM32F4xx standard peripheral drivers into one convenient library, since then, a few people have asked me about the library, so to make life easier, I downloaded the latest StdPeriph/CMSIS, in addition to a few other libraries that I might need later, and shared everything in one repository, which currently has the following libraries:
Cortex-M  CMSIS      V3.20
STM32F4xx CMSIS      V1.3.0
STM32F4xx StdPeriph  V1.3.0
STM32_USB_Device     V1.1.0
STM32_USB_OTG        V2.1.0
In addition to those, the repository also includes a simple USB device library  (stm32f4xx/USB_Generic) which abstracts all the horrible details of the USB libraries into a very simple generic USB device implementation with just two Bulk endpoints...

To use this library you just pass a struct with two callback functions and the library will call those functions whenever data is received or requested, it's as simple as that, note that it's configured for OTG FS only, it could still be useful if you just want to get USB working and don't have time to go through all the examples.

Finally, repository also includes some examples, a Blinky, a USB_Generic example and some user-space code with libusb.

Building The Libraries:
To build the libraries and examples just type make in the top directory, the top Makefile will pass along all the flags and variables, here are some options you can pass on the command line:

make DEBUG=0
This will build everything with -O2 and no debugging symbols (not recommended)

make DEBUG=1 CFLAGS="-DOSC=xx"
This will build the library with debugging enabled, no optimization and using the given crystal frequency in MHz (for example -DOSC=16)



  1. Have you seen libopencm3 project -

    1. yes I have, very nice project, but not everything is supported yet.

  2. Hi. I'm currently working on an university project.

    I'm developing on a STM32F4-Discovery with an LCD touch screen and the OV9655 camera module. The main part of the project is about image processing.

    At first, I thought on OpenCV for this task. But now after I've been searching on internet for a while, I've realized that it isn't possible, at least that's what I think.

    Today I found this website (your website) and this repository of image processing libraries.I hope you could help me because I don't know where it is or how to add to my code (I'm using CoIDE).
    I will be so much thankful if you help me with this puzzle.

    Best regards and congratulations for your work.

    1. Feel free to use any image processing code or the OV/DCMI drivers from my openmv repository, but I can't really help you with the IDE I'm not familiar with it.