[ARM] Some keil syntax questions

Status
Not open for further replies.

love_electronic

Member level 5
Joined
Nov 16, 2010
Messages
93
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,964
Hi
I wanna ask some basic questions regarding keil uvision syntax.
what are the functions of following statement

Code:
#define GPIOCONF(mode, cnf)	((cnf << 2) | (mode))
Is (cnf<<2) shifting 2 times here?

Code:
#define CONFMASKL(pin) ((u32)~(15 << (pin * 4)))
what this statement tells?
 

Those are normal macro definitions.

The first shift the value of 'cnf' 2 bits to the left making room for ORing in 'mode'. I would suppose that mode is in the range 0-3.

The second makes an inverted 32 bit unsigned integer mask of 4 bits dependent on the 'pin' value, range 0-7. Like pin=0: 0xFFFFFFF0, to pin=7: 0x0FFFFFFF
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…