overriding Serial Driver interrupt

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

overriding Serial Driver interrupt

Post 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?
Last edited by DeusExMachina on Thu Apr 26, 2012 7:45 am, edited 1 time in total.
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: overridind Serial Driver interrupt

Post 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
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: overridind Serial Driver interrupt

Post by DeusExMachina »

I don't want to use CMSIS libs... I'll try to port code using UART driver
User avatar
Giovanni
Site Admin
Posts: 14895
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: overridind Serial Driver interrupt

Post 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
User avatar
DeusExMachina
Posts: 223
Joined: Tue Apr 03, 2012 5:08 am
Has thanked: 3 times
Been thanked: 3 times

Re: overridind Serial Driver interrupt

Post 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.
Post Reply