2020-09-29 02:04 AM
There are several places in the code generated by STM32CubeMX where the comments contain the phrase "in this example". For example we have the following in stm32l4xx_hal_msp.c.
/**
* @brief I2C MSP Initialization
* This function configures the hardware resources used in this example
* @param hi2c: I2C handle pointer
* @retval None
*/
void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
It was my understanding that the generated code is suitable for production use and not merely as an example.
2020-09-29 07:17 AM
> It was my understanding that the generated code is suitable for production use
I don't know why you'd think that. Bugs come up in CubeMX generated code all the time. It works most of the time, but it's very much a use at your own risk code generation scheme.
I'm sure having "in this example" in the comments is just a mistake, however.
2020-09-29 07:35 AM
It is described as an 'initialization code generator' and not as an example generator, or some kind of learning tool.
Obviously we review and test the code that it generates, and make our own modifications and additions, but having comments in our production code talking about "this example" doesn't look very professional. These comments lie outside the region that is preserved when you re-generate the project, so if we were to change these we'd have to re-apply the fix.
I'm not saying this is a major defect. I'm guessing this comes from a template somewhere which was originally from an example. But it's a minor nuisance that should be easy to fix.