FX3 SPI Interrupt Enable

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.
ZhBo_4667106
Level 1
Level 1
5 replies posted 10 sign-ins 5 sign-ins

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
Moderator
1000 replies posted 250 solutions authored 750 replies posted

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
Moderator
1000 replies posted 250 solutions authored 750 replies posted

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

0 Likes

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

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