Jump to content

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!


Link to post
Share on other sites

See " 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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...