4 Replies Latest reply on Nov 10, 2020 8:42 PM by YoIs_1298666

    I2C slave error handling for PSoC4000S

    YoIs_1298666

      Hello,

       

      I am considering error handling for I2C slave of PSoC4000S.

      Please see the return value of SCB_I2CSlaveStatus() API.

      [In case of write operation (master -> slave)]

      1. Just program the error handling between /* your error handling here */ and /* your error handling end */.

              if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_CMPLT))

              {

                  if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_OVFL))

                  {

                      /* your error handling here */

                      /* your error handling end */

                  }

                  else if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_ERR))

                  {

                      /* your error handling here */

                     /* your error handling end */

                  }

                  /* your write operation handling here */

                  /* your write operation handling end*/

              }

      2. Just progarm the timeout handling between /* your timeout handling here */ and /* your timeout handling end */.

          for example:

              while(0 != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_WR_BUSY))

              {

                  /* your timeout handling here */

                  /* your timeout handling end */

              }

       

      [In case of read operation (master <- slave)]

      3. Just program the error handling between /* your error handling here */ and /* your error handling end */.

              if (0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_CMPLT))

              {

                  if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_OVFL))

                  {

                      /* your error handling here */

                      /* your error handling end */

                  }

                  else if(0u != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_ERR))

                  {

                      /* your error handling here */

                      /* your error handling end */

                  }

                  /* read operation handling here*/

                  /* read operation handling end*/

              }

       

      4. Just progarm the timeout handling between /* your timeout handling here */ and /* your timeout handling end */.

          for example:

            while(0 != (I2CS_I2CSlaveStatus() & I2CS_I2C_SSTAT_RD_BUSY))

              {

                  /* your timeout handling here */

                  /* your timeout handling end */

              }

       

      Is there anything else I can prepare?

       

      Best regards,

      Yocchi