This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot add more struct to CMSDK_CM3.h

Dear everyone,

I want to add new struct type called I2C_TypeDef to the CMSDK_CM3.h
I followed the format, added right below the other CMSDK_TypeDef, but strangely the Keil IDE cannot recognize my new type.
Here is what I added


/*------------------- I2C ----------------------------------------------*/
/** @addtogroup I2C
  @{
*/
typedef struct
{

        __IO    uint32_t  PRER; // <h> I2C Prescaler Register   (R/W)    </h>
        __IO    uint32_t  CTR;  // <h> I2C Control Register     (R/W)    </h>
        __O     uint32_t  TXR;  // <h> I2C Transmit Register    (W)        </h>
        __I     uint32_t  RXR;  // <h> I2C Receive Register     (R)        </h>
        union {
                __O   uint32_t  CR;     // <h> I2C Command Register       (W)       </h>
                __I   uint32_t  SR;     // <h> I2C Status Register        (R)       </h>
        };

} I2C_TypeDef;

/*@}*/ /* end of group  I2C */

it is compiled but whenever I try to use the I2C_TypeDef in main, for example,
I2C_TypeDef mySensor;

It doesn't compile with an 'error: unknown type name 'I2C_TypeDef'
I am sure that I have included the CMSDK_CM3.h since the other CMSDK_xxx_typedef work just fine.
Also, when I declare the struct in the same file as the main. It recognizes the struct and now compiles.
Please, anybody know what is the problem? I am using Keil MDK5 by the way. Thank you for any help.

Parents Reply Children