3 Replies Latest reply on Dec 2, 2019 3:53 AM by RakshithM_16

    The I2C slave (Cy8kit-145-40xx psoc) is not detected by raspberry pi.

    UlMo_4589691

      SDA(P0.5) and SCL(P3.0). The raspberry detects another I2C. Here is the code. I am using PSoC 4.

       

      #include <project.h>
      uint8 bufSize;
      uint8 readBuffer[] = {1,2,3,4,5,6,7,8,9,10};
      uint8 writeBuffer[10];
      uint8 byteCnt;
      uint8 userArray[10];
      uint32 status;
      
      int main()
      {    
          I2C_1_I2CSlaveInitReadBuf(readBuffer, 10);
          I2C_1_I2CSlaveInitWriteBuf(writeBuffer, 10);
          I2C_1_Start();
          
          readBuffer[2]=11;
         for(;1;)
          {
          status=I2C_1_I2CSlaveStatus();
          if(0u!= (status & !I2C_1_I2C_SSTAT_RD_CMPLT))
          
          {
              I2C_1_I2CSlaveClearReadBuf();
          }
          
              if(I2C_1_I2CSlaveStatus() & I2C_1_I2C_SSTAT_RD_CMPLT)
              {
                  byteCnt=I2C_1_I2CSlaveGetWriteBufSize();
                  for (uint8 i=0; i<byteCnt;i++)
                  {
                      userArray[i]=writeBuffer[i];
                  }
                  I2C_1_I2CSlaveClearWriteStatus();
                  I2C_1_I2CSlaveClearWriteBuf();
              }
          }
      }