cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

ZhBo_4667106
New Contributor

Hello,

I configured SPI block on FX3 using this example:  cyfxusbspiregmode – SPI in Register Mode. However, for my application I need to enable interrupt. I will be sending data from FPGA through SPI at any point, so I need to enable RX DONE register. The thing is I know where it's located and know general structure, but don't know how to implement it in C code, since there is no example for SPI interrupt registers. There are examples for GPIO interrupts though.

Thanks!

0 Likes
1 Solution
AliAsgar
Moderator
Moderator

Hello,

When a callback function is given as the second parameter in the 'CyU3PSpiSetConfig()' API instead of 'NULL', all the SPI event interrupts are enabled in the firmware internally. The prototype of SPI event callback function is given in FX3APIGuide page no. 455. Let us know if any help is needed

Best Regards,                                                                                                                                                                                                                   AliAsgar

View solution in original post

0 Likes
3 Replies
AliAsgar
Moderator
Moderator

Hello,

When a callback function is given as the second parameter in the 'CyU3PSpiSetConfig()' API instead of 'NULL', all the SPI event interrupts are enabled in the firmware internally. The prototype of SPI event callback function is given in FX3APIGuide page no. 455. Let us know if any help is needed

Best Regards,                                                                                                                                                                                                                   AliAsgar

View solution in original post

0 Likes
ZhBo_4667106
New Contributor

Thanks for reply, 

So, I first register callback function using:   CyU3PRegisterSpiCallBack ( SpiServiceRoutine), then I pass it to CyU3PSpiSetConfig (&spiConfig, SpiServiceRoutine). Then use servie routine as:

 void SpiServiceRoutine(CyU3PSpiEvt_t evt, CyU3PSpiError_t error) {

swtich(evt){

case CY_U3P_SPI_EVENT_RX_DONE: don something

                       }

}

 

Is my idea right. 

Thanks

0 Likes
AliAsgar
Moderator
Moderator

Hello,

There is no need of registering the callback function using the CyU3PRegisterSpiCallBack() API. The callback function(SpiServiceRoutine) can be defined in the code, and can be used directly in the CyU3PSpiSetConfig() API.

Best Regards,                                                                                                                                                                                AliAsgar

0 Likes