1 Reply Latest reply on Oct 25, 2019 2:45 AM by JayakrishnaT_76

    Are FX3 API calls thread safe?

    PeBe_4097246

      Hi,

       

      Did not find a clear answer in the FX3 API guide, but are API calls like

       

      CyU3PI2cSetConfig()

      CyU3PI2cReceiveBytes()

      CyU3PI2cTransmitBytes()

      CyU3PUartSetConfig()

      ...

       

      made thread safe, meaning can we call them from several ThreadX OS tasks or must we avoid doing that?

       

      Looking forward to your feedback.

        • 1. Re: Are FX3 API calls thread safe?
          JayakrishnaT_76

          Hello,

           

          We do not recommend you to use the APIs from two different threads. Consider I2C example. If you have added CyU3PI2cTransmitBytes() API in thread 1 and CyU3PI2cReceiveBytes() API in thread 2, and if thread 1 starts first. Then CyU3PI2cTransmitBytes() will be called first. This gives the mutex to Transmitter. The mutex will be released only after the data transmission is complete or after a predefined timeout. If the device still has data to be transmitted when thread 1 times out, then Transmitter would still have the mutex. At that time you cannot receive data by using CyU3PI2cReceiveBytes() API. So the data will be either lost or it will have to wait until transmitter release its lock.

           

          Best Regards,

          Jayakrishna