2023-07-04 08:18 AM - edited 2023-07-04 08:23 AM
STM32CubeIDE is a big help for a relatively inexperienced embedded programmer like me. However, the program structure it uses isn't ideal for the way I organize my C++ projects. My projects have to interface with lots of devices, for example a GPS receiver connected to a UART. In my way of thinking it would be nice to have a UART class and a GPS class. The UART class would have the UART specific IRQs in it. The GPS class would instantiate an instance of the UART class specific to the UART the GPS is connected to. CubeIDE puts all the IRQs in the stm32h7xx_it.c file. I've been editing these IRQs with the __weak qualifier so I can override them with an IRQ Handler in my UART class. But I have to re-edit the stm32h7xx_it.c file every time I regenerate the code with CubeIDE/MX.
The IRQs have /* USER CODE BEGIN ... */ and /* USER CODE END ... */ inside the function but they don't cover the function signature. The generated code looks like this
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
It would be nice to do something like this
/* USER CODE BEGIN USART1_IRQn 0 */
__weak void USART1_IRQHandler(void)
{
/* USER CODE END USART1_IRQn 0 */
/* USER CODE BEGIN USART1_IRQn 1 */
/* USER CODE END USART1_IRQn 1 */
}
I've tried several variations on this without success. I know I could just put a call to an IRQ handler in my UART class inside the generated code but it would be nice to minimize the number of function calls. Any suggestions or other ideas about how to do this will be greatly appreciated. Thanks.
2023-07-04 08:39 AM - edited 2023-07-04 08:40 AM
Maybe here you can off on or simply exclude it file from build and use own.