cancel
Showing results for 
Search instead for 
Did you mean: 

CubeMx, Suggestion

JulienD
Senior
Posted on December 02, 2015 at 16:27

Hi,

I'm writing an app which will embed its own DFU. In CubeMx gui, I checked usb as a DFU class. Here's what I get in the main function:

int
main(
void
) {
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC_Init();
MX_CRC_Init();
MX_I2C2_Init();
MX_IWDG_Init();
MX_RTC_Init();
MX_SPI1_Init();
MX_SPI2_Init();
MX_TIM2_Init();
MX_TIM3_Init();
MX_TIM4_Init();
MX_TIM5_Init();
MX_TIM11_Init();
MX_UART4_Init();
MX_UART5_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
MX_USART3_UART_Init();
MX_USB_DEVICE_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while
(1) {
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

The point is: I did not find any elegant way to initialize or not the usb port depending on the user action (typically press a button at boot). Suggestion : put the MX_USB_DEVICE_Init() at the end of the initialization process (as it seems to be) and add a user code section before and after it, in which we will be able to check the custom user action. Of course, if you have a cool way to do it with the current generated code, I'll be pleased to use it ! 😉 Best regards Julien
3 REPLIES 3
Amel NASRI
ST Employee
Posted on December 14, 2015 at 11:37

Hi JulienD,

Your suggestion is shared internally. It will be studied before coming back to you.

-Mayla-

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

stm32cube-t
Senior III
Posted on February 03, 2016 at 15:39

Dear user,

Coming with STM32CubeMX 4.13, you will have the possibility to decide in which order the init calls are made and not to generate the call to the init function at all (in this case it will be up to the user code to call it).

Please try this STM32CubeMX version (coming out soon) and let us know if it answers your request.

Thank you
JulienD
Senior
Posted on February 25, 2016 at 22:41

Thumb up !

Thanks

Julien