EmbeddedRelated.com
Forums

Converting IAR header files for use on other compilers

Started by alfasud123 May 5, 2004
Hi,

I have inhertited code written on the IAR MSP 430 compiler and uses 
the header file io430x14x1.h which provides definitions of all ports 
to enable simple bit manipulation of the ports.

Problem is I want to evaluate other compilers and hence would like 
this feature supported.

I'd prefer to modify the include files and not re-write the code.

Here's a example of what IAR provide. 

Any suggestions?

------------------------
/* Port 1 Input */
__no_init volatile union
{
  unsigned __READ char P1IN;
  struct
  {
    unsigned __READ char P1IN_0  : 1;
    unsigned __READ char P1IN_1  : 1;
    unsigned __READ char P1IN_2  : 1;
    unsigned __READ char P1IN_3  : 1;
    unsigned __READ char P1IN_4  : 1;
    unsigned __READ char P1IN_5  : 1;
    unsigned __READ char P1IN_6  : 1;
    unsigned __READ char P1IN_7  : 1;
  } P1IN_bit;
} @ 0x0020;


/* Port 1 Output */
__no_init volatile union
{
  unsigned char P1OUT;
  struct
  {
    unsigned char P1OUT_0        : 1;
    unsigned char P1OUT_1        : 1;
    unsigned char P1OUT_2        : 1;
    unsigned char P1OUT_3        : 1;
    unsigned char P1OUT_4        : 1;
    unsigned char P1OUT_5        : 1;
    unsigned char P1OUT_6        : 1;
    unsigned char P1OUT_7        : 1;
  } P1OUT_bit;
} @ 0x0021;
---------



Beginning Microcontrollers with the MSP430

That's an extension to ANSI C in a number of respects:

(a) __no_init is not a standard keyword
(b) No idea what __READ means, but double underscore is reserved for C
system use.
(c) unsigned char x : 1 is an extension to ANSI C as ANSI C requires
unsigned int x : 1 only.
(d) The @ notation is an extension.

You might like to use the standard TI header files that all other
compiler vendors use, which are generated from TI's part description,
are maintained by TI and are distributed to all compiler vendors.  Who
knows why IAR choose not to use them in their latest offering?

It's going to be difficult not to modify your code...

-- Paul.

> -----Original Message-----
> From: alfasud123 [mailto:gregrosser@greg...]
> Sent: 05 May 2004 23:36
> To: msp430@msp4...
> Subject: [msp430] Converting IAR header files for use on 
> other compilers
> 
> 
> Hi,
> 
> I have inhertited code written on the IAR MSP 430 compiler and uses 
> the header file io430x14x1.h which provides definitions of all ports 
> to enable simple bit manipulation of the ports.
> 
> Problem is I want to evaluate other compilers and hence would like 
> this feature supported.
> 
> I'd prefer to modify the include files and not re-write the code.
> 
> Here's a example of what IAR provide. 
> 
> Any suggestions?
> 
> ------------------------
> /* Port 1 Input */
> __no_init volatile union
> {
>   unsigned __READ char P1IN;
>   struct
>   {
>     unsigned __READ char P1IN_0  : 1;
>     unsigned __READ char P1IN_1  : 1;
>     unsigned __READ char P1IN_2  : 1;
>     unsigned __READ char P1IN_3  : 1;
>     unsigned __READ char P1IN_4  : 1;
>     unsigned __READ char P1IN_5  : 1;
>     unsigned __READ char P1IN_6  : 1;
>     unsigned __READ char P1IN_7  : 1;
>   } P1IN_bit;
> } @ 0x0020;
> 
> 
> /* Port 1 Output */
> __no_init volatile union
> {
>   unsigned char P1OUT;
>   struct
>   {
>     unsigned char P1OUT_0        : 1;
>     unsigned char P1OUT_1        : 1;
>     unsigned char P1OUT_2        : 1;
>     unsigned char P1OUT_3        : 1;
>     unsigned char P1OUT_4        : 1;
>     unsigned char P1OUT_5        : 1;
>     unsigned char P1OUT_6        : 1;
>     unsigned char P1OUT_7        : 1;
>   } P1OUT_bit;
> } @ 0x0021;
> ---------
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> ---------------------~-->
> Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
> Now with Pop-Up Blocker. Get it for free!
> http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/CFFolB/TM
> --------------------------
> -------~->
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 

Hello Paul,

> 
> That's an extension to ANSI C in a number of respects:
> 
> (a) __no_init is not a standard keyword
> (b) No idea what __READ means, but double underscore is reserved for C
> system use.
> (c) unsigned char x : 1 is an extension to ANSI C as ANSI C requires
> unsigned int x : 1 only.
> (d) The @ notation is an extension.
> 

Also, there is 

   (e) anonymous structures and unions
 
which are not part of *any* C standard (they are supposed in embedded-C++).
   
 
 Preston
 

Hi,

C has no anonymous objects but unnamed objects; e. g. unnamed padding and
unnamed bit fields.
One example of the standard (6.5.2.5):

int *p = (int []){2, 4};

Rolf

