In my head, I just have to change the IRQ number to use an IRQ function created by me.
With this function I should be able to do what I want ...
But I do not understand what is the IRQ number (in this case is the number 0) and how do I create mine.
Thats not the way it would work. I haven't tried, but I think this way will work:
1. enable serial comms in STMCWB
2. a switch in stm32f10x_MC_it.c, USART_IRQHandler(), rerouting all interrupts to your specific function. The function USART_IRQHandler() is an alias (per #define) and
is the interrupt handler for the UART that is selected with STMCWB, one of USART1_IRQHandler(), USART2_IRQHandler(), USART3_IRQHandler().
3. a switch in main(), calling UI_TaskInit in a different way when you want to claim the UART: UI_TaskInit(UI_INIT_CFG & ~OPT_COM,wConfig,MC_NUM,oMCI,oMCT,s_fwVer);
4. do your own serial GPIO and UART initialization in case, like this (careful, this is code for STM32F103xB):
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
// Init USART1 at pins PB6 (TX) and PB7 (RX)
RCC_APB2PeriphClockCmd( RCC_APB2Periph_USART1, (FunctionalState)ENABLE );
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_Init( USART1, &USART_InitStructure );
GPIO_InitStructure.GPIO_Pin = GPIO_TXD | GPIO_RXD;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init( GPIOB, &GPIO_InitStructure );
GPIO_PinRemapConfig(GPIO_Remap_USART1, (FunctionalState)ENABLE);
USART_Cmd( USART1, (FunctionalState)ENABLE );
USART_ITConfig( USART1, USART_IT_RXNE ..., (FunctionalState)ENABLE);
I would also use DMA to further reduce UART interrupt traffic.