Self initializing UART with Pin Stackign
- October 25, 2023
- 2 replies
- 4048 views
Hello everyone,
I have not conventional question. My purpose is to create code where 2 pins are used as two different interfaces (I2C1 and USART3). I know that pin Stacking option is just theoretical as no code is generated for this interface. I found solution to it as I:
1. Generated normal code for I2C so it works normal
2. defined huart3 struct and mx_UART3_Init all in user code brackets in usat.c /usatr.h the same as it would be generated from ioc file.
3. Code in fucntion HAL_UART_MspInit and HAL_UART_MspDeInit is generated only for one instance USART1 (My debug uart). So i added "else if" for USART3 instance as if it would be generated by cube. The trouble here is that user code bracket is only inside the "if(instance ==USART1)"
And here is my problem code is working fine, trouble is this that every time i change something in ioc file my code from third point is deleted so i need to take care of it and add again my changes.
Is there any way to stop cube from changing this file? Or maybe there is a bracket i can add so cube won't change my code ?