Function strings for interrupt functions starting with @interrupt

Syntax highlighting, code folding, brace matching, code indenting, and function list

Function strings for interrupt functions starting with @interrupt

Postby jafriede » Tue Mar 10, 2009 2:54 pm

With my embedded Cosmic C compiler, interrupt functions are preceded by @interrupt. With this prefix, UEStudio does not show these functions in the function list. I attempted to modify the wordfile adding "@" to the regular expressions like so:

Code: Select all
/Function String = "%^([@_a-zA-Z_0-9^[^]*]+^)[ ^t]+([^p*&:, ^t^[^]a-zA-Z_0-9.!]++)[~;]"
/Function String 1 = "%[@_a-zA-Z_0-9*]*::^([a-zA-Z_0-9^~]+^)[ ^t^p]++([^p*&:, ^t^[^]/*^-'=:&a-zA-Z_0-9./(!]++)[~;]"
/Function String 2 = "%[@_a-zA-Z_0-9][a-zA-Z_0-9^[^]]+[ ^t*]+^([a-zA-Z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./(!]++)[~;]"
/Function String 3 = "%[@_a-zA-Z_0-9*&$^[^]*]+[ ^t]+[a-zA-Z_0-9*&$^[^]]+[ ^t*]+^([a-zA-Z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./(!]++)[~;]"
/Function String 4 = "%[@_a-z_0-9^[^]*]++ [a-z_0-9*^[^]]+[ ^t]++[a-z_0-9*^[^]]+[ ^t]++^([*a-z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-z_0-9./(!]++)[~;]"
/Function String 5 = "%^([@_a-zA-Z_0-9^[^]*]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./()!]++)[~;]"

I'm not great with regular expressions and would appreciate any help.

Below is my function used for receiving messages from a data bus and placing them in a queue. Normal program execution is interrupted when a message is received by the hardware buffer and calls this function.

Code: Select all
@interrupt void can_rx(void)   
{
  volatile unsigned char received_length;
  volatile unsigned char count;

  if (QUEUE_RX.q_count >= MAXQUEUE)
  {
    goto end;  //Queue is full
  }
  else
  {

    QUEUE_RX.q_count++;
    QUEUE_RX.q_rear = (QUEUE_RX.q_rear + 1) % MAXQUEUE;

    QUEUE_RX.Store_RX[QUEUE_RX.q_rear].IDR0 = CANRXFG[0];
    QUEUE_RX.Store_RX[QUEUE_RX.q_rear].IDR1 = CANRXFG[1];
    QUEUE_RX.Store_RX[QUEUE_RX.q_rear].IDR2 = CANRXFG[2];
    QUEUE_RX.Store_RX[QUEUE_RX.q_rear].IDR3 = CANRXFG[3];

    QUEUE_RX.Store_RX[QUEUE_RX.q_rear].DLC = (CANRXFG[12] & 0x0f);  // Lower nibble
    received_length = (QUEUE_RX.Store_RX[QUEUE_RX.q_rear].DLC);

    for (count = 0; count < received_length; count++)
    {
      QUEUE_RX.Store_RX[QUEUE_RX.q_rear].Data[count] = CANRXFG[count+4];
    }
  }
end:
  CANRFLG = CANRFLG | 0x01;
 
}

Thanks!
jafriede
Newbie
 
Posts: 2
Joined: Fri May 02, 2008 9:49 am

Re: Function strings for interrupt functions starting with @interrupt

Postby Mofi » Wed Mar 11, 2009 9:30 am

Function String 3 finds your interrupt function. But I think the function string set can be optimized by using this set:

Code: Select all
/Function String = "%^([a-zA-Z_0-9^[^]*]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./()!]++)[~;]"
/Function String 1 = "%[a-zA-Z_0-9][a-zA-Z_0-9^[^]]+[ ^t*]+^([a-zA-Z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./(!]++)[~;]"
/Function String 2 = "%[@a-zA-Z_0-9*&$^[^]]+[ ^t]+[a-zA-Z_0-9*&$^[^]]+[ ^t*]+^([a-zA-Z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-zA-Z_0-9./(!]++)[~;]"
/Function String 3 = "%[a-z_0-9^[^]*]++ [a-z_0-9*^[^]]+[ ^t]++[a-z_0-9*^[^]]+[ ^t]++^([*a-z_0-9]+^)[ ^t]++([^p*&:, ^t^[^]a-z_0-9./(!]++)[~;]"

Function String 5 = is now Function String = because standard Function String = is just a more restricted version of Function String 5 =.

Function String 1 = is deleted because it is for C++ only (syntax classname::function) and therefore not needed for 'C'. The other 2 function strings are just renumbered.

The duplicate underscore in first [] is removed on all function strings as well as the duplicate * in Function String 2 =.

I have added @ on Function String 2 = which is for "word word functionname(parameters)" and so finds

@interrupt void can_rx(void)
unsigned int foo1()
unsigned long* foo2()
unsigned char foo3 ( int size /*comment*/)
...

If you can't see your interrupt function, disable setting Use Function Tips data (if available) for Function List at Configuration - IDE - IntelliTips - Function Tips.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4054
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Function strings for interrupt functions starting with @interrupt

Postby jafriede » Wed Mar 11, 2009 10:24 am

Thanks Mofi! Works like a charm.
jafriede
Newbie
 
Posts: 2
Joined: Fri May 02, 2008 9:49 am


Return to Syntax Highlighting

cron