1 Reply Latest reply on Dec 2, 2016 12:10 AM by user_1377889

    How to handle PSoC5/4 common I2C projects

    user_499366433

      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