What is this Standard Peripheral Library (SPL)?
It’s just a collection of hardware libraries that provide an easy approach to any STM32 ARM programmer. It has support for every peripheral a STM32 micro has like CAN, USB, ADC, Timers, etc. In short it’s a hardware abstraction layer fully covering the STM32.
Why use the ST SPL?
- Reduce coding time by spending less time figuring out 32 bit register values and going through a near thousand page reference manual.
- Take the advantages of the built-in code library of MikroC which other compilers don’t offer.
- SPL is used by most STM32 ARM programmers and so it is a widely used tool with a large community.
- Most books and documents on STM32 ARMs are based on SPL.
- A compiler like MikroC doesn’t give full focus towards STM32. It has other ARM concerns like TI’s TIVA, NXP, etc and so MikroC’s built-in libraries are not 100% compatible with all ST hardware.
- Following the previous point MikroC (at least at the time of writing this article) doesn’t give library support for hardware like the DMA and so there’s incompleteness to some extent. It is also worth noting that depending on MikroC’s library also has the disadvantage of code size and efficiency. It is in general true for every compiler. However MikroC’s IDE is cool enough to do things with ease and that’s why I like it. Unless you are a Maple or Arduino fanboy, you’ll get my point.
- Modified ST Standard Peripheral Library (SPL) as supplied here: STM32 Standard Peripheral Library for MikroC. It works for STM32F10x micros only.
- MikroC PRO for ARM compiler.
- Flash Loader Demo or ST-Link Programmer Software.
- A STM32F10x Development Board.
- A USB-Serial Converter or ST-Link Programmer.
- Some basic components like a mini bread board, connecting wires/jumpers, a LED, a 220Ω 0.25W resistor and a push button.
- Optional debugger hardware.
How to use the Standard Peripheral Library?
First we need to prepare our MikroC PRO for ARM compiler for linking with SPL. I’m assuming that the compiler is preinstalled. First go to the compiler’s installation folder and look for the include folder. In my case, it is:
C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for ARM\Include.
In this folder there’s a file named stdint.h. It’s basically a definition of variable types and other related stuffs. Rename it to stdint (backup).h and copy the new stdint.h file from the supplied folder to this location. We are done here.