You are here

How to handle PSoC5/4 common I2C projects | Cypress Semiconductor

How to handle PSoC5/4 common I2C projects

Summary: 1 Reply, Latest post by Bob Marlowe on 02 Dec 2016 12:10 AM PST
Verified Answers: 0
Last post
Log in to post new comments.
GregL's picture
User
8 posts

Hello Forum

Our company uses a few types of PSoC5 and 4 devices with projects sharing a common code-base for the I2C protocol. With the same instance name for the I2C component, the function names are inherently different between the two families.

PSOC4
SCB_I2CSlaveInitReadBuf();

PSOC5
SCB_SlaveInitReadBuf();

 

Are there any novel suggestions or ideas to keep the function names similar between PSoC families? Thought below of possibly redefining the PSoC5 function names??

#if (ProjType == Project1)
    I2C_R_I2CSlaveInitReadBuf(i2cReadBuffer,  BufferSize);
    I2C_R_I2CSlaveInitWriteBuf(i2cWriteBuffer, BufferSize);
#endif

#if (ProjType == Project2) 
    I2C_R_SlaveInitReadBuf(i2cReadBuffer, BufferSize);
    I2C_R_SlaveInitWriteBuf(i2cWriteBuffer, BufferSize);
    
    #define I2C_R_I2CSlaveInitReadBuf I2C_R_SlaveInitReadBuf
    #define I2C_R_I2CSlaveInitWriteBuf I2C_R_SlaveInitWriteBuf
    #define I2C_R_I2C_SSTAT_WR_CMPLT I2C_R_SSTAT_WR_CMPLT
    #define I2C_R_I2CSlaveStatus I2C_R_SlaveStatus
    #define I2C_R_I2CSlaveGetWriteBufSize I2C_R_SlaveGetWriteBufSize
    #define I2C_R_I2CSlaveClearWriteBuf I2C_R_SlaveClearWriteBuf
    #define I2C_R_I2CSlaveClearWriteStatus I2C_R_SlaveClearWriteStatus
    #define I2C_R_I2C_SSTAT_RD_CMPLT I2C_R_SSTAT_RD_CMPLT
    #define I2C_R_I2CSlaveClearReadBuf I2C_R_SlaveClearReadBuf
    #define I2C_R_I2CSlaveClearReadStatus I2C_R_SlaveClearReadStatus
#endif

With Best Regards
Greg

user_1377889's picture
User
9581 posts

Your #defines will solve your problem, but I would suggest to use in #if conditions as CY_PSOC4 or CY_PSOC5 to be independent from the project. The conditions you find in Creator -> Help -> System Reference Guides.

 

Bob

Log in to post new comments.