cancel
Showing results for 
Search instead for 
Did you mean: 

Is there any way to modify the project templates for STM32CubeMx?

Freek Eek
Associate
Posted on August 11, 2017 at 09:39

The enforced project and directory structures created are seriously limiting especially when trying to use STM32CubeMx for defining boards which can run multiple applications or when trying to use the code generated as a library for board functionality, including not being able to generate board.h and board.c instead of main.h and main.c for for encapsulating startup code.  These 'perceived' limitations make it impossible to use STM32CubeMx to maintain these initialisations except for very small projects.  

#stm32cubemx
4 REPLIES 4
Andrian Andria
Associate II
Posted on February 02, 2018 at 17:05

Hello,

I am interested in the solution to

freek

‌'s problem.

1. The directories' structure doesn't fit to our needs. So, It's hard to organize 'properly' our project.

2. In my company we want to use our naming rule for functions, variables, enum,.... I doesn't found a solution to do this without modify each templace file (.ftl) in db/templates. The problem ison each update, these files are replaced so I will loose all my customisation.

Does anyone have a solution for these points (or one of them)?

Thanks a lot.

Posted on February 04, 2018 at 20:12

The problem is on each update, these files are replaced so I will loose all my customisation. 

Assign someone else to track the changes and update your codebase.

Sorry but this looks like the only sensible solution... 

-- pa

henry.dick
Senior II
Posted on February 04, 2018 at 22:03

I am not sure why directory structures would be such a big deal. whatever the structure, so long as you can include it in your project, why do you need to worry about it?

'

I doesn't found a solution to do this without modify each templace file (.ftl) in db/templates.'

to me, it is 2nd nature that OEM libraries are ***NOT*** to be used directly in your project. ***always*** put on top of your OEM libraries a set of your own routines. and you only access OEM libraries through those middle layers. Under this approach, you can freely swap out different OEM libraries or even your own, without having to re-do your code.

Here is an example: say you want to drive a PWM module, set period and prescaler and then set its duty cycle.

 pwm1_init(100, 1000); //initialize pwm1 to prescaler of 100, and period of 1000
 pwm1_setdc2(50); //set pwm1 ch2's duty cycle to 50/1000.
�?�?�?�?�?

the actual implementation of pwm1_init() and pwm1_setdc() vary greatly, depending on the kind of libraries you use: it can be SPL, HAL, LL, or even your own. and when you port the code to different chip, all you need to do is to implement the same code on that target chip / environment.

this approach is fairly standard in any half-decent shop.

Posted on February 08, 2018 at 11:52

So how do I use STM32CubeMx's functionality to not place the initialisations in main.c and not create the main.h, but place it in a separate file (structure) in order to access it as an OEM (or in this case board specific) file/folder structure and not as main.c?