Are FX3 API calls thread safe?

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

cross mob
PeBe_4097246
Level 1
Level 1
Welcome!

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.

0 Likes
1 Solution
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

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

Best Regards,
Jayakrishna

View solution in original post

0 Likes
1 Reply
JayakrishnaT_76
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

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

Best Regards,
Jayakrishna
0 Likes