Jump to content
Sign in to follow this  
MSPLife

structure in Capacitive Touch.

Recommended Posts

Hi everyone,

I wanna understand about how the source can define as below while I can not find in any C tutorial about defining a struct.

 

struct Element{
uint8_t *inputPxselRegister;    // PinOsc: port selection address
uint8_t *inputPxsel2Register;   // PinOsc: port selection 2 address
uint8_t *inputPxoutRegister; // PinOsc: port output address
uint8_t *inputPxdirRegister; // PinOsc: port direction address
uint16_t inputBits; // PinOsc: bit definition
uint16_t *baseCnt; // PinOsc: base count
uint16_t *threshold;
};
//a dot '.' make me confuse
const struct Element First ={
.inputPxselRegister = (uint8_t *)&P3SEL,
.inputPxsel2Register = (uint8_t *)&P3SEL2,
.inputPxoutRegister = (uint8_t *)&P3OUT,
.inputPxdirRegister = (uint8_t *)&P3DIR,
.inputBits = BIT3,
.baseCnt = base_cnt,
.threshold = threshold
};

Please help to explain about the '.' at First element.

Thank in advance!

 

Share this post


Link to post
Share on other sites

See "2.4.2.3 Initializing Structure Members" Here https://www.gnu.org/software/gnu-c-manual/gnu-c-manual.html#Declaring-Structure-Variables-After-Definition

 

There are a few other ways to assign constant data in structures. It's not normally seen, I'm not sure why. I find it much easier to read/understand.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×