Skip to content

ukmars/black-pill-demo

Repository files navigation

Simple Test Project to trial maintaining and sharing minimus code.

This simple project is indended to act as a testbed before working on the main application. It serves a number of purposes.

  1. Set the basic project directory structure
  2. Define the .gitignore file to ensure only properly portable content is kept under version control
  3. Describe how to maintain a project from outside the workspace in STM32CubeIDE
  4. Act as a template for further applications
  5. Ilustrate how to connect the stdio functions printf() and scanf(0)to the serial port.
  6. Show how to keep application code separate from the CubeMX generated code.

General notes

  • STM32CubeIDE generates and maintains everything in the Core and Drivers directories
  • The actual application lives in the Application directory.
  • Make sure the project includes list includes ${ProjectDir}/Application
  • Add the Application directory to the list of sources. Check this is done for both Debug and Release configurations
  • The project must be of C++ type
  • In the STM32CubeIDe MX generator, under Project Manager\Code Generator Select the option to generate peripheral initialisation as a pair of '.c/.h' files per peripheral. this lets you include the peripheral descriptions in the user application code.
  • Modify Core/Src/main.c :
    • Near the beginning, find the Private Includes section and modify it to read:
  /* Private includes ----------------------------------------------------------*/
  /* USER CODE BEGIN Includes */
  #include "app_main.h"
  /* USER CODE END Includes */
  • In the main() funtion, find the USER CODE BEGIN 2 section and, in there add a call to app_main():
  /* USER CODE BEGIN 2 */
	app_main();
	/* USER CODE END 2 */
  • Core/Src/main.c should include app_main.h which will declare a single entry point int app_main(void)

Project Structure

.
├── Application   # holds the application source code
├── Core          # holds the CubeMX generated code
│   ├── Inc
│   ├── Src
│   └── Startup
├── Docs          # application documentation
├── Drivers       # generated by the CubeMX configuration
│   ├── CMSIS
│   │   ├── Device
│   │   │   └── ST
│   │   │       └── STM32F4xx
│   │   │           ├── Include
│   │   │           └── Source
│   │   │               └── Templates
│   │   └── Include
│   └── STM32F4xx_HAL_Driver
│       ├── Inc
│       │   └── Legacy
│       └── Src
├── Debug         # build artifacts for Debug configuration
└── Release       # build artifacts for Release configuration

About

A simple STM32CubeIDE project template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages