C Programming problem

Status
Not open for further replies.
Hi All.

I'm an audiophile and an electronics designer by day. I have a RC5 remote control design that I have inherited in C that runs my pre-amp, but it interferes with my TV. Unfortunately i'm a Pascal man completely. I have picked up most things, but I need to be able to decipher the constant declarations below. They denote the translation from the decoded manchester input from the IR receiver. But I have searched every thing I can find on google and have found no reference to the syntax used.

Can anyone out there help me to get a binary representation of each of the constant values. i.e. RC_VOLUP etc It's the CBITS line that is really messing me up!

// definitions of remote keys
#define CBITS(x) (((x) & 0x3f) | ((x & 0x40) ? 0x1000 : 0))

#define RC_ECODE (0x10 << 6)
#define RC_NONE 0x0000
#define RC_VOLUP (RC_ECODE|CBITS(16))
#define RC_VOLDOWN (RC_ECODE|CBITS(17))
#define RC_INPUTLEFT (RC_ECODE|CBITS(85))
#define RC_INPUTRIGHT (RC_ECODE|CBITS(86))
#define RC_STANDBY (RC_ECODE|CBITS(12))
#define RC_MUTE (RC_ECODE|CBITS(13))
#define RC_SELECT (RC_ECODE|CBITS(87))

Help please.
 
ok I'm guessing that it is the question mark that is confusing the issue??? it is a ternary operator, basically what it says is (if x logically anded with 0x40 is true then 0x1000 else 0

so we end up with the argument to cbits being anded with 0x3f then or'ed with either 0x1000 or 0 depending on the result of anding the argument with 0x40....

is that clear??

Tony.
 
Status
Not open for further replies.