Need help for this syntax: "#define LEDs (char *) 0x0003010"

Posted by Noge on Stack Overflow See other posts from Stack Overflow or by Noge
Published on 2010-06-10T01:51:21Z Indexed on 2010/06/10 2:02 UTC
Read the original article Hit count: 258

Filed under:
|
|
|

I'm doing programming of a softcore processor, Nios II from Altera, below is the code in one of the tutorial, I manage to get the code working by testing it on the hardware (DE2 board), however, I could not understand the code.

#define Switches (volatile char *) 0x0003000
#define LEDs (char *) 0x0003010
void main()
{ while (1)
*LEDs = *Switches;
}

What I know about #define is that, it is either used to define a constant, or a macro, but

  1. why in the above code, there are casting like, (char *) 0x0003010, in #define?
  2. why the 2 constants, Switches and LEDs act like a variable instead of a constant?

Thanks in advance !

© Stack Overflow or respective owner

Related posts about c

    Related posts about casting