Syntax question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Syntax question

Jump to solution
816 Views
GregDavies
Contributor I

I recently downloaded CodeWarrior to start on a project for a MC9S12XDP512. While I was looking through MC9S12XDP512.h, I came across this line (21322):

 

extern volatile DDRSSTR _DDRS @(REG_BASE + 0x0000024AUL);

 

I've never seen the @ character used in this way in C, and I haven't found a search engine that indexes '@', so I can't search for information. Is this a custom addition to CodeWarrior's C or preprocessor syntax?

Labels (1)
Tags (1)
0 Kudos
1 Solution
681 Views
Lundin
Senior Contributor IV

That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:

 

#define DDRS   (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))

 

That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.

 

My advise is to throw the default CW register maps in the garbage bin and write new ones in C.

 

View solution in original post

0 Kudos
4 Replies
682 Views
Lundin
Senior Contributor IV

That code isn't valid C, it is written in the Codewarrior language. In C, you would have written:

 

#define DDRS   (*(volatile DDRSSTR*)(REG_BASE + 0x0000024AUL))

 

That's just one of many non-standard things in the register map. They made this non-standard @ solution because they couldn't figure out how to provide debug information of registers otherwise.

 

My advise is to throw the default CW register maps in the garbage bin and write new ones in C.

 

0 Kudos
681 Views
GregDavies
Contributor I

Thanks for the reply. I was worried this was the case. I don't suppose Freescale supplies a set of gcc friendly register maps?

0 Kudos
681 Views
bigmac
Specialist III

Hello,

 

This construct is used to map a variable, in this case a hardware register, to a specific address.  This usage is CW specific, and is extensively used within the device header files.

 

Regards,

Mac

 

 

 

0 Kudos
681 Views
Jim_P
Contributor III

taking a guess

 

when defining like this - - - - I believe that the @ means the address of the variable is being defined, not the contents of the variable.   Could be wrong

0 Kudos