STM32 L1 Standard Peripheral Lib Revisited

stm32_icon_bigHello everyone! Today I thought that I might actually share my version of STM32L Standard Peripheral Library that I am using for all my projects. You would probably ask if it is any different from what ST Microelectronics already gave you. Well there are few differences which are presented below. You may also ask why bother switching to my library instead of using ST’s. The main reason for that is, that all of my projects are/will be based on this piece of code, so if you are interested in those you may want to get familiar with my lib. I plan to upload some simple examples (“Hello, World!” like, you know, for basic interfaces, GPIO, SPI, I2C, DMA…), so stay tuned and watch for updates.


  • I’ve got rid of all that CMSIS related sources – since I’m using CodeSourcery toolchain¬†I have no need to have those. To maintain support for all ARM related things I have created separate files like nvic.c, systick.c and so on, which are no different (in terms of usage, from programmer’s point of view, of course) from any other peripheral.
  • I’ve improved code formatting, because I hate it when lines of code have more than 80 characters. That gray, vertical line (a.k.a. “margin”) in your editor exists there for a reason which is called “usability”. Whenever you try to open two source code files in, let’s say, Eclipse IDE then long lines of code can really ruin your day, because not only that you have to scroll up and down but, in addition you need to go from left to right. Bummer!
  • Most of functions have the same name as in ST’s version, but some of those were altered to be more descriptive about what they really do. Nevertheless you should’n have any hard time with that.
  • I made some use of bit-banding feautre in some of those functions, just to improve overall performance.
  • I removed all #define #if and all that macro magic used in *.c files by ST. I find it pretty hard to debug such things.
  • I removed all “asserts“, wasn’t using those anyway…

That’s about it. I’m about to post all my source code in downloads¬†section of this page, so you all can have a better access to it.

Posted in Uncategorized and tagged .