plusk01 / stm32-playground

Examples, descriptions, and thoughts about STM32 programming

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

STM32 Playground

This repo is to help me get up to speed on (and remember) various facets of programming STM32 devices. My end goal is to contribute to STM32-based flight controllers and autopilots such as ROSflight. In particular, I will be developing on the BeeCore F3.

Getting Started

A great place to start is with the minimalist directory. It is an independent STM32 project that uses no peripherals and no magic. Undertanding these basics wil help to gain an intuition on what all the drivers, libraries, Makefiles, and linker scripts are doing.

Then, to see the use of the CMSIS and StdPeriph_Driver libs in action, take a look at the f3 folder.

Understanding lib/CMSIS, lib/StdPeriph and the HAL

There are various ways of working with ARM cores in general and the STM32 micros in particular. The ARM company creates standards for so-called ARM processors, which are then implemented by other companies (i.e., STMicroelectronics). ARM has standardized the interface to core features (e.g., registers) through a vendor-independent, header-only hardware abstraction layer called Cortex Microontroller Software Interface Standard (CMSIS), vendors are then able to build off of that, providing further abstractions to components and peripherals that they have chosen to put into their implementation of a given ARM processor. For STM32-based micros, this extended support layer has historically been the Standard Peripheral Library (StdPeriph, or SPL); however, within the last five years STM has been pushing their new product, STM32CubeMX, with its associated HAL as a successor to the SPL.

It seems that the flight controller community has not yet adopted hardware implementations using the Cube and the new HAL, so most of the time you will find a directory named something like StdPeriph in the source code of projects. Further, it can be confusing knowing what to do with the system_stm32f30x.c implementation file. In my opinion, it should be included with the source code and NOT in the library code.

See the discussion on SO CMSIS vs HAL vs Standard Peripherals Library.

Obtaining Official Libraries and Examples

Finding the official STM32 CMSIS, StdPeriph, and examples can be a pain. However, if you search for stm32 standard peripheral libraries, you may be fortunate to find this page. Once you get here, you can find the latest library and example code by clicking the STM32 Standard Peripheral Libraries Expansion button and filtering for your specific STM32 family.

Note that information can also be found by clicking one of the family buttons on the first page. However, the F3 button seems to only have information for STM32F37xx/8xx. If you download an example through the Expansion button for the F3 (like the USB example, STSW-STM32121) you can find up to date CMSIS and StdPeriph libraries.

Relevant Flight Controller Boards

Resources

About

Examples, descriptions, and thoughts about STM32 programming


Languages

Language:C 92.8%Language:Assembly 4.0%Language:HTML 1.8%Language:Makefile 0.8%Language:C++ 0.6%Language:CMake 0.0%