How to handle PSoC5/4 common I2C projects

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
GrLe_1336286
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

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

0 Likes
1 Reply
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes