Page 1 of 1

overriding Serial Driver interrupt

Posted: Tue Apr 24, 2012 3:43 pm
by DeusExMachina
I'm trying to port modbus realization using CMSIS to Ch.
I have to redefine UART2 irq to serve incoming data like this:

Code: Select all

void USART3_IRQHandler(void)
{
   //Receive Data register not empty interrupt
     if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
   {
         USART_ClearITPendingBit(USART3, USART_IT_RXNE);
        uart3.rxtimer=0;

           if(uart3.rxcnt>(BUF_SZ-2))
           uart3.rxcnt=0;

            uart3.buffer[uart3.rxcnt++]=USART_ReceiveData (USART3);


   }

     //Transmission complete interrupt
    if(USART_GetITStatus(USART3, USART_IT_TC) != RESET)
     {

        USART_ClearITPendingBit(USART3, USART_IT_TC);
          if(uart3.txcnt<uart3.txlen)
        {
           USART_SendData(USART3,uart3.buffer[uart3.txcnt++]);
        }
         else
        {
         uart3.txlen=0;
         //rs485 tx disable
         GPIO_WriteBit(GPIOB,GPIO_Pin_2,Bit_RESET);

         USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
         USART_ITConfig(USART3, USART_IT_TC, DISABLE);
        }
     }

}

Is it possible to redefine IRQ Vector assigned to USART2 and using SerialDriver or I had to switch of ch driver and work with hardware without OS layer?

Re: overridind Serial Driver interrupt

Posted: Tue Apr 24, 2012 4:01 pm
by Giovanni
If you are not using the Serial driver then switch it off (or switch off just a specific USART in mcuconf.h) and the IRQ vector will be free for you to use. Kernel services will still be available.

Giovanni

Re: overridind Serial Driver interrupt

Posted: Tue Apr 24, 2012 6:23 pm
by DeusExMachina
I don't want to use CMSIS libs... I'll try to port code using UART driver

Re: overridind Serial Driver interrupt

Posted: Tue Apr 24, 2012 6:25 pm
by Giovanni
If you just want to change the interrupt handler you can rename the interrupt vector in vectors.c so it will jump to your code instead of the normal driver ISR, this way you can use the high level part of the driver and just replace the ISR.

Giovanni

Re: overridind Serial Driver interrupt

Posted: Thu Apr 26, 2012 7:43 am
by DeusExMachina
Finally I include ST Standard Peripherals Library into os\hal\platforms\STM32F1xx\ (I had to modify platform.mk) and switched off USART2 in halconf.h and mcuconf.h
After all I can mix SPL code with chibios HAL abstraction drivers.