2015-12-02 07:27 AM
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
2015-12-14 02:37 AM
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.
2016-02-03 06:39 AM
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 you2016-02-25 01:41 PM
Thumb up !
Thanks Julien