GithubHelp home page GithubHelp logo

ailikez / stm32-cmake-cpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jedrzejboczar/stm32-cmake-cpp

0.0 1.0 0.0 9 KB

A template for C++ projects on STM32 microcontrollers. Uses CMake as build system and wraps STM32CubeMX generated code.

License: MIT License

CMake 41.42% Makefile 25.49% C++ 33.10%

stm32-cmake-cpp's Introduction

STM32Cube + CMake + C++

This is a template for creating projects using CMake with STM32CubeMX generation tool. It allows to use C++, but can be easily modified for pure C. For the toolchain.cmake you need to download stm32-cmake (there's a straightforward tutorial on its usage too).

Above all it is just a code snippet. You have to understand it and modify the way you need. Use it however you want.

Usage

First generate the Cube project in the directory src/stm32cube and set the project name in CMakeLists.txt there. Cube code generation options don't matter, but if not needed then set toolchain to "Other Toolchains" and don't copy libraries.

Then do the standard cmake project generation & build, providing the definitions (stm32-cmake for more details and options):

  • CMAKE_BUILD_TYPE --- release/debug build
  • STM32_CHIP --- the MCU used
  • CMAKE_MODULE_PATH --- path to the stm32-cmake module
  • CMAKE_TOOLCHAIN_FILE --- path to the gcc_stm32.cmake toolchain file
  • STM32Cube_DIR --- directory with used STM32Cube repository

Example CMake usage:

> mkdir build/
> cd build/
> cmake
-DCMAKE_BUILD_TYPE=Debug
-DSTM32_CHIP=STM32F407VGT6
-DCMAKE_MODULE_PATH=/opt/stm32-cmake/cmake/
-DCMAKE_TOOLCHAIN_FILE=/opt/stm32-cmake/cmake/gcc_stm32.cmake
-DSTM32Cube_DIR=/opt/STM32Cube_FW_F4_V1.17.0
..

For linux you may use the Makefile provided (but it may be helpful anyway).

Remote operation

Copy the necessary openocd configuration from default scripts (/usr/share/openocd/scripts/) and modify if needed. See example of remote operations in Makefile.

Bridge between STM32Cube and user code

To make the program a little less "hard-coded" you may use the example structure provided in src/stm32cube (stm_config.h, stm_config.cpp, stm_interrupts.cpp). The main idea is to group everything in one place so it can be easily modified.

stm32-cmake-cpp's People

Contributors

jedrzejboczar avatar

Watchers

Ailike avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.