CY_U3P_ERROR_MUTEX_FAILURE on CyU3PSpiSetSsnLine

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

cross mob
lock attach
Attachments are accessible only for community members.
OfOr_1738446
Level 3
Level 3
First like received 25 replies posted 10 replies posted

Hello,

I'm working on the AN75779 example and i'm adding changes to it. Iv'e added code for SPI from the USBFlashProg example.

Iv'e added my vendor commands for read and write in my CyFxUVCApplnUSBSetupCB (they work).

At run time, I change my 32bit data bus to:

CyU3PMemSet ((uint8_t *)&io_cfg, 0, sizeof(io_cfg));

    io_cfg.isDQ32Bit = CyFalse;

    io_cfg.s0Mode = CY_U3P_SPORT_INACTIVE;

    io_cfg.s1Mode = CY_U3P_SPORT_INACTIVE;

    io_cfg.useUart   = CyFalse;

    io_cfg.useI2C    = CyTrue;

    io_cfg.useI2S    = CyFalse;

    io_cfg.useSpi    = CyTrue;

    io_cfg.lppMode   = CY_U3P_IO_MATRIX_LPP_DEFAULT;

The spi seems to work except that on the last call for CyU3PSpiSetSsnLine(cyTrue) it returns CY_U3P_ERROR_MUTEX_FAILURE:

here:

status = CyU3PSpiSetSsnLine (CyTrue);

            if (status != CY_U3P_SUCCESS)

{

status = 0xC5;

return status;

}

Iv'e attached my code (iv'e added my numeric status errors to find where it gets stuck because I can't debug the code).

Why does this happens? Maybe the problem is that they are on the same thread?

And if you have other sample code it would be great.

Thanks,

Ofer.

0 Likes
1 Solution
YashwantK_46
Moderator
Moderator
Moderator
100 solutions authored 50 solutions authored 50 likes received

Hi,

Please replace static uint8_t glEp0Buffer[32]; with uint8_t glEp0Buffer[4096] __attribute__ ((aligned (32)));

Also, you can't directly change the IO matrix at run time while UVC application thread is already using the GPIF, UART, GPIO and I2C. The UVC applications needs to be stopped including the GPIF state machine and all the blocks need to be de-initialized an


To re-configure the IO matrix, you will have to firstly de-enit the GPIF, UART, GPIO and I2C and then change the IO matrix config to use SPI and I2C and then re-Initialize them.

So, before enableSPI(), you will have to do the following:

1.) Disable GPIF using CyU3PGpifDisable(CyFalse);

2.) Disable GPIO block using CyU3PGpioDeInit();

3.) Disable I2C block using CyU3PI2cDeInit();

4.) Disable UART block using CyU3PUartDeInit();

Every block of the FX3 needs to be de-initialized and then re-initialized accordingly after the IO matrix is modified.


Please do the following and share your findings.

Regards,
Yashwant

View solution in original post

0 Likes
1 Reply
YashwantK_46
Moderator
Moderator
Moderator
100 solutions authored 50 solutions authored 50 likes received

Hi,

Please replace static uint8_t glEp0Buffer[32]; with uint8_t glEp0Buffer[4096] __attribute__ ((aligned (32)));

Also, you can't directly change the IO matrix at run time while UVC application thread is already using the GPIF, UART, GPIO and I2C. The UVC applications needs to be stopped including the GPIF state machine and all the blocks need to be de-initialized an


To re-configure the IO matrix, you will have to firstly de-enit the GPIF, UART, GPIO and I2C and then change the IO matrix config to use SPI and I2C and then re-Initialize them.

So, before enableSPI(), you will have to do the following:

1.) Disable GPIF using CyU3PGpifDisable(CyFalse);

2.) Disable GPIO block using CyU3PGpioDeInit();

3.) Disable I2C block using CyU3PI2cDeInit();

4.) Disable UART block using CyU3PUartDeInit();

Every block of the FX3 needs to be de-initialized and then re-initialized accordingly after the IO matrix is modified.


Please do the following and share your findings.

Regards,
Yashwant

0 Likes