- STM32F series (bxCAN)
- STM32G series
- STM32U series
- STM32H series
- Download and unzip repository to your local drive.
- In your STM32 Cube project, right-click on the project and select
Import... - Select
File Systemfrom theGeneralTab. - Select the
can-libfolder from your local filesystem. - In the dropdown for the
can-libfolder select thesrcandincfolders and hit Finish - Right click the added
can-libfolder in the project root, and selectAdd/remove include pathand hit OK. - Right click on the project and select
Properties - Navigate to
C/C++ Generaland thenPaths and Symbols - Under
Source LocationclickAdd Folder - Select the
can-lib/srcfolder and hit Okay. - Repeat Step 11 for each build configuration.
- Under the
Symbolstab, clickAddto add a new compilation symbol. - Type
STM32_PROCESSORin the name field. - In the value field put the number of the STM32 board that is being used
f0for F0,f1for F1, etc. - Check both the
Add to all configurationsandAdd to all languagescheckboxes and hit OK. - Close the Properties menu.
- You can now include the header files and compile the program with the library.
Example:
#define STM32_PROCESSOR f3 // Board Selection
#include "can_lib.hpp"Example:
$ gcc <...> -DSTM32_PROCESSOR=f4 <...>
| Microcontroller | C/C++ Define Statement |
|---|---|
| STM32Fx | #define STM32_PROCESSOR fx |
| STM32Gx | #define STM32_PROCESSOR gx |
| STM32Ux | #define STM32_PROCESSOR ux |
| STM32Hx | #define STM32_PROCESSOR hx |