We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I am using struct in my code. with LPC1317.
Now if I write:
typedef struct { uint32_t f; union { uint32_t ADR[3]; struct { uint32_t ADR1; uint32_t ADR2; uint32_t ADR3; }; // warning : #40-D expected an identifier }; // warning : #40-D expected an identifier } j;
It generated a warninga s mentioned above. I know it can be solved my naming them.
But in header file of LPC13Uxx.h, this has been done & it don't generate warning.& elements can be accessed also. Below is how its is done in lPc13uxx.h
typedef struct { /*!< (@ 0x50000000) GPIO_PORT Structure */ union { struct { __IO uint8_t B0[32]; /*!< (@ 0x50000000) Byte pin registers port 0; pins PIO0_0 to PIO0_31 */ __IO uint8_t B1[32]; /*!< (@ 0x50000020) Byte pin registers port 1 */ }; __IO uint8_t B[64]; /*!< (@ 0x50000000) Byte pin registers port 0/1 */ }; __I uint32_t RESERVED0[1008]; union { struct { __IO uint32_t W0[32]; /*!< (@ 0x50001000) Word pin registers port 0 */ __IO uint32_t W1[32]; /*!< (@ 0x50001080) Word pin registers port 1 */ }; __IO uint32_t W[64]; /*!< (@ 0x50001000) Word pin registers port 0/1 */ }; __I uint32_t RESERVED1[960]; __IO uint32_t DIR[2]; /*!< (@ 0x50002000) Direction registers port 0/1 */ __I uint32_t RESERVED2[30]; __IO uint32_t MASK[2]; /*!< (@ 0x50002080) Mask register port 0/1 */ __I uint32_t RESERVED3[30]; __IO uint32_t PIN[2]; /*!< (@ 0x50002100) Portpin register port 0 */ __I uint32_t RESERVED4[30]; __IO uint32_t MPIN[2]; /*!< (@ 0x50002180) Masked port register port 0/1 */ __I uint32_t RESERVED5[30]; __IO uint32_t SET[2]; /*!< (@ 0x50002200) Write: Set register for port 0/1 Read: output bits for port 0/1 */ __I uint32_t RESERVED6[30]; __O uint32_t CLR[2]; /*!< (@ 0x50002280) Clear port 0/1 */ __I uint32_t RESERVED7[30]; __O uint32_t NOT[2]; /*!< (@ 0x50002300) Toggle port 0/1 */ } LPC_GPIO_Type;