msp430@msp4... schrieb am 10.05.04 20:45:59:
> 
> Hello Paul,
> 
> > 
> > That's an extension to ANSI C in a number of respects:
> > 
> > (a) __no_init is not a standard keyword
> > (b) No idea what __READ means, but double underscore is reserved for C
> > system use.
> > (c) unsigned char x : 1 is an extension to ANSI C as ANSI C requires
> > unsigned int x : 1 only.
> > (d) The @ notation is an extension.
> > 
> 
> Also, there is 
> 
>    (e) anonymous structures and unions
>  
> which are not part of *any* C standard (they are supposed in
embedded-C++).
>    
>  
>  Preston
>  
> 
> 
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 




Rolf,

Preston was on about anonymous unions, something you get in C++ but not
in C.  An anonymous union allows you to omit one part of the
discriminator for field access and has nothing to do with anonymous
objects.

Regards,

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 

> -----Original Message-----
> From: rolf.freitag@rolf... [mailto:rolf.freitag@rolf...] 
> Sent: 10 May 2004 19:56
> To: msp430@msp4...
> Subject: RE: [msp430] Converting IAR header files for use on 
> other compilers
> 
> 
> Hi,
> 
> C has no anonymous objects but unnamed objects; e. g. unnamed 
> padding and unnamed bit fields. One example of the standard (6.5.2.5):
> 
> int *p = (int []){2, 4};
> 
> Rolf
> 
> msp430@msp4... schrieb am 10.05.04 20:45:59:
> > 
> > Hello Paul,
> > 
> > > 
> > > That's an extension to ANSI C in a number of respects:
> > > 
> > > (a) __no_init is not a standard keyword
> > > (b) No idea what __READ means, but double underscore is 
> reserved for 
> > > C system use.
> > > (c) unsigned char x : 1 is an extension to ANSI C as ANSI 
> C requires 
> > > unsigned int x : 1 only.
> > > (d) The @ notation is an extension.
> > > 
> > 
> > Also, there is
> > 
> >    (e) anonymous structures and unions
> >  
> > which are not part of *any* C standard (they are supposed in 
> > embedded-C++).
> >    
> >  
> >  Preston
> >  
> > 
> > 
> > 
> > .
> > 
> >  
> > Yahoo! Groups Links
> > 
> > 
> > 
> >  
> > 
> 
> 
> 
> 
> 
> ------------------------ Yahoo! Groups Sponsor 
> ---------------------~--> Make a clean sweep of pop-up ads. 
> Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for 
> free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/CFFolB/TM
> --------------------------
> -------~->
> 
> .
> 
>  
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 

Paul,

standard C has unnamed unions but as far as i know only as padding.
Example:

typedef struct
{
  unsigned char steps;
    union                     // unnamed union at end of struct for 
padding, see standard
  {
    unsigned char value;
    unsigned char meter;
    unsigned char percent;
  };
}
T_foo;

gcc has no problem with a struct consisting of only one unsigned union; 
mabe that's a gcc and future standards feature.

Rolf


Paul Curtis schrieb:

>Rolf,
>
>Preston was on about anonymous unions, something you get in C++ but not
>in C.  An anonymous union allows you to omit one part of the
>discriminator for field access and has nothing to do with anonymous
>objects.
>
>Regards,
>
>--
>Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
>CrossWorks for MSP430, ARM, and (soon) Atmel AVR processors 
>
>  
>
>>-----Original Message-----
>>From: rolf.freitag@rolf... [mailto:rolf.freitag@rolf...] 
>>Sent: 10 May 2004 19:56
>>To: msp430@msp4...
>>Subject: RE: [msp430] Converting IAR header files for use on 
>>other compilers
>>
>>
>>Hi,
>>
>>C has no anonymous objects but unnamed objects; e. g. unnamed 
>>padding and unnamed bit fields. One example of the standard (6.5.2.5):
>>
>>int *p = (int []){2, 4};
>>
>>Rolf
>>
>>msp430@msp4... schrieb am 10.05.04 20:45:59:
>>    
>>
>>>Hello Paul,
>>>
>>>      
>>>
>>>>That's an extension to ANSI C in a number of respects:
>>>>
>>>>(a) __no_init is not a standard keyword
>>>>(b) No idea what __READ means, but double underscore is 
>>>>        
>>>>
>>reserved for 
>>    
>>
>>>>C system use.
>>>>(c) unsigned char x : 1 is an extension to ANSI C as ANSI 
>>>>        
>>>>
>>C requires 
>>    
>>
>>>>unsigned int x : 1 only.
>>>>(d) The @ notation is an extension.
>>>>
>>>>        
>>>>
>>>Also, there is
>>>
>>>   (e) anonymous structures and unions
>>> 
>>>which are not part of *any* C standard (they are supposed in 
>>>embedded-C++).
>>>   
>>> 
>>> Preston
>>> 
>>>
>>>
>>>
>>>.
>>>
>>> 
>>>Yahoo! Groups Links
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>>
>>
>>
>>------------------------ Yahoo! Groups Sponsor 
>>---------------------~--> Make a clean sweep of pop-up ads. 
>>Yahoo! Companion Toolbar. Now with Pop-Up Blocker. Get it for 
>>free! http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/CFFolB/TM
>>--------------------------
>>-------~->
>>
>>.
>>
>> 
>>Yahoo! Groups Links
>>
>>
>>
>> 
>>
>>
>>    
>>
>
>
>
>.
>
> 
>Yahoo! Groups Links
>
>
>
> 
>
>
>  
